tor-browser

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

postMessage_invalid_targetOrigin.htm (1148B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title> postMessage with invalid targetOrigin raises SyntaxError exception </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="./support/ChildWindowPostMessage.htm"></iframe>
     13 </div>
     14 
     15 <script>
     16 
     17 
     18    var description = "Test Description: " +
     19                      "If the value of the targetOrigin argument is neither a single U+002A ASTERISK character (*), " +
     20                      "a single U+002F SOLIDUS character (/), nor an absolute URL, then throw a SyntaxError exception " +
     21                      "and abort the overall set of steps.";
     22 
     23    var DATA = "InvalidOrigin";
     24    var TARGET = document.querySelector("iframe");
     25 
     26    function PostMessageTest()
     27    {
     28        test(function()
     29        {
     30            assert_throws_dom("SYNTAX_ERR", TARGET.contentWindow.DOMException, function()
     31            {
     32                TARGET.contentWindow.postMessage(DATA, DATA);
     33            });
     34        }, description);
     35    }
     36 </script>
     37 </body>
     38 </html>