Electrolysis/e10s test tips: Difference between revisions
Jump to navigation
Jump to search
(Beginning of a page with tips for making tests e10s compatible) |
(Be clearer about contentWindow and contentDocument) |
||
| Line 33: | Line 33: | ||
== Browser-chrome == | == Browser-chrome == | ||
* Use BrowserTestUtils! | * Use <code>BrowserTestUtils</code>! | ||
** Lots of examples in the tree. | ** Lots of examples in the tree. | ||
** This + ContentTask.spawn make for nice control flow. | ** This + <code>ContentTask.spawn</code> make for nice control flow. | ||
** Can also use <code>browser.messageManager.loadFrameScript("data:,(" + fn.toString() + ")()")</code> | ** Can also use <code>browser.messageManager.loadFrameScript("data:,(" + fn.toString() + ")()")</code> | ||
* browser.contentWindow/contentDocument | * <code>browser.contentWindow/contentDocument</code> | ||
** | ** Tests that use this are asking to fail! | ||
** | ** Replace uses with <code>ContentTask.spawn</code> to retrieve needed information. | ||
Revision as of 21:55, 28 October 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
- Observers:
- Only receive observer notifications for the content process (possibly OK).
SpecialPowers.addObserverdoes the Right Thing (TM).
- Services
- Some services are only available in the parent process (form history, window watcher, etc).
SpecialPowers.loadChromeScriptallows 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.spawnmake 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.spawnto retrieve needed information.