tor-browser

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

navigator-plugins.https.html (1564B)


      1 <!DOCTYPE html>
      2 <title>Same-origin prerendering can access navigator.plugins</title>
      3 <meta name="timeout" content="long">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/common/utils.js"></script>
      7 <script src="../resources/utils.js"></script>
      8 <script src="resources/utils.js"></script>
      9 
     10 <body>
     11 <script>
     12 setup(() => {
     13  assertSpeculationRulesIsSupported();
     14  assert_implements_optional(
     15      'plugins' in navigator, 'navigator.plugins is not provided.'
     16    );
     17 });
     18 
     19 promise_test(async t => {
     20  const uid = token();
     21  const bc = new PrerenderChannel('prerender-channel', uid);
     22  t.add_cleanup(_ => bc.close());
     23 
     24  const gotMessage = new Promise(resolve => {
     25    bc.addEventListener('message', e => {
     26      resolve(e.data);
     27    }, {
     28      once: true
     29    });
     30  });
     31 
     32  // Start prerendering a page that attempts to access the navigator.plugins.
     33  startPrerendering(`resources/navigator-plugins.html?uid=${uid}`);
     34  const result = await gotMessage;
     35  const plugins = JSON.parse(result);
     36  assert_equals(plugins.length, navigator.plugins.length);
     37  for (let i = 0; i < plugins.length; ++i) {
     38    const expected_plugin = navigator.plugins[i];
     39    assert_equals(plugins[i].pluginLength, expected_plugin.length);
     40    for (let j = 0; j < plugins[i].pluginLength; ++j) {
     41      assert_equals(plugins[i].pluginTypes[j], expected_plugin[j].type,
     42                    `type of navigator.plugins[${i}].plugin[${j}]`);
     43    }
     44  }
     45 }, 'prerendering page should be able to access the navigator.plugins');
     46 </script>