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