|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 Test that frames playing audio get BACKGROUND_PERCEIVABLE priority. |
|
5 --> |
|
6 <head> |
|
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <script type="application/javascript" src="../browserElementTestHelpers.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 |
|
13 <script type="application/javascript;version=1.7"> |
|
14 "use strict"; |
|
15 |
|
16 SimpleTest.waitForExplicitFinish(); |
|
17 browserElementTestHelpers.setEnabledPref(true); |
|
18 browserElementTestHelpers.addPermission(); |
|
19 browserElementTestHelpers.enableProcessPriorityManager(); |
|
20 |
|
21 function runTest() { |
|
22 var iframe = document.createElement('iframe'); |
|
23 iframe.setAttribute('mozbrowser', true); |
|
24 iframe.src = 'file_Audio.html'; |
|
25 |
|
26 var childID = null; |
|
27 expectOnlyOneProcessCreated().then(function(chid) { |
|
28 childID = chid; |
|
29 return Promise.all( |
|
30 [expectPriorityChange(childID, 'FOREGROUND'), |
|
31 expectMozbrowserEvent(iframe, 'loadend'), |
|
32 expectMozbrowserEvent(iframe, 'showmodalprompt').then(function(e) { |
|
33 is(e.detail.message, 'onplay', 'showmodalprompt message'); |
|
34 })] |
|
35 ); |
|
36 }).then(function() { |
|
37 // Send the child process into the background. Because it's playing audio, |
|
38 // it should get priority BACKGROUND_PERCEIVABLE, not vanilla BACKGROUND. |
|
39 var p = expectPriorityChange(childID, 'BACKGROUND_PERCEIVABLE'); |
|
40 iframe.setVisible(false); |
|
41 return p; |
|
42 }).then(function() { |
|
43 var p = expectPriorityChange(childID, 'FOREGROUND'); |
|
44 iframe.setVisible(true); |
|
45 return p; |
|
46 }).then(SimpleTest.finish); |
|
47 |
|
48 document.body.appendChild(iframe); |
|
49 } |
|
50 |
|
51 // This test relies on <audio> elements interacting with the audio channel |
|
52 // service. This is controled by the media.useAudioChannelService pref. |
|
53 addEventListener('testready', function() { |
|
54 SpecialPowers.pushPrefEnv({set: [['media.useAudioChannelService', true]]}, |
|
55 runTest); |
|
56 }); |
|
57 |
|
58 </script> |
|
59 </body> |
|
60 </html> |