Electrolysis/e10s test tips
Jump to navigation
Jump to search
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.spawn make for nice control flow.
- Can also use
browser.messageManager.loadFrameScript("data:,(" + fn.toString() + ")()")
- browser.contentWindow/contentDocument
- Sometimes "works" due to CPOWs.
- Probably better to use ContentTask.spawn to retrieve needed information.