content/base/test/test_bug353334.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=353334
     5 -->
     6 <head>
     7   <title>Test for Bug 353334</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10   <script>var x = "PASS"</script>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=353334">Mozilla Bug 353334</a>
    14 <p id="display">
    15 <iframe id="one"></iframe>
    16 <object id="two" data="about:blank"></object>
    17 <iframe id="three" src="data:text/html,<body>test</body>"></iframe>
    18 <object id="four" data="data:text/html,<body>test</body>"></object>
    19 <iframe id="five" src="javascript:parent.x"></iframe>
    20 <object id="six" data="javascript:x"></object>
    21 </p>
    22 <div id="content" style="display: none">
    24 </div>
    25 <pre id="test">
    26 <script class="testbody" type="text/javascript">
    28 /** Test for Bug 353334 **/
    29 SimpleTest.waitForExplicitFinish();
    31 function doPrincipalTest(id) {
    32   var doc = SpecialPowers.wrap($(id).contentDocument);
    34   isnot(doc.nodePrincipal, undefined, "Should have a principal");
    35   isnot(doc.nodePrincipal, null, "Should have a non-null principal");
    36   is(doc.nodePrincipal.origin, SpecialPowers.wrap(document).nodePrincipal.origin,
    37      "Wrong principal for document in node with id='" + id + "'");
    38 }
    40 function doContentTest(id) {
    41   is($(id).contentDocument.documentElement.textContent, "PASS",
    42      "Script executed in wrong context in node with id='" + id + "'");
    43 }
    45 function checkPrincipal() {
    46   ok(SpecialPowers.call_Instanceof(SpecialPowers.wrap(document).nodePrincipal, SpecialPowers.Ci.nsIPrincipal),
    47      "Should be a principal");
    48 }
    50 addLoadEvent(function() {
    51   checkPrincipal();
    53   for (var i of [ "one", "two", "three", "four" ]) {
    54     doPrincipalTest(i);
    55   }
    57   for (i of [ "five", "six" ]) {
    58     doContentTest(i);
    59   }
    61   SimpleTest.finish();
    62 });
    63 </script>
    64 </pre>
    65 </body>
    66 </html>

mercurial