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.
--HG--
extra : rebase_source : 7d22be6f800aa39bbddb976baa2ea7fdfb96a58b
When running tests locally, it's occasionally useful to be able to
increase the number of tests permitted to timeout before declaring the
test run a failure. This patch adds the necessary bits to SimpleTest
and the appropriate amount of plumbing to runtests.py and mach to make
that so.
This reworks how the Mochitest DOMWINDOW and DOCSHELL leak detector works. Rather than
collecting immediately in the top-level script, it sends a message to all processes
telling them to carry out collections. Each process prints out a message when it has
finished the collections. This message is used by the test harness to decide when windows
and docshells for that process should be have been destroyed.
In non-e10s mode, the shutdown leak detector is only run in the parent process, to work
around various issues with leak detection in the thumbnail process tests.
This reworks how the Mochitest DOMWINDOW and DOCSHELL leak detector works. Rather than
collecting immediately in the top-level script, it sends a message to all processes
telling them to carry out collections. Each process prints out a message when it has
finished the collections. This message is used by the test harness to decide when windows
and docshells for that process should be have been destroyed.
This change was generated using the `autopep8` module [1]. To replicate:
$ pip install --upgrade autopep8
$ cd gecko
$ autopep8 -i -a -a -r testing/mochitest --exclude 'testing/mochitest/pywebsocket/*'
[1] https://github.com/hhatto/autopep8
--HG--
extra : rebase_source : fb127187cd488b977981338373d66cc8c735214f
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";
});
--HG--
extra : rebase_source : 9b6ae71407da582cdaa8087b5e367c72fa08a337
A filter is a callable that accepts an iterable of tests and a dictionary of values (e.g mozinfo.info) and returns an iterable of tests. Note filtering can mean modifying tests in addition to removing them. For example, this implements a "timeout-if" tag in the manifest:
from manifestparser import expression
import mozinfo
def timeout_if(tests, values):
for test in tests:
if 'timeout-if' in test:
timeout, condition = test['timeout-if'].split(',', 1)
if expression.parse(condition, **values):
test['timeout'] = timeout
yield test
tests = mp.active_tests(filters=[timeout_if], **mozinfo.info)
--HG--
extra : rebase_source : adead90910811e71e8ea2bb862f2b8e92f2c1bee
Make use of SpecialPowers.isB2G to do the proper detection, and fix
mochitest execution for Mulet to include some B2G-specific prefs.
--HG--
extra : rebase_source : 2683f17794204cdb8b17248c9469f2498085ee81
Some mochitests needs to behave differently when ran on B2G Desktop.
Currently, this is implemented using user agent string detection,
mostly relying on "Mobile" being present and "Android" being absent.
This is only true on B2G Desktop when ran on Try because the mozconfig
defined FXOS_SIMULATOR and that, per bug 1115935, this substring is only
added in this case, but not if just MOZ_B2G is defined. A better
approach is to expose 'isB2G' in SpecialPowers for this kind of
detection.
A filter is a callable that accepts an iterable of tests and a dictionary of values (e.g mozinfo.info) and returns an iterable of tests. Note filtering can mean modifying tests in addition to removing them. For example, this implements a "timeout-if" tag in the manifest:
from manifestparser import expression
import mozinfo
def timeout_if(tests, values):
for test in tests:
if 'timeout-if' in test:
timeout, condition = test['timeout-if'].split(',', 1)
if expression.parse(condition, **values):
test['timeout'] = timeout
yield test
tests = mp.active_tests(filters=[timeout_if], **mozinfo.info)
--HG--
extra : rebase_source : 7afc5d677717279e477d420899ba839073de2d8f