tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

restriction-audio-setSinkId-with-invalid-sinkId.https.tentative.https.html (2019B)


      1 <!DOCTYPE html>
      2 <title>
      3 Access to the setSinkId of the Audio API with an invalid value is deferred
      4 </title>
      5 <meta name="variant" content="?target_hint=_self">
      6 <meta name="variant" content="?target_hint=_blank">
      7 <meta name="timeout" content="long">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="/common/utils.js"></script>
     11 <script src="../resources/utils.js"></script>
     12 <script src="resources/utils.js"></script>
     13 
     14 <body>
     15 <script>
     16 setup(() => assertSpeculationRulesIsSupported());
     17 
     18 promise_test(async t => {
     19  const uid = token();
     20  const bc = new PrerenderChannel('test-channel', uid);
     21  t.add_cleanup(_ => bc.close());
     22 
     23  const gotMessage = new Promise(resolve => {
     24    bc.addEventListener('message', e => {
     25      resolve(e.data);
     26    }, {
     27      once: true
     28    });
     29  });
     30 
     31  const url = `resources/audio-setSinkId.https.html?sinkId=invalid&uid=${uid}&target_hint=${getTargetHint()}`;
     32  window.open(url, '_blank', 'noopener');
     33 
     34  const result = await gotMessage;
     35  const expected = [
     36    {
     37      event: 'started waiting Audio.setSinkId',
     38      prerendering: true
     39    },
     40    {
     41      event: 'prerendering change',
     42      prerendering: false
     43    },
     44    {
     45      event: 'Audio.setSinkId rejected: NotFoundError',
     46      prerendering: false
     47    },
     48  ];
     49  // The spec, https://wicg.github.io/nav-speculation/prerendering.html#audio-output-patch,
     50  // mentions selectAudioOutput() but this test uses setSinkId() function.
     51  assert_equals(result.length, expected.length);
     52  for (let i = 0; i < result.length; i++) {
     53    assert_equals(result[i].event, expected[i].event, `event${i}`);
     54    assert_equals(result[i].prerendering, expected[i].prerendering,
     55      `prerendering${i}`);
     56  }
     57 
     58  // Send a close signal to PrerenderEventCollector on the prerendered page.
     59  new PrerenderChannel('close', uid).postMessage('');
     60 }, `the access to the setSinkId of Audio API with the invalid sinkId should be
     61    deferred until the prerendered page is activated`);
     62 </script>