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