test_predictor_wrap.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  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
  19. //
  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).
  24. //
  25. function run_test() {
  26. var test_path = do_get_file("../unit/test_predictor.js").path.replace(/\\/g, "/");
  27. load(test_path);
  28. do_load_child_test_harness();
  29. do_test_pending();
  30. sendCommand("load(\"" + test_path + "\");", function () {
  31. sendCommand("predictor = Cc[\"@mozilla.org/network/predictor;1\"].getService(Ci.nsINetworkPredictor);", function() {
  32. run_test_real();
  33. do_test_finished();
  34. });
  35. });
  36. }