Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / netwerk / test / unit_ipc / test_predictor_wrap.js
blob24aafe1a09a35bdec8b111cb696dd358c49fc180
1 // This is the bit that runs in the parent process when the test begins. Here's
2 // what happens:
3 //
4 //  - Load the entire single-process test in the parent
5 //  - Setup the test harness within the child process
6 //  - Send a command to the child to have the single-process test loaded there, as well
7 //  - Send a command to the child to make the predictor available
8 //  - run_test_real in the parent
9 //  - run_test_real does a bunch of pref-setting and other fun things on the parent
10 //  - once all that's done, it calls run_next_test IN THE PARENT
11 //  - every time run_next_test is called, it is called IN THE PARENT
12 //  - the test that gets started then does any parent-side setup that's necessary
13 //  - once the parent-side setup is done, it calls continue_<testname> IN THE CHILD
14 //  - when the test is done running on the child, the child calls predictor.reset
15 //    this causes some code to be run on the parent which, when complete, sends an
16 //    obserer service notification IN THE PARENT, which causes run_next_test to be
17 //    called again, bumping us up to the top of the loop outlined here
18 //  - when the final test is done, cleanup happens IN THE PARENT and we're done
20 // This is a little confusing, but it's what we have to do in order to have some
21 // things that must run on the parent (the setup - opening cache entries, etc)
22 // but with most of the test running on the child (calls to the predictor api,
23 // verification, etc).
25 /* import-globals-from ../unit/test_predictor.js */
27 function run_test() {
28   var test_path = do_get_file("../unit/test_predictor.js").path.replace(
29     /\\/g,
30     "/"
31   );
32   load(test_path);
33   do_load_child_test_harness();
34   do_test_pending();
35   sendCommand('load("' + test_path + '");', function () {
36     sendCommand(
37       'predictor = Cc["@mozilla.org/network/predictor;1"].getService(Ci.nsINetworkPredictor);',
38       function () {
39         run_test_real();
40         do_test_finished();
41       }
42     );
43   });