Development:Testing arbitrary scenarios with Mochitest
Because of this architecture, it’s possible to run tests on various scenarios without having to find a live site on the Internet that behaves in the way you need to test. (As an example, rather than tracking down sites with Internationalized Domain Names (IDN) in order to see how various parts of Camino’s UI handle IDNs, you can create test pages locally and access them via one of the built-in IDN hosts.)
Unfortunately, Mochitest is only available when building with
ac_add_options --enable-tests in your
mozconfig. You probably want to add this option only in a debug build, as logging output is less useful in a static build; in addition, the static build breaks in Gecko 1.9.0 because of problems linking certain test binaries.
--enable-tests (re)build is complete, you run Mochitest using
$ cd $OBJDIR/_tests/testing/mochitest/
$ python runtests.py
This launches Camino into the Mochitest harness, running from a special Mochitest profile (
$OBJDIR/_tests/testing/mochitest/mochitesttestingprofile/) which is created anew each time the Mochitest harness is launched.
Testing Your Scenario
Gecko’s Mochitest test files are copied to subdirectories of
dom/ for DOM tests, by the build system. For sanity’s sake, you should create your own subfolder for your scenario’s files. Then place all HTML and supporting files for your test into the subfolder you just created. If you need to test cross-site interactions, see this list (formerly found in
automation.py) for supported hosts.
Be sure to set any Camino preferences that are required (Mochitest disables many Camino default preferences for automated testing purposes) and then navigate Camino to your test files using the chosen server name. For example, if you are testing the pop-up blocker on παράδειγμα.δοκιμή and your test file is
$OBJDIR/_tests/testing/mochitest/tests/popups/test.html, navigate to http://sub1.παράδειγμα.δοκιμή/tests/popups/test.html to run your test. If you need to examine any profile files during or following the testings, remember the profile is located in
There is no step 3. When you have completed your test, quit Camino. Happy testing!
For more information about writing tests using advanced features of Mochitest, see the Mochitest documentation on MDC.
Mochitest test files live across the tree in
tests/mochitest/ directories, with some stragglers in
The test harness itself lives in
mozilla/testing/mochitest/, although code in
mozilla/build/pgo/ is also used (e.g.