dom/src/jsurl/test/test_bug351633-3.html

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

mercurial