Closed
Bug 1347482
Opened 8 years ago
Closed 8 years ago
Having a System Add-on as a WebExtension with a content script causes mochitest failures in dom/ to do with enabling prefs in tests
Categories
(Core :: DOM: Core & HTML, defect, P1)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox55 | --- | fixed |
People
(Reporter: standard8, Assigned: standard8)
References
Details
Attachments
(1 file)
We are currently looking at enabling pageshot as a system add-on in the Firefox tree. Our initial experimentations have led us to find a number of test failures on try server:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=4b6533ee47272f4c8712a081af342cdeef12ae1e&selectedJob=83038766&filter-searchStr=tc-M
The failures are for the content based Mochitests. Generally the failures are items like:
dom/workers/test/test_navigator.html | Navigator has no 'connection' property!
dom/workers/test/test_navigator_secureContext.html | Navigator has no 'connection' property!
mock_gamepad.js, line 9: TypeError: navigator.requestGamepadServiceTest is not a function
test_geolocation_is_undefined_when_pref_is_off.html undefined assertion name - got [object Geolocation], expected undefined
test_bug957899.html, line 12: TypeError: navigator.requestWakeLock is not a function
test_presentation_availability.html | navigator.presentation should be available
These tests all have one thing in common: they are setting a preference to enable or disable a feature that's exposed via WebIDL on window.navigator.
The line of code that appears to be causing this due to enabling a WebExtension with a content script is:
https://dxr.mozilla.org/mozilla-central/rev/6d38ad302429c98115c354d643e81987ecec5d3c/toolkit/components/extensions/ExtensionContent.jsm#151
This appears to initialise window.navigator, such that preference changes don't take effect (until the page is reloaded, something I don't think the mochitests can't do).
Assignee | ||
Comment 1•8 years ago
|
||
At the moment, this will block PageShot as a system add-on, for which it is aiming for 54. So we need to find a solution.
For most of the tests, we could either:
1) Skip the test if the preference isn't enabled by default.
2) Set the preference to "on" for tests globally, rather than in the individual tests.
They would work for most of the tests, however `test_geolocation_is_undefined_when_pref_is_off.html` is specifically checking geolocation isn't available when the pref is off, so we'd still have an issue there.
Hence, I'm not sure of what the best way of getting this to work is.
Comment 2•8 years ago
|
||
Boris, do you know what could be going wrong here?
Flags: needinfo?(bzbarsky)
Priority: -- → P1
Comment 3•8 years ago
|
||
Comment 0 explains what's going wrong. The tests are relying on nothing touching navigator before they do their pref-setting, but ExtensionContent.jsm pokes at navigator and gets to run before the test code does.
The right fix is to change the tests to set the pref, wait for the callback that it's set, then create a new iframe and examine the navigator object inside that iframe. That will be created after the pref is set, so will properly take it into account.
Flags: needinfo?(bzbarsky)
Comment 4•8 years ago
|
||
If it helps, we could pretty easily fix ExtensionContent.jsm to avoid touching navigator. The line referenced in comment 0 was originally written that way to avoid having to expose the permission check that enables mozAddonManager to js but we ended up exposing that permission check anyway so I don't think it would be awful to use it instead of looking for navigator.mozAddonManager.
Comment 5•8 years ago
|
||
It might help Mark's specific issue, but the tests are just kinda fragile as things stand, and making them less fragile is a good idea no matter what.
Assignee | ||
Comment 6•8 years ago
|
||
I'm going to start looking at this later this week/start of next.
Assignee: nobody → standard8
Comment hidden (mozreview-request) |
Assignee | ||
Comment 8•8 years ago
|
||
The WIP is as far as I've got so far - it appears the test harness doesn't let you run tests from sub-iframes, so you have to proxy results back to the parent.
So far I've fixed the simplest test, still working out how to do the others.
Comment hidden (mozreview-request) |
Updated•8 years ago
|
Attachment #8853348 -
Flags: review?(bzbarsky) → review?(michael)
Comment 10•8 years ago
|
||
Mark, please watch out: due to bug 1286740 you will NOT get the right emails when that patch is reviewed. :(
Comment 11•8 years ago
|
||
mozreview-review |
Comment on attachment 8853348 [details]
Bug 1347482 - Change various DOM tests to run the navigator checks in sub-iframes.
https://reviewboard.mozilla.org/r/125448/#review129672
LGTM - it would be nice if there was an easy way to do this without the annoying boilerplate, but I can't think of one off of the top of my head, so this will have to do.
Attachment #8853348 -
Flags: review?(michael) → review+
Updated•8 years ago
|
Flags: needinfo?(standard8)
Assignee | ||
Comment 12•8 years ago
|
||
Thank you for the extra notification Boris.
Unfortunately it turns out that there's still some failures I missed (or more were introduced), this patch is good though, so I'll get it landed, and then work on those other issues today.
Flags: needinfo?(standard8)
Comment 13•8 years ago
|
||
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3c68d659c2b7
Change various DOM tests to run the navigator checks in sub-iframes. r=mystor
Comment 14•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•