Currently code used by many mochitest-browser tests is scattered
throughout the tree in various head.js files. Many similar or identical
helper methods are repeated throughout these files.
This commit introduces a BrowserTestUtils.jsm module and includes it in
the mochitest scope; the idea being these frequently re-implemented
methods can live in a central place.
A TestUtils.jsm module has also been introduced to contain code useful to
all types of tests.
This introduces a new medule ContentTask, which includes a spawn method.
This new method can be used to spawn a task in the content process of a
browser. When called, a promise will be returned which resolves to the
value returned by the task.
This allows you to quickly write test code which can touch the content
and return information without having to write custom framescripts all
the time (The content code can be written inline as a simple generator
definition). ContentTask is automatically included in the scope of
mochitests.
An example use follows:
yield ContentTask.spawn(browser, {}, function* gen_replaceState() {
content.window.history.replaceState({}, "", 'test-entry/');
return "Value that the promise will resolve with";
});