Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Test that high-priority processes downgrade the CPU priority of regular
5 processes.
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>
18 <script type="application/javascript;version=1.7">
19 "use strict";
21 SimpleTest.waitForExplicitFinish();
22 browserElementTestHelpers.setEnabledPref(true);
23 browserElementTestHelpers.addPermission();
24 browserElementTestHelpers.enableProcessPriorityManager();
25 SpecialPowers.addPermission("embed-apps", true, document);
27 function runTest() {
28 var iframe = document.createElement('iframe');
29 iframe.setAttribute('mozbrowser', true);
31 iframe.src = browserElementTestHelpers.emptyPage1;
33 var highPriorityIframe = null;
34 var childID = null;
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;
48 var p = Promise.all(
49 [expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW'),
50 expectMozbrowserEvent(highPriorityIframe, 'loadend')]
51 );
53 document.body.appendChild(highPriorityIframe);
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);
64 document.body.appendChild(iframe);
65 }
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 });
75 </script>
76 </body>
77 </html>