1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/audiochannel/tests/file_audio.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,99 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test audio-channel-changed & visible-audio-channel-changed mozChromeEvent</title> 1.8 +</head> 1.9 +<body> 1.10 + <div id="content"></div> 1.11 + <script> 1.12 + var normalAudio; 1.13 + var contentAudio; 1.14 + var notificationAudio; 1.15 + var alarmAudio; 1.16 + var telephonyAudio; 1.17 + var ringerAudio; 1.18 + var publicnotificationAudio; 1.19 + 1.20 + function playWithAudioType(audio, type) { 1.21 + audio.mozAudioChannelType = type; 1.22 + audio.src = "test.ogg"; 1.23 + audio.loop = true; 1.24 + 1.25 + audio.play(); 1.26 + } 1.27 + 1.28 + function runTest() { 1.29 + // normal channel. 1.30 + normalAudio = new Audio(); 1.31 + playWithAudioType(normalAudio, 'normal'); 1.32 + 1.33 + // content channel. 1.34 + contentAudio = new Audio(); 1.35 + playWithAudioType(contentAudio, 'content'); 1.36 + 1.37 + // notification channel. 1.38 + notificationAudio = new Audio(); 1.39 + playWithAudioType(notificationAudio, 'notification'); 1.40 + 1.41 + // alarm channel. 1.42 + alarmAudio = new Audio(); 1.43 + playWithAudioType(alarmAudio, 'alarm'); 1.44 + 1.45 + // telephony channel. 1.46 + telephonyAudio = new Audio(); 1.47 + playWithAudioType(telephonyAudio, 'telephony'); 1.48 + 1.49 + // ringer channel. 1.50 + ringerAudio = new Audio(); 1.51 + playWithAudioType(ringerAudio, 'ringer'); 1.52 + 1.53 + // publicnotification channel. 1.54 + publicnotificationAudio = new Audio(); 1.55 + playWithAudioType(publicnotificationAudio, 'publicnotification'); 1.56 + 1.57 + window.addEventListener('hashchange', function(event) { 1.58 + if (location.hash == "#pauseAudio") { 1.59 + publicnotificationAudio.pause(); 1.60 + ringerAudio.pause(); 1.61 + telephonyAudio.pause(); 1.62 + } 1.63 + 1.64 + if (location.hash == "#pauseAudioFollowing") { 1.65 + alarmAudio.pause(); 1.66 + notificationAudio.pause(); 1.67 + contentAudio.pause(); 1.68 + normalAudio.pause(); 1.69 + } 1.70 + }, false); 1.71 + } 1.72 + 1.73 + function checkBackgroundStatus() { 1.74 + if (location.hash == "#fg") { 1.75 + runTest(); 1.76 + return; 1.77 + } 1.78 + 1.79 + if (document.hidden) { 1.80 + runTest(); 1.81 + return; 1.82 + } 1.83 + 1.84 + document.addEventListener('visibilitychange', function visibilityChange() { 1.85 + if (document.hidden) { 1.86 + runTest(); 1.87 + } 1.88 + }); 1.89 + } 1.90 + 1.91 + SpecialPowers.pushPermissions( 1.92 + [{ "type": "audio-channel-content", "allow": 1, "context": document }, 1.93 + { "type": "audio-channel-notification", "allow": 1, "context": document }, 1.94 + { "type": "audio-channel-alarm", "allow": 1, "context": document }, 1.95 + { "type": "audio-channel-telephony", "allow": 1, "context": document }, 1.96 + { "type": "audio-channel-ringer", "allow": 1, "context": document }, 1.97 + { "type": "audio-channel-publicnotification", "allow": 1, "context": document }], 1.98 + checkBackgroundStatus); 1.99 + 1.100 + </script> 1.101 +</body> 1.102 +</html>