Closed
Bug 809920
Opened 12 years ago
Closed 12 years ago
Provide test only module to define nsIXULAppInfo for tests
Categories
(Testing :: XPCShell Harness, defect)
Testing
XPCShell Harness
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla21
People
(Reporter: gps, Assigned: gps)
References
Details
(Keywords: dev-doc-complete)
Attachments
(1 file)
7.32 KB,
patch
|
ted
:
review+
|
Details | Diff | Splinter Review |
A common pattern in xpcshell and other test suites is to define nsIXULAppInfo with "dummy" fields to facilitate testing of certain features. There are even cases where the values need to agree across different sets of tests for tests to pass (e.g. the tests for Sync and AddonManager need the same application name otherwise the add-on sync functionality won't work).
I think it would be handy for the common "define nsIXULAppInfo for this test suite" boilerplate code to live in a common test only JS module. If you need app info, you can import this module and call a function. If not or if you don't want the shared/common defaults, you don't.
One can make the argument that all tests may want to share a common nsIXULAppInfo. We could certainly explore that. Although we may have to provide a backdoor via xpcshell.ini, etc to disable this.
I'm filing this bug in xpcshell runner because this problems seems to bite xpcshell tests more than other tests suites since they don't run in the context of a larger XUL application.
Assignee | ||
Comment 1•12 years ago
|
||
I accidentally landed something in https://hg.mozilla.org/services/services-central/rev/4ac2babbafec.
I'd love it if we had a central directory containing generic test-only JSMs like this.
Ted: What's a good place in the tree for generic test-only JSMs? testing/jsms?
Flags: needinfo?(ted)
Comment 4•12 years ago
|
||
Any reason why xpcshell doesn't have a valid nsIXULAppInfo registered at @mozilla.org/xre/app-info;1? Some tests might still want to override it, but xpcshell tests of other modules that happen to refer to Services.appinfo fail with the following exception, because the lazy getter in Services.jsm assumes that xre/app-info implements the nsIXULAppInfo interface.
TEST-UNEXPECTED-FAIL | /Users/ireid/tbird/obj/mozilla-central/_tests/xpcshell/toolkit/modules/tests/xpcshell/test_TelemetryTimestamps.js | Failed: [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]" nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" location: "JS frame :: resource://gre/modules/Services.jsm :: <TOP_LEVEL> :: line 22" data: no] ...
I tripped over this while trying to test TelemetryTimestamps.jsm, which depends on TelemetryPing.jsm, which uses Services.appinfo. Having these buried dependencies fail under the test harness reduces the level of fun being had.
Assignee | ||
Comment 5•12 years ago
|
||
I pretty much copied the JSM from /services/healthreport and didn't modify the original file out of concerns that a lot of FHR code is being uplifted and I want to reduce potential for merge conflicts.
I manually ran a build and verified AppInfo.jsm is installed in the proper location alongside existing testing-only JSMs.
Updated•12 years ago
|
Attachment #709186 -
Flags: review?(ted) → review+
Assignee | ||
Comment 6•12 years ago
|
||
Comment 7•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Comment 8•12 years ago
|
||
For those who come after, the incantation to use this module in your xpcshell test is:
// Work around the fact that XPCSHELL doesn't have a proper app-info XPCOM object
Cu.import("resource://testing-common/AppInfo.jsm");
updateAppInfo();
Comment 9•12 years ago
|
||
I updated MDN accordingly:
https://developer.mozilla.org/en-US/docs/Using_nsIXULAppInfo#Getting_nsIXULAppInfo
Keywords: dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•