dom/audiochannel/tests/file_audio.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial