tor-browser

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

restriction-screen-capture.https.html (1340B)


      1 <!DOCTYPE html>
      2 <title>Prerendering cannot invoke the Screen Capture API</title>
      3 <meta name="variant" content="?target_hint=_self">
      4 <meta name="variant" content="?target_hint=_blank">
      5 <meta name="timeout" content="long">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/common/utils.js"></script>
      9 <script src="../resources/utils.js"></script>
     10 <script src="resources/utils.js"></script>
     11 
     12 <body>
     13 <script>
     14 setup(() => assertSpeculationRulesIsSupported());
     15 
     16 promise_test(async t => {
     17  const uid = token();
     18  const bc = new PrerenderChannel('prerender-channel', uid);
     19 
     20  const gotMessage = new Promise(resolve => {
     21    bc.addEventListener('message', e => {
     22      resolve(e.data);
     23    }, {
     24      once: true
     25    });
     26  });
     27 
     28  // Start prerendering a page that attempts to invoke the Screen Capture API.
     29  // This API is activated-gated so it's expected to fail:
     30  // https://wicg.github.io/nav-speculation/prerendering.html#implicitly-restricted
     31  const rule_extras = {'target_hint': getTargetHint()};
     32  startPrerendering(
     33      `resources/screen-capture.https.html?uid=${uid}`, rule_extras);
     34  const result = await gotMessage;
     35  assert_equals(result, 'InvalidStateError');
     36  bc.close();
     37 }, `prerendering pages should not be able to invoke the Screen Capture API`);
     38 </script>