summaryrefslogtreecommitdiffstats
path: root/xpcom/tests/unit/test_nsIProcess_stress.js
blob: 802f9d70aa4d28943bae9c60d4ee7f4a2679b875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function run_test() {
  set_process_running_environment();

  var file = get_test_program("TestQuickReturn");
  var tm = Cc["@mozilla.org/thread-manager;1"].getService();

  for (var i = 0; i < 1000; i++) {
    var process = Cc["@mozilla.org/process/util;1"].createInstance(
      Ci.nsIProcess
    );
    process.init(file);

    process.run(false, [], 0);

    try {
      process.kill();
    } catch (e) {}

    // We need to ensure that we process any events on the main thread -
    // this allow threads to clean up properly and avoid out of memory
    // errors during the test.
    tm.spinEventLoopUntilEmpty();
  }
}