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

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

mercurial