File: test_predictor_wrap.js

package info (click to toggle)
thunderbird 1%3A52.9.1-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,709,148 kB
  • sloc: cpp: 5,081,792; ansic: 2,051,951; python: 458,733; java: 241,615; xml: 193,600; asm: 178,649; sh: 81,881; makefile: 24,702; perl: 16,874; objc: 4,389; yacc: 1,816; ada: 1,697; lex: 1,257; pascal: 1,251; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (36 lines) | stat: -rw-r--r-- 1,874 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This is the bit that runs in the parent process when the test begins. Here's
// what happens:
//
//  - Load the entire single-process test in the parent
//  - Setup the test harness within the child process
//  - Send a command to the child to have the single-process test loaded there, as well
//  - Send a command to the child to make the predictor available
//  - run_test_real in the parent
//  - run_test_real does a bunch of pref-setting and other fun things on the parent
//  - once all that's done, it calls run_next_test IN THE PARENT
//  - every time run_next_test is called, it is called IN THE PARENT
//  - the test that gets started then does any parent-side setup that's necessary
//  - once the parent-side setup is done, it calls continue_<testname> IN THE CHILD
//  - when the test is done running on the child, the child calls predictor.reset
//    this causes some code to be run on the parent which, when complete, sends an
//    obserer service notification IN THE PARENT, which causes run_next_test to be
//    called again, bumping us up to the top of the loop outlined here
//  - when the final test is done, cleanup happens IN THE PARENT and we're done
//
// This is a little confusing, but it's what we have to do in order to have some
// things that must run on the parent (the setup - opening cache entries, etc)
// but with most of the test running on the child (calls to the predictor api,
// verification, etc).
//
function run_test() {
  var test_path = do_get_file("../unit/test_predictor.js").path.replace(/\\/g, "/");
  load(test_path);
  do_load_child_test_harness();
  do_test_pending();
  sendCommand("load(\"" + test_path + "\");", function () {
    sendCommand("predictor = Cc[\"@mozilla.org/network/predictor;1\"].getService(Ci.nsINetworkPredictor);", function() {
      run_test_real();
      do_test_finished();
    });
  });
}