Electrolysis/e10s test tips: Difference between revisions
Jump to navigation
Jump to search
(Be clearer about contentWindow and contentDocument) |
Amccreight (talk | contribs) (→Mochitest (plain): add note about raciness of addPermission) |
||
Line 15: | Line 15: | ||
** Prefs should only be set using <code>SpecialPowers</code> (<code>pushPrefEnv</code>). | ** Prefs should only be set using <code>SpecialPowers</code> (<code>pushPrefEnv</code>). | ||
** Getting prefs is fine. | ** Getting prefs is fine. | ||
* Setting permissions | |||
** SpecialPowers.addPermission() is racy, so use SpecialPowers.pushPermissions() instead. | |||
* Observers: | * Observers: |
Revision as of 00:48, 6 November 2015
There isn't a standard formula to use to fix broken tests for e10s. Instead, one has to read the test and look for potential problem areas. Sometimes, it's pretty obvious (there are a lot of browser-chrome tests that use contentWindow or contentDocument). Other times it's much more subtle.
Here are a few tips to look for.
About CPOWs
CPOWs are allowed in tests but tend to be a little flaky (search for "dead CPOW" in bugzilla) so it's probably worth spending a little extra time to use message passing and setting things up "correctly".
Mochitest (plain)
- Setting prefs
- Prefs should only be set using
SpecialPowers
(pushPrefEnv
). - Getting prefs is fine.
- Prefs should only be set using
- Setting permissions
- SpecialPowers.addPermission() is racy, so use SpecialPowers.pushPermissions() instead.
- Observers:
- Only receive observer notifications for the content process (possibly OK).
SpecialPowers.addObserver
does the Right Thing (TM).
- Services
- Some services are only available in the parent process (form history, window watcher, etc).
SpecialPowers.loadChromeScript
allows you to have a "worker" in the parent process with which to communicate.
SpecialPowers.wrap
- Sometimes OK (getting window utils, controller, etc.)
- Sometimes not (getting the chrome window).
- Fixing might require something like loadChromeScript.
SpecialPowers.Cc
- Big red flag. Especially for windowwatcher!
Browser-chrome
- Use
BrowserTestUtils
!- Lots of examples in the tree.
- This +
ContentTask.spawn
make for nice control flow. - Can also use
browser.messageManager.loadFrameScript("data:,(" + fn.toString() + ")()")
browser.contentWindow/contentDocument
- Tests that use this are asking to fail!
- Replace uses with
ContentTask.spawn
to retrieve needed information.