|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 Test that high-priority processes downgrade the CPU priority of regular |
|
5 processes. |
|
6 |
|
7 This is just like test_HighPriorityDowngrade, except instead of waiting for the |
|
8 high-priority process's wake lock to expire, we kill the process by removing |
|
9 its iframe from the DOM. |
|
10 --> |
|
11 <head> |
|
12 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
13 <script type="application/javascript" src="../browserElementTestHelpers.js"></script> |
|
14 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
15 </head> |
|
16 <body> |
|
17 |
|
18 <script type="application/javascript;version=1.7"> |
|
19 "use strict"; |
|
20 |
|
21 SimpleTest.waitForExplicitFinish(); |
|
22 browserElementTestHelpers.setEnabledPref(true); |
|
23 browserElementTestHelpers.addPermission(); |
|
24 browserElementTestHelpers.enableProcessPriorityManager(); |
|
25 SpecialPowers.addPermission("embed-apps", true, document); |
|
26 |
|
27 function runTest() { |
|
28 var iframe = document.createElement('iframe'); |
|
29 iframe.setAttribute('mozbrowser', true); |
|
30 |
|
31 iframe.src = browserElementTestHelpers.emptyPage1; |
|
32 |
|
33 var highPriorityIframe = null; |
|
34 var childID = null; |
|
35 |
|
36 expectProcessCreated().then(function(chid) { |
|
37 childID = chid; |
|
38 return expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL'); |
|
39 }).then(function() { |
|
40 // Create a new, high-priority iframe. |
|
41 highPriorityIframe = document.createElement('iframe'); |
|
42 highPriorityIframe.setAttribute('mozbrowser', true); |
|
43 highPriorityIframe.setAttribute('expecting-system-message', true); |
|
44 highPriorityIframe.setAttribute('mozapptype', 'critical'); |
|
45 highPriorityIframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); |
|
46 highPriorityIframe.src = browserElementTestHelpers.emptyPage2; |
|
47 |
|
48 var p = Promise.all( |
|
49 [expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW'), |
|
50 expectMozbrowserEvent(highPriorityIframe, 'loadend')] |
|
51 ); |
|
52 |
|
53 document.body.appendChild(highPriorityIframe); |
|
54 |
|
55 return p; |
|
56 }).then(function() { |
|
57 // Killing the high-priority iframe should cause our CPU priority to go back |
|
58 // up to regular. |
|
59 var p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL'); |
|
60 document.body.removeChild(highPriorityIframe); |
|
61 return p; |
|
62 }).then(SimpleTest.finish); |
|
63 |
|
64 document.body.appendChild(iframe); |
|
65 } |
|
66 |
|
67 addEventListener('testready', function() { |
|
68 // Cause the CPU wake lock taken on behalf of the high-priority process never |
|
69 // to time out during this test. |
|
70 SpecialPowers.pushPrefEnv( |
|
71 {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 1000]]}, |
|
72 runTest); |
|
73 }); |
|
74 |
|
75 </script> |
|
76 </body> |
|
77 </html> |