dom/tests/mochitest/whatwg/postMessage_joined_helper2.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE html>
     2 <html>
     3 <!--
     4 http://example.org/tests/dom/tests/mochitest/whatwg/postMessage_joined_helper2.html
     5 -->
     6 <head>
     7   <title>postMessage joined domains, innermost frame</title>
     8   <script type="application/javascript" src="browserFu.js"></script>
     9   <script type="application/javascript">
    10     function receiveMessage(evt)
    11     {
    12       var response = "subframe-test-finished";
    14       if (evt.origin !== "http://sub1.test1.example.org")
    15       {
    16         response += " wrong-origin(" + evt.origin + ")";
    17         response += " location(" + window.location.href + ")";
    18       }
    20       if (evt.data !== "start-test")
    21         response += " incorrect-subframe-data(" + evt.data + ")";
    22       if (evt.type !== "message")
    23         response += " wrong-type(" + evt.type + ")";
    24       if (evt.target !== window)
    25       {
    26         response += " wrong-target(" + evt.target + ")";
    27         response += " location(" + window.location.href + ")";
    28       }
    30       if (isMozilla)
    31       {
    32         if (evt.isTrusted !== false)
    33           response += " unexpected-trusted-event";
    34       }
    36       if (evt.source !== window.parent)
    37       {
    38         response += " unexpected-source(" + evt.source + ")";
    39         response += " window-parent-is(" + window.parent + ")";
    40         response += " location(" + window.location.href + ")";
    41       }
    43       // verify that document.domain was actually joined with this domain
    44       try
    45       {
    46         var passed = evt.source.document.domain === document.domain;
    47       }
    48       catch (e)
    49       {
    50       }
    52       if (!passed)
    53         response += " expected-joined-domains";
    55       window.parent.postMessage(response, "http://sub1.test1.example.org");
    56     }
    58     function setup()
    59     {
    60       var oldDomain = document.domain;
    61       var newDomain = "example.org"; // join with parent
    63       document.domain = newDomain;
    65       var target = document.getElementById("location");
    66       target.textContent = "Location: " + oldDomain +
    67                            ", effective domain: " + newDomain;
    69       window.addEventListener("message", receiveMessage, false);
    70     }
    72     window.addEventListener("load", setup, false);
    73   </script>
    74 </head>
    75 <body>
    76 <p id="location">No location!</p>
    77 </body>
    78 </html>

mercurial