tor-browser

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

require-corp-about-blank.https.html (1825B)


      1 <!doctype html>
      2 <script src=/resources/testharness.js></script>
      3 <script src=/resources/testharnessreport.js></script>
      4 <script>
      5 
      6 promise_test(t => {
      7  return new Promise(resolve => {
      8    window.addEventListener("DOMContentLoaded", resolve);
      9  });
     10 }, "Wait for the DOM to be built.");
     11 
     12 promise_test(async t => {
     13  let iframe = document.createElement("iframe");
     14  let iframe_loaded =  new Promise(resolve => iframe.onload = resolve);
     15  iframe.src = "about:blank";
     16  document.body.appendChild(iframe);
     17 
     18  // The about:blank document can load.
     19  await iframe_loaded;
     20  assert_not_equals(iframe.contentDocument, null);
     21 }, "about:blank can always be embedded by a 'require-corp' document");
     22 
     23 promise_test(async t => {
     24  let iframe_C = document.createElement("iframe");
     25  let iframe_B = document.createElement("iframe");
     26  iframe_B.src = "about:blank";
     27  iframe_C.src = "/common/blank.html";
     28  let iframe_B_loaded = new Promise(resolve => iframe_B.onload = resolve);
     29  document.body.appendChild(iframe_B);
     30 
     31  // The about:blank frame must be able to load.
     32  await iframe_B_loaded;
     33  assert_not_equals(iframe_B.contentDocument, null);
     34  iframe_B.contentDocument.body.appendChild(iframe_C);
     35 
     36 
     37  // The document nested under about:blank must not load because it does not
     38  // specify the Cross-Origin-Embedder-Policy: require-corp header.
     39  // An error page must be displayed instead.
     40  // See https://github.com/whatwg/html/issues/125 for why a timeout is used
     41  // here. Long term all network error handling should be similar and have a
     42  // reliable event.
     43  assert_equals(iframe_C.contentWindow.location.href, "about:blank");
     44  assert_not_equals(iframe_C.contentDocument, null);
     45  await t.step_wait(() => iframe_C.contentDocument === null);
     46 }, "A(B(C)) A=require-corp, B=about:blank, C=no-require-corp => C can't load");
     47 
     48 </script>