Project Fission/Enabling Tests with Fission

From MozillaWiki
Jump to: navigation, search

Enabling Tests with Fission

Mochitests-Fission

The Mochitests that are not working with Fission enabled have been annotated with either "skip-if = fission" or "fail-if = fission". Both of these cases need to be fixed.

Cross-Origin Mochitests

Cross-origin (or "xorigin") mode allows for mochitests to be run in a cross origin iframe. Used in conjunction with fission mode, xorigin mode can be used validate site isolation in Firefox.

When cross-origin mode is enabled, the toplevel window runs at "http://mochi.xorigin-test:8888" and individual mochitests are loaded in a cross origin iframe running at "http://mochi.test:8888".

The list of all tests that are currently failing or skipped with xorigin and fission mode enabled can be seen here.

Enabling cross-origin mode

Xorigin mode can be enabled by a flag or environment variable, though at least some tests seem to only work with a flag:

./mach mochitest --enable-xorigin-tests [path to test]
MOZ_XORIGIN_MOCHITEST=1 ./mach mochitest [path to test]

To enable xorigin and fission at the same time:

./mach mochitest --enable-xorigin-tests --enable-fission [path to test]
MOZ_XORIGIN_MOCHITEST=1 ./mach mochitest --enable-fission [path to test]

Failing or hanging tests should be annotated at the manifest level using the "xorigin" keyword, for example:

skip-if = xorigin
fail-if = xorigin

Running cross-origin mochitests in Treeherder

Mochitest-plain jobs with cross-origin and fission mode enabled can be run on treeherder. Search for "M-fis" using the try fuzzy selector (./mach try fuzzy).

Tips for debugging broken xorigin mochitests

URL mismatch

When cross-origin mode is enabled, some test state is passed between the parent frame and the cross-origin test iframe via query string parameters in the test URL. This means some tests cases validating against a URL value may fail when unexpected query parameters are present, e.g. location.href.split("?")[0]

Missing method in xOriginTestRunner

For example, "TypeError: parentRunner.expectChildProcessCrash is not a function at SimpleTest.expectChildProcessCrash".

Since tests are running in a cross-origin iframe, the parent frame's TestRunner instance (i.e. parentRunner) cannot be accessed directly. A method dispatcher is used via postMessage in place of direct method accesses. This error suggests that a method does not exist in the dispatcher. To add a method, first add it as a function to xOriginRunner in SimpleTest.js and also add it to xOriginDispatchMap in TestRunner.js

General Tips

  • To run a mochitest with Fission enabled locally, use --enable-fission with mach test. If the test is marked as a "fail-if" however, then you also need to disable that annotation. Otherwise, the test will report a false success (resulting from an expected fail). The skipped tests do not need this extra step.
  • SpecialPowers.useRemoteSubframes can be used to check if Fission is enabled from a mochitest. In browser mochitests, use gFissionBrowser.
  • SpecialPowers.spawn() is typically used when you have a cross-process iframe and you need to interact with it in some way that is not supported cross-process. In such a case, one can use SpecialPowers.spawn() to send a script over to the process of the iframe to assert and/or return a value.
  • If a test complains that the remote type is “webIsolated=<some URI>”, but it expected “web”, then you can use E10SUtils.isWebRemoteType() instead to check the remote type (added in bug 1574543).
  • JavaScript error: resource://testing-common/content-task.js, line 66: NS_ERROR_NOT_INITIALIZED This means that the message manager has been torn down in the current content process. This can happen if you navigate to another process, then try to use test harness stuff in the original process.
  • Some XPConnect and bindings related tests check that cross-origin operations fail. With Fission, they will fail, but in a different way. These tests can be changed to use http://test1.mochi.test:8888/ (instead of, say, example.org) so that they will be cross-origin but still same-process even with Fission. See bug 1572895. It would probably be good to also check the cross-origin, out-of-process case.
  • JavaScript error: resource:///actors/PageStyleChild.jsm, line 35: SecurityError: Permission denied to access property "document" on cross-origin object This is just an error that always happens, so don’t worry about it if you see it in a specific test.
  • SpecialPowers push and pop for prefs have been fixed to work with Fission, but the equivalent methods for permissions have not been.
  • If the test failure cause is a shutdown hang, leak or crash, reach out to the DOM Fission team, as this is a known Fission issue.