1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Test that a regular (not mozapptype=critical) frame that's expecting a system 1.8 +message gets priority BACKGROUND_PERCEIVABLE when it's in the background. 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 +// Give our origin permission to open browsers, and remove it when the test is complete. 1.27 +var principal = SpecialPowers.wrap(document).nodePrincipal; 1.28 +SpecialPowers.addPermission("browser", true, { url: SpecialPowers.wrap(principal.URI).spec, 1.29 + appId: principal.appId, 1.30 + isInBrowserElement: true }); 1.31 + 1.32 +addEventListener('unload', function() { 1.33 + var principal = SpecialPowers.wrap(document).nodePrincipal; 1.34 + SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec, 1.35 + appId: principal.appId, 1.36 + isInBrowserElement: true }); 1.37 +}); 1.38 + 1.39 +function runTest() { 1.40 + var iframe = document.createElement('iframe'); 1.41 + iframe.setAttribute('mozbrowser', true); 1.42 + iframe.setAttribute('expecting-system-message', true); 1.43 + iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp'); 1.44 + 1.45 + iframe.src = browserElementTestHelpers.emptyPage1; 1.46 + 1.47 + var childID = null; 1.48 + expectOnlyOneProcessCreated().then(function(chid) { 1.49 + childID = chid; 1.50 + return Promise.all( 1.51 + [expectPriorityChange(childID, 'FOREGROUND'), 1.52 + expectMozbrowserEvent(iframe, 'loadend')]); 1.53 + }).then(function() { 1.54 + var p = expectPriorityChange(childID, 'BACKGROUND_PERCEIVABLE'); 1.55 + iframe.setVisible(false); 1.56 + return p; 1.57 + }).then(SimpleTest.finish); 1.58 + 1.59 + document.body.appendChild(iframe); 1.60 +} 1.61 + 1.62 +addEventListener('testready', function() { 1.63 + // We don't want this wake lock to time out during the test; if it did, then 1.64 + // we might see BACKGROUND priority instead of BACKGROUND_PERCEIVABLE. So 1.65 + // set the timeout to a large value. 1.66 + SpecialPowers.pushPrefEnv( 1.67 + {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 99999]]}, 1.68 + runTest); 1.69 +}); 1.70 + 1.71 +</script> 1.72 +</body> 1.73 +</html>