dom/browser-element/mochitest/priority/test_HighPriorityDowngrade2.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial