1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/priority/test_Audio.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Test that frames playing audio get BACKGROUND_PERCEIVABLE priority. 1.8 +--> 1.9 +<head> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <script type="application/javascript" src="../browserElementTestHelpers.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 + 1.16 +<script type="application/javascript;version=1.7"> 1.17 +"use strict"; 1.18 + 1.19 +SimpleTest.waitForExplicitFinish(); 1.20 +browserElementTestHelpers.setEnabledPref(true); 1.21 +browserElementTestHelpers.addPermission(); 1.22 +browserElementTestHelpers.enableProcessPriorityManager(); 1.23 + 1.24 +function runTest() { 1.25 + var iframe = document.createElement('iframe'); 1.26 + iframe.setAttribute('mozbrowser', true); 1.27 + iframe.src = 'file_Audio.html'; 1.28 + 1.29 + var childID = null; 1.30 + expectOnlyOneProcessCreated().then(function(chid) { 1.31 + childID = chid; 1.32 + return Promise.all( 1.33 + [expectPriorityChange(childID, 'FOREGROUND'), 1.34 + expectMozbrowserEvent(iframe, 'loadend'), 1.35 + expectMozbrowserEvent(iframe, 'showmodalprompt').then(function(e) { 1.36 + is(e.detail.message, 'onplay', 'showmodalprompt message'); 1.37 + })] 1.38 + ); 1.39 + }).then(function() { 1.40 + // Send the child process into the background. Because it's playing audio, 1.41 + // it should get priority BACKGROUND_PERCEIVABLE, not vanilla BACKGROUND. 1.42 + var p = expectPriorityChange(childID, 'BACKGROUND_PERCEIVABLE'); 1.43 + iframe.setVisible(false); 1.44 + return p; 1.45 + }).then(function() { 1.46 + var p = expectPriorityChange(childID, 'FOREGROUND'); 1.47 + iframe.setVisible(true); 1.48 + return p; 1.49 + }).then(SimpleTest.finish); 1.50 + 1.51 + document.body.appendChild(iframe); 1.52 +} 1.53 + 1.54 +// This test relies on <audio> elements interacting with the audio channel 1.55 +// service. This is controled by the media.useAudioChannelService pref. 1.56 +addEventListener('testready', function() { 1.57 + SpecialPowers.pushPrefEnv({set: [['media.useAudioChannelService', true]]}, 1.58 + runTest); 1.59 +}); 1.60 + 1.61 +</script> 1.62 +</body> 1.63 +</html>