Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test audio-channel-changed & visible-audio-channel-changed mozChromeEvent</title> |
michael@0 | 5 | </head> |
michael@0 | 6 | <body> |
michael@0 | 7 | <div id="content"></div> |
michael@0 | 8 | <script> |
michael@0 | 9 | var normalAudio; |
michael@0 | 10 | var contentAudio; |
michael@0 | 11 | var notificationAudio; |
michael@0 | 12 | var alarmAudio; |
michael@0 | 13 | var telephonyAudio; |
michael@0 | 14 | var ringerAudio; |
michael@0 | 15 | var publicnotificationAudio; |
michael@0 | 16 | |
michael@0 | 17 | function playWithAudioType(audio, type) { |
michael@0 | 18 | audio.mozAudioChannelType = type; |
michael@0 | 19 | audio.src = "test.ogg"; |
michael@0 | 20 | audio.loop = true; |
michael@0 | 21 | |
michael@0 | 22 | audio.play(); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function runTest() { |
michael@0 | 26 | // normal channel. |
michael@0 | 27 | normalAudio = new Audio(); |
michael@0 | 28 | playWithAudioType(normalAudio, 'normal'); |
michael@0 | 29 | |
michael@0 | 30 | // content channel. |
michael@0 | 31 | contentAudio = new Audio(); |
michael@0 | 32 | playWithAudioType(contentAudio, 'content'); |
michael@0 | 33 | |
michael@0 | 34 | // notification channel. |
michael@0 | 35 | notificationAudio = new Audio(); |
michael@0 | 36 | playWithAudioType(notificationAudio, 'notification'); |
michael@0 | 37 | |
michael@0 | 38 | // alarm channel. |
michael@0 | 39 | alarmAudio = new Audio(); |
michael@0 | 40 | playWithAudioType(alarmAudio, 'alarm'); |
michael@0 | 41 | |
michael@0 | 42 | // telephony channel. |
michael@0 | 43 | telephonyAudio = new Audio(); |
michael@0 | 44 | playWithAudioType(telephonyAudio, 'telephony'); |
michael@0 | 45 | |
michael@0 | 46 | // ringer channel. |
michael@0 | 47 | ringerAudio = new Audio(); |
michael@0 | 48 | playWithAudioType(ringerAudio, 'ringer'); |
michael@0 | 49 | |
michael@0 | 50 | // publicnotification channel. |
michael@0 | 51 | publicnotificationAudio = new Audio(); |
michael@0 | 52 | playWithAudioType(publicnotificationAudio, 'publicnotification'); |
michael@0 | 53 | |
michael@0 | 54 | window.addEventListener('hashchange', function(event) { |
michael@0 | 55 | if (location.hash == "#pauseAudio") { |
michael@0 | 56 | publicnotificationAudio.pause(); |
michael@0 | 57 | ringerAudio.pause(); |
michael@0 | 58 | telephonyAudio.pause(); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | if (location.hash == "#pauseAudioFollowing") { |
michael@0 | 62 | alarmAudio.pause(); |
michael@0 | 63 | notificationAudio.pause(); |
michael@0 | 64 | contentAudio.pause(); |
michael@0 | 65 | normalAudio.pause(); |
michael@0 | 66 | } |
michael@0 | 67 | }, false); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | function checkBackgroundStatus() { |
michael@0 | 71 | if (location.hash == "#fg") { |
michael@0 | 72 | runTest(); |
michael@0 | 73 | return; |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | if (document.hidden) { |
michael@0 | 77 | runTest(); |
michael@0 | 78 | return; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | document.addEventListener('visibilitychange', function visibilityChange() { |
michael@0 | 82 | if (document.hidden) { |
michael@0 | 83 | runTest(); |
michael@0 | 84 | } |
michael@0 | 85 | }); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | SpecialPowers.pushPermissions( |
michael@0 | 89 | [{ "type": "audio-channel-content", "allow": 1, "context": document }, |
michael@0 | 90 | { "type": "audio-channel-notification", "allow": 1, "context": document }, |
michael@0 | 91 | { "type": "audio-channel-alarm", "allow": 1, "context": document }, |
michael@0 | 92 | { "type": "audio-channel-telephony", "allow": 1, "context": document }, |
michael@0 | 93 | { "type": "audio-channel-ringer", "allow": 1, "context": document }, |
michael@0 | 94 | { "type": "audio-channel-publicnotification", "allow": 1, "context": document }], |
michael@0 | 95 | checkBackgroundStatus); |
michael@0 | 96 | |
michael@0 | 97 | </script> |
michael@0 | 98 | </body> |
michael@0 | 99 | </html> |