tor-browser

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

frameElement-siblings.sub.html (1465B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>window.frameElement access to a same-origin-domain sibling</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <iframe src="//{{hosts[][]}}:{{ports[http][0]}}/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessed.html"></iframe>
      8 <iframe src="//{{hosts[][www]}}:{{ports[http][0]}}/html/browsers/windows/nested-browsing-contexts/resources/frameElement-sibling-accessor.html"></iframe>
      9 
     10 <script>
     11 "use strict";
     12 setup({ explicit_done: true });
     13 
     14 window.onload = () => {
     15  promise_test(async () => {
     16    frames[1].postMessage({}, "*");
     17    const result = await waitForMessage();
     18 
     19    assert_equals(result, "SecurityError");
     20  }, "it must give a \"SecurityError\" DOMException if the pages are different-origin domain");
     21 
     22  promise_test(async () => {
     23    document.domain = document.domain;
     24 
     25    frames[0].postMessage({ newDocumentDomain: document.domain }, "*");
     26    assert_equals(await waitForMessage(), "done");
     27 
     28    frames[1].postMessage({ newDocumentDomain: document.domain }, "*");
     29    const result = await waitForMessage();
     30 
     31    assert_equals(result, "HTMLIFrameElement");
     32  }, "it must return the iframe element if the pages are same-origin domain");
     33 
     34  done();
     35 };
     36 
     37 function waitForMessage() {
     38  return new Promise(resolve => {
     39    window.addEventListener("message", e => resolve(e.data), { once: true });
     40  });
     41 }
     42 </script>