|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 Test that the preallocated process starts up with priority BACKGROUND. |
|
5 --> |
|
6 <head> |
|
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <script type="application/javascript" src="../browserElementTestHelpers.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 |
|
13 <script type="application/javascript;version=1.7"> |
|
14 "use strict"; |
|
15 |
|
16 SimpleTest.waitForExplicitFinish(); |
|
17 browserElementTestHelpers.setEnabledPref(true); |
|
18 browserElementTestHelpers.addPermission(); |
|
19 browserElementTestHelpers.enableProcessPriorityManager(); |
|
20 |
|
21 var preallocationEnabledPref = null; |
|
22 try { |
|
23 preallocationEnabledPref = SpecialPowers.getBoolPref('dom.ipc.processPrelaunch.enabled'); |
|
24 } |
|
25 catch(e) { |
|
26 preallocationEnabledPref = null; |
|
27 } |
|
28 |
|
29 var childID = null; |
|
30 |
|
31 var cleanedUp = false; |
|
32 function cleanUp() |
|
33 { |
|
34 if (cleanedUp) { |
|
35 return; |
|
36 } |
|
37 |
|
38 cleanedUp = true; |
|
39 |
|
40 if (preallocationEnabledPref === null) { |
|
41 SpecialPowers.clearUserPref('dom.ipc.processPrelaunch.enabled'); |
|
42 } else { |
|
43 SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', |
|
44 preallocationEnabledPref); |
|
45 } |
|
46 } |
|
47 |
|
48 // Even if this test times out, we still want to run cleanUp so as to set the |
|
49 // pref back. |
|
50 addEventListener('unload', cleanUp); |
|
51 |
|
52 function runTest() |
|
53 { |
|
54 if (preallocationEnabledPref) { |
|
55 ok(false, "dom.ipc.processPrelaunch.enabled must be " + |
|
56 "false for this test to work."); |
|
57 SimpleTest.finish(); |
|
58 return; |
|
59 } |
|
60 |
|
61 // Ensure that the preallocated process initially gets BACKGROUND priority. |
|
62 // That's it. |
|
63 expectProcessCreated().then(function(childID) { |
|
64 return expectPriorityChange(childID, 'PREALLOC', 'CPU_LOW'); |
|
65 }).then(function() { |
|
66 // We need to set the pref asynchoronously or the preallocated process won't |
|
67 // be shut down. |
|
68 SimpleTest.executeSoon(function(){ |
|
69 cleanUp(); |
|
70 SimpleTest.finish(); |
|
71 }); |
|
72 }); |
|
73 |
|
74 // Setting this pref to true should cause us to prelaunch a process. |
|
75 SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', true); |
|
76 } |
|
77 |
|
78 addEventListener('testready', runTest); |
|
79 </script> |
|
80 </body> |
|
81 </html> |