Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 |