tor-browser

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

workers-coep-report.https.html (1539B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Multiple globals for Worker constructor: COEP reports</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <!-- This is the entry global -->
      8 
      9 <iframe src="incumbent/incumbent.html"></iframe>
     10 <button onclick="" id="button">Hello</button>
     11 
     12 <script>
     13 async function observeReports(global) {
     14  const reports = [];
     15  const observer = new global.ReportingObserver((rs) => {
     16    for (const r of rs) {
     17      reports.push(r.toJSON());
     18    }
     19  });
     20  observer.observe();
     21 
     22  // Wait 5000ms for reports to settle.
     23  await new Promise(r => step_timeout(r, 5000));
     24  return reports;
     25 }
     26 
     27 async_test((t) => {
     28  onload = t.step_func(() => {
     29    Promise.all([
     30      observeReports(window),
     31      observeReports(frames[0]),
     32      observeReports(frames[0].frames[0])
     33    ]).then(t.step_func_done(([entry, incumbent, current]) => {
     34      assert_equals(entry.length, 0);
     35      assert_equals(incumbent.length, 0);
     36      assert_equals(current.length, 1);
     37      const report = current[0];
     38      assert_equals(report.type, 'coep');
     39      assert_equals(report.url, new URL('current/current.html', location.href).href);
     40      assert_equals(report.body.type, 'worker initialization');
     41      assert_equals(report.body.blockedURL, new URL('current/worker.js', location.href).href);
     42      assert_equals(report.body.disposition, 'enforce');
     43    }));
     44 
     45    frames[0].hello();
     46  });
     47  onmessage = t.unreached_func('worker should have been blocked by COEP');
     48 });
     49 </script>