Open
Bug 1181268
Opened 9 years ago
Updated 2 years ago
add a way to mock services in xpcshell tests
Categories
(DevTools :: Framework, enhancement, P3)
DevTools
Framework
Tracking
(Not tracked)
NEW
People
(Reporter: tromey, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
patch
|
Details | Diff | Splinter Review |
I tried to create a new subtype of DevToolsLoader that would allow mocking
services. This way, more tests could be written as xpcshell tests rather than
mochitests.
See the attached patch.
This approach fails because, we think, the DevToolsLoader binds "require" to
its own "this", which happens too early. This results on a call being made
on an object that doesn't have _mockedServices set, leading to this trace:
0:00.09 LOG: Thread-1 ERROR TypeError: invalid 'in' operand this._mockedServices at /home/tromey/firefox-git/gecko-dev/obj-x86_64-unknown-linux-gnu/_tests/xpcshell/toolkit/devtools/tests/unit/head_devtools.js:33
DevToolsTestLoader.prototype.lazyServiceGetter@/home/tromey/firefox-git/gecko-dev/obj-x86_64-unknown-linux-gnu/_tests/xpcshell/toolkit/devtools/tests/unit/head_devtools.js:33:1
@resource://gre/modules/devtools/css-color.js:444:1
DevToolsLoader.prototype.require@resource://gre/modules/devtools/Loader.jsm:302:12
@/home/tromey/firefox-git/gecko-dev/obj-x86_64-unknown-linux-gnu/_tests/xpcshell/toolkit/devtools/tests/unit/test_cssColor.js:35:22
load_file@/home/tromey/firefox-git/gecko-dev/testing/xpcshell/head.js:600:7
_load_files@/home/tromey/firefox-git/gecko-dev/testing/xpcshell/head.js:612:3
_execute_test@/home/tromey/firefox-git/gecko-dev/testing/xpcshell/head.js:494:3
It would be nice if the loader supported this sort of mocking or subtyping.
Reporter | ||
Comment 1•9 years ago
|
||
Updated•7 years ago
|
Severity: normal → enhancement
Priority: -- → P3
Updated•6 years ago
|
Product: Firefox → DevTools
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•