1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/priority/test_HighPriorityDowngrade.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Test that high-priority processes downgrade the CPU priority of regular 1.8 +processes. 1.9 +--> 1.10 +<head> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="../browserElementTestHelpers.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 + 1.17 +<script type="application/javascript;version=1.7"> 1.18 +"use strict"; 1.19 + 1.20 +SimpleTest.waitForExplicitFinish(); 1.21 +browserElementTestHelpers.setEnabledPref(true); 1.22 +browserElementTestHelpers.addPermission(); 1.23 +browserElementTestHelpers.enableProcessPriorityManager(); 1.24 +SpecialPowers.addPermission("embed-apps", true, document); 1.25 + 1.26 +var iframe = null; 1.27 +var childID = null; 1.28 + 1.29 +function runTest() { 1.30 + var iframe = document.createElement('iframe'); 1.31 + iframe.setAttribute('mozbrowser', true); 1.32 + 1.33 + iframe.src = browserElementTestHelpers.emptyPage1; 1.34 + 1.35 + var highPriorityIframe = null; 1.36 + var childID = null; 1.37 + 1.38 + expectProcessCreated().then(function(chid) { 1.39 + childID = chid; 1.40 + return expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL'); 1.41 + }).then(function() { 1.42 + // Create a new, high-priority iframe. 1.43 + highPriorityIframe = document.createElement('iframe'); 1.44 + highPriorityIframe.setAttribute('mozbrowser', true); 1.45 + highPriorityIframe.setAttribute('expecting-system-message', true); 1.46 + highPriorityIframe.setAttribute('mozapptype', 'critical'); 1.47 + highPriorityIframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); 1.48 + highPriorityIframe.src = browserElementTestHelpers.emptyPage2; 1.49 + 1.50 + var p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW'); 1.51 + 1.52 + document.body.appendChild(highPriorityIframe); 1.53 + 1.54 + return p; 1.55 + }).then(function() { 1.56 + return expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL'); 1.57 + }).then(SimpleTest.finish); 1.58 + 1.59 + document.body.appendChild(iframe); 1.60 +} 1.61 + 1.62 +addEventListener('testready', function() { 1.63 + // Cause the CPU wake lock taken on behalf of the high-priority process to 1.64 + // time out after 1s. 1.65 + SpecialPowers.pushPrefEnv( 1.66 + {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 1]]}, 1.67 + runTest); 1.68 +}); 1.69 + 1.70 +</script> 1.71 +</body> 1.72 +</html>