New issue
Advanced search Search tips

Issue 844820 link

Starred by 5 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 2
Type: Bug

Blocking:
issue 525224



Sign in to add a comment

Eliminate/replace usage of mock4js

Project Member Reported by dpa...@chromium.org, May 19 2018

Issue description

mock4js is a fairly old library for creating mock Javascript objects for testing purposes.

In its own github page [1], it states:

"This library has been made available on NPM for legacy code that still depends on mock4js. If you are looking for a mocking library for new code than you should look at either Sinon.jS or mochito."

Besides just being old and having no OWNER in Chrome (see [2], the library is relying on "new Function()" constructor, which is basically eval(), which in turn causes several WebUI code to allow eval() in CSP just so that tests are passing, see more context at issue 525224.

It is unclear if a replacement library is needed at all, or if existing WebUI testing infrastructure like TestBrowserProxy [3] is sufficient (needs to be investigated).

[1] https://github.com/BladeRunnerJS/mock4js
[2] https://cs.chromium.org/chromium/src/chrome/third_party/mock4js/
[3] https://cs.chromium.org/chromium/src/chrome/test/data/webui/test_browser_proxy.js
 

Comment 1 by dpa...@chromium.org, May 19 2018

Blocking: 525224

Comment 2 by dpa...@chromium.org, May 21 2018

So Mock4JS usage seems to be exposed by test_api.js via various helper methods, see [1]. Next step in the investigation would be to identify exactly where are those helper methods being used and see what can be done to replace such usages with something else.

[1] https://cs.chromium.org/chromium/src/chrome/test/data/webui/test_api.js?l=1727

Sign in to add a comment