tor-browser

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

event.source.xorigin.sub.htm (1512B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title> Corss-origin: event.source returns the WindowProxy of the source window </title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 </head>
      8 <body>
      9 <div id=log></div>
     10 
     11 <div style="display:none">
     12    <iframe width="70%" onload="PostMessageTest()" src="{{location[scheme]}}://{{domains[www1]}}:{{location[port]}}/webmessaging/support/ChildWindowPostMessage.htm"></iframe>
     13 </div>
     14 
     15 <script>
     16 
     17    var description = "Test Description: Cross-origin: event.source returns the WindowProxy of the source window.";
     18 
     19    var t = async_test(description);
     20 
     21    var PORT = location.port !== "" ? ":" + location.port : "";
     22    var DATA = "foo";
     23    var TARGET = document.querySelector("iframe");
     24    var XORIGIN = "{{location[scheme]}}://{{domains[www1]}}" + PORT;
     25    var ExpectedResult = [XORIGIN, "AccessCookieDenied"];
     26    var ActualResult = [];
     27 
     28    function PostMessageTest()
     29    {
     30        TARGET.contentWindow.postMessage(DATA, XORIGIN);
     31    }
     32 
     33    window.onmessage = t.step_func(function(e)
     34    {
     35        try
     36        {
     37            var sdomainCookie = e.source.document.cookie;
     38            ActualResult.push(e.origin, "AccessCookieAllowed");
     39        }
     40        catch(ex)
     41        {
     42            ActualResult.push(e.origin, "AccessCookieDenied");
     43        }
     44 
     45        assert_equals(e.source.parent, window);
     46        assert_array_equals(ActualResult, ExpectedResult, "ActualResult");
     47        t.done();
     48    });
     49 </script>
     50 </body>
     51 </html>