1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug353334.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=353334 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 353334</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + <script>var x = "PASS"</script> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=353334">Mozilla Bug 353334</a> 1.17 +<p id="display"> 1.18 +<iframe id="one"></iframe> 1.19 +<object id="two" data="about:blank"></object> 1.20 +<iframe id="three" src="data:text/html,<body>test</body>"></iframe> 1.21 +<object id="four" data="data:text/html,<body>test</body>"></object> 1.22 +<iframe id="five" src="javascript:parent.x"></iframe> 1.23 +<object id="six" data="javascript:x"></object> 1.24 +</p> 1.25 +<div id="content" style="display: none"> 1.26 + 1.27 +</div> 1.28 +<pre id="test"> 1.29 +<script class="testbody" type="text/javascript"> 1.30 + 1.31 +/** Test for Bug 353334 **/ 1.32 +SimpleTest.waitForExplicitFinish(); 1.33 + 1.34 +function doPrincipalTest(id) { 1.35 + var doc = SpecialPowers.wrap($(id).contentDocument); 1.36 + 1.37 + isnot(doc.nodePrincipal, undefined, "Should have a principal"); 1.38 + isnot(doc.nodePrincipal, null, "Should have a non-null principal"); 1.39 + is(doc.nodePrincipal.origin, SpecialPowers.wrap(document).nodePrincipal.origin, 1.40 + "Wrong principal for document in node with id='" + id + "'"); 1.41 +} 1.42 + 1.43 +function doContentTest(id) { 1.44 + is($(id).contentDocument.documentElement.textContent, "PASS", 1.45 + "Script executed in wrong context in node with id='" + id + "'"); 1.46 +} 1.47 + 1.48 +function checkPrincipal() { 1.49 + ok(SpecialPowers.call_Instanceof(SpecialPowers.wrap(document).nodePrincipal, SpecialPowers.Ci.nsIPrincipal), 1.50 + "Should be a principal"); 1.51 +} 1.52 + 1.53 +addLoadEvent(function() { 1.54 + checkPrincipal(); 1.55 + 1.56 + for (var i of [ "one", "two", "three", "four" ]) { 1.57 + doPrincipalTest(i); 1.58 + } 1.59 + 1.60 + for (i of [ "five", "six" ]) { 1.61 + doContentTest(i); 1.62 + } 1.63 + 1.64 + SimpleTest.finish(); 1.65 +}); 1.66 +</script> 1.67 +</pre> 1.68 +</body> 1.69 +</html> 1.70 +