1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/src/jsurl/test/test_bug351633-3.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=351633 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 351633</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 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=351633">Mozilla Bug 351633</a> 1.16 +<pre id="test"> 1.17 +<script class="testbody" type="text/javascript"> 1.18 + 1.19 +var passJSUrl; 1.20 +var passJSUrl2; 1.21 +var finishTest; 1.22 + 1.23 +/** Test for Bug 351633 **/ 1.24 +function runTests() { 1.25 + $("testframe1").onload = test1; 1.26 + // test2 will be called as finishTest 1.27 + $("testframe3").onload = test3; 1.28 + $("testframe4").onload = test4; 1.29 + $("testframe5").onload = test5; 1.30 + passJSUrl = false; 1.31 + window.testframe1.location.href = 1.32 + 'javascript:"<script>parent.passJSUrl = true</' + 'script>"' 1.33 +} 1.34 + 1.35 +function test1() { 1.36 + is(passJSUrl, true, "Script should have run in child"); 1.37 + 1.38 + passJSUrl = false; 1.39 + passJSUrl2 = true; 1.40 + finishTest = test2; 1.41 + 1.42 + window.testframe2.location.href = 1.43 + 'javascript: location = "pass.html"; ' + 1.44 + '"<script>parent.passJSUrl2 = false</' + 'script>"' 1.45 +} 1.46 + 1.47 +function test2() { 1.48 + is(passJSUrl, true, "pass.html should have loaded"); 1.49 + is(passJSUrl2, true, "<script> should not have run"); 1.50 + 1.51 + passJSUrl = true; 1.52 + passJSUrl2 = false; 1.53 + finishTest = function() { }; 1.54 + 1.55 + window.testframe3.location.href = 'fail.html'; 1.56 + window.testframe3.location.href = 1.57 + 'javascript: "<script>parent.passJSUrl2 = true</' + 'script>"' 1.58 +} 1.59 + 1.60 +function test3() { 1.61 + if (window.testframe3.location.href == 'fail.html') { 1.62 + // Ignore this call; we expect the javascript: URI to still load. Note 1.63 + // that whether onload fires for the fail.html load before the event for 1.64 + // the javascript: URI execution runs is a timing issue, so we can't depend 1.65 + // on the ordering. 1.66 + return; 1.67 + } 1.68 + 1.69 + // Since fail.html could have loaded, the value of passJSUrl here is random 1.70 + 1.71 + // Something is bogus here. Maybe we're ending up with the href being the 1.72 + // javascript: URI even though it hasn't run yet? Or something? In any 1.73 + // case, this test fails on some tinderboxen but not others.... Need to 1.74 + // sort it out. 1.75 + // is(passJSUrl2, true, "<script> should have run"); 1.76 + 1.77 + passJSUrl = false; 1.78 + passJSUrl2 = true; 1.79 + finishTest = function() { }; 1.80 + 1.81 + window.testframe4.location.href = 'pass.html'; 1.82 + window.testframe4.location.href = 1.83 + 'javascript:void("<script>parent.passJSUrl2 = false</' + 'script>")'; 1.84 +} 1.85 + 1.86 +function test4() { 1.87 + is(passJSUrl, true, "pass.html should have loaded again"); 1.88 + is(passJSUrl2, true, "<script> should not have run in void"); 1.89 + 1.90 + passJSUrl = false; 1.91 + passJSUrl2 = true; 1.92 + finishTest = function() { }; 1.93 + 1.94 + window.testframe5.location.href = 1.95 + 'javascript:"<script>parent.passJSUrl2 = false</' + 'script>"'; 1.96 + window.testframe5.location.href = 'pass.html'; 1.97 +} 1.98 + 1.99 +function test5() { 1.100 + is(passJSUrl, true, "pass.html should have loaded yet again"); 1.101 + is(passJSUrl2, true, "javascript: load should have been canceled"); 1.102 + 1.103 + SimpleTest.finish(); 1.104 +} 1.105 + 1.106 +SimpleTest.waitForExplicitFinish(); 1.107 +addLoadEvent(runTests); 1.108 + 1.109 +</script> 1.110 +</pre> 1.111 +<p id="display"> 1.112 + <iframe name="testframe1" id="testframe1"></iframe> 1.113 + <iframe name="testframe2" id="testframe2"></iframe> 1.114 + <iframe name="testframe3" id="testframe3"></iframe> 1.115 + <iframe name="testframe4" id="testframe4"></iframe> 1.116 + <iframe name="testframe5" id="testframe5"></iframe> 1.117 +</p> 1.118 +<div id="content" style="display: none"> 1.119 + 1.120 +</div> 1.121 +</body> 1.122 +</html> 1.123 +