summaryrefslogtreecommitdiffstats
path: root/dom/browser-element/mochitest/priority/test_Preallocated.html
blob: b2cb0335ee6d37676f18610632676424c56cf2b7 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE HTML>
<html>
<!--
Test that the preallocated process starts up with priority BACKGROUND.
-->
<head>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>

<script type="application/javascript;version=1.7">
"use strict";

SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
browserElementTestHelpers.enableProcessPriorityManager();

var preallocationEnabledPref = null;
try {
  preallocationEnabledPref = SpecialPowers.getBoolPref('dom.ipc.processPrelaunch.enabled');
}
catch(e) {
  preallocationEnabledPref = null;
}

var childID = null;

var cleanedUp = false;
function cleanUp()
{
  if (cleanedUp) {
    return;
  }

  cleanedUp = true;
}

// Even if this test times out, we still want to run cleanUp so as to set the
// pref back.
addEventListener('unload', cleanUp);

function runTest()
{
  if (preallocationEnabledPref) {
    ok(false, "dom.ipc.processPrelaunch.enabled must be " +
              "false for this test to work.");
    SimpleTest.finish();
    return;
  }

  // Ensure that the preallocated process initially gets BACKGROUND priority.
  // That's it.
  expectProcessCreated('PREALLOC').then(function() {
    // We need to set the pref asynchoronously or the preallocated process won't
    // be shut down.
    SimpleTest.executeSoon(function(){
      cleanUp();
      SimpleTest.finish();
    });
  });
}
// Setting this pref to true should cause us to prelaunch a process.
addEventListener('testready', function() {
  SpecialPowers.pushPrefEnv({'set':[["dom.ipc.processPrelaunch.enabled",true]]},runTest);
});
</script>
</body>
</html>