Thu, 22 Jan 2015 13:21:57 +0100
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=351633 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 351633</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 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=351633">Mozilla Bug 351633</a> |
michael@0 | 13 | <pre id="test"> |
michael@0 | 14 | <script class="testbody" type="text/javascript"> |
michael@0 | 15 | |
michael@0 | 16 | var passJSUrl; |
michael@0 | 17 | var passJSUrl2; |
michael@0 | 18 | var finishTest; |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 351633 **/ |
michael@0 | 21 | function runTests() { |
michael@0 | 22 | $("testframe1").onload = test1; |
michael@0 | 23 | // test2 will be called as finishTest |
michael@0 | 24 | $("testframe3").onload = test3; |
michael@0 | 25 | $("testframe4").onload = test4; |
michael@0 | 26 | $("testframe5").onload = test5; |
michael@0 | 27 | passJSUrl = false; |
michael@0 | 28 | window.testframe1.location.href = |
michael@0 | 29 | 'javascript:"<script>parent.passJSUrl = true</' + 'script>"' |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function test1() { |
michael@0 | 33 | is(passJSUrl, true, "Script should have run in child"); |
michael@0 | 34 | |
michael@0 | 35 | passJSUrl = false; |
michael@0 | 36 | passJSUrl2 = true; |
michael@0 | 37 | finishTest = test2; |
michael@0 | 38 | |
michael@0 | 39 | window.testframe2.location.href = |
michael@0 | 40 | 'javascript: location = "pass.html"; ' + |
michael@0 | 41 | '"<script>parent.passJSUrl2 = false</' + 'script>"' |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function test2() { |
michael@0 | 45 | is(passJSUrl, true, "pass.html should have loaded"); |
michael@0 | 46 | is(passJSUrl2, true, "<script> should not have run"); |
michael@0 | 47 | |
michael@0 | 48 | passJSUrl = true; |
michael@0 | 49 | passJSUrl2 = false; |
michael@0 | 50 | finishTest = function() { }; |
michael@0 | 51 | |
michael@0 | 52 | window.testframe3.location.href = 'fail.html'; |
michael@0 | 53 | window.testframe3.location.href = |
michael@0 | 54 | 'javascript: "<script>parent.passJSUrl2 = true</' + 'script>"' |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function test3() { |
michael@0 | 58 | if (window.testframe3.location.href == 'fail.html') { |
michael@0 | 59 | // Ignore this call; we expect the javascript: URI to still load. Note |
michael@0 | 60 | // that whether onload fires for the fail.html load before the event for |
michael@0 | 61 | // the javascript: URI execution runs is a timing issue, so we can't depend |
michael@0 | 62 | // on the ordering. |
michael@0 | 63 | return; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | // Since fail.html could have loaded, the value of passJSUrl here is random |
michael@0 | 67 | |
michael@0 | 68 | // Something is bogus here. Maybe we're ending up with the href being the |
michael@0 | 69 | // javascript: URI even though it hasn't run yet? Or something? In any |
michael@0 | 70 | // case, this test fails on some tinderboxen but not others.... Need to |
michael@0 | 71 | // sort it out. |
michael@0 | 72 | // is(passJSUrl2, true, "<script> should have run"); |
michael@0 | 73 | |
michael@0 | 74 | passJSUrl = false; |
michael@0 | 75 | passJSUrl2 = true; |
michael@0 | 76 | finishTest = function() { }; |
michael@0 | 77 | |
michael@0 | 78 | window.testframe4.location.href = 'pass.html'; |
michael@0 | 79 | window.testframe4.location.href = |
michael@0 | 80 | 'javascript:void("<script>parent.passJSUrl2 = false</' + 'script>")'; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function test4() { |
michael@0 | 84 | is(passJSUrl, true, "pass.html should have loaded again"); |
michael@0 | 85 | is(passJSUrl2, true, "<script> should not have run in void"); |
michael@0 | 86 | |
michael@0 | 87 | passJSUrl = false; |
michael@0 | 88 | passJSUrl2 = true; |
michael@0 | 89 | finishTest = function() { }; |
michael@0 | 90 | |
michael@0 | 91 | window.testframe5.location.href = |
michael@0 | 92 | 'javascript:"<script>parent.passJSUrl2 = false</' + 'script>"'; |
michael@0 | 93 | window.testframe5.location.href = 'pass.html'; |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | function test5() { |
michael@0 | 97 | is(passJSUrl, true, "pass.html should have loaded yet again"); |
michael@0 | 98 | is(passJSUrl2, true, "javascript: load should have been canceled"); |
michael@0 | 99 | |
michael@0 | 100 | SimpleTest.finish(); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 104 | addLoadEvent(runTests); |
michael@0 | 105 | |
michael@0 | 106 | </script> |
michael@0 | 107 | </pre> |
michael@0 | 108 | <p id="display"> |
michael@0 | 109 | <iframe name="testframe1" id="testframe1"></iframe> |
michael@0 | 110 | <iframe name="testframe2" id="testframe2"></iframe> |
michael@0 | 111 | <iframe name="testframe3" id="testframe3"></iframe> |
michael@0 | 112 | <iframe name="testframe4" id="testframe4"></iframe> |
michael@0 | 113 | <iframe name="testframe5" id="testframe5"></iframe> |
michael@0 | 114 | </p> |
michael@0 | 115 | <div id="content" style="display: none"> |
michael@0 | 116 | |
michael@0 | 117 | </div> |
michael@0 | 118 | </body> |
michael@0 | 119 | </html> |
michael@0 | 120 |