OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../resources/libwrapjs.js"></script> | 3 <script src="../resources/libwrapjs.js"></script> |
4 <script src="../resources/cross-frame-access.js"></script> | 4 <script src="../resources/cross-frame-access.js"></script> |
5 <script> | 5 <script> |
6 var code; | 6 var code; |
7 var openedWindow; | 7 var openedWindow; |
8 | 8 |
9 window.onload = function() | 9 window.onload = function() |
10 { | 10 { |
(...skipping 21 matching lines...) Expand all Loading... |
32 code = libwrapjs.in_script_tag(payload); | 32 code = libwrapjs.in_script_tag(payload); |
33 log("Code injected into window:"); | 33 log("Code injected into window:"); |
34 log(code); | 34 log(code); |
35 | 35 |
36 if (window.testRunner) { | 36 if (window.testRunner) { |
37 setTimeout(pollForTest1, 1); | 37 setTimeout(pollForTest1, 1); |
38 } else { | 38 } else { |
39 log("To run the test, click the button below when the frames finish
loading."); | 39 log("To run the test, click the button below when the frames finish
loading."); |
40 var button = document.createElement("button"); | 40 var button = document.createElement("button"); |
41 button.appendChild(document.createTextNode("Run Test")); | 41 button.appendChild(document.createTextNode("Run Test")); |
42 button.onclick = runTest; | 42 button.onclick = runTest1; |
43 document.body.appendChild(button); | 43 document.body.appendChild(button); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 pollForTest1 = function() | 47 pollForTest1 = function() |
48 { | 48 { |
49 if (!testRunner.globalFlag) { | 49 if (window.testRunner && !testRunner.globalFlag) { |
50 setTimeout(pollForTest1, 1); | 50 setTimeout(pollForTest1, 1); |
51 return; | 51 return; |
52 } | 52 } |
53 runTest1(); | 53 runTest1(); |
54 } | 54 } |
55 | 55 |
56 runTest1 = function() { | 56 runTest1 = function() { |
57 frames[0].openWindow(); | 57 frames[0].openWindow(); |
58 openedWindow = frames[0].openedWindow; | 58 openedWindow = frames[0].openedWindow; |
59 | 59 |
60 if (window.testRunner) | 60 if (window.testRunner) |
61 testRunner.globalFlag = false; | 61 testRunner.globalFlag = false; |
62 | 62 |
63 frames[0].location = 'http://localhost:8000/security/resources/innocent-
victim-with-notify.html'; | 63 frames[0].location = 'http://localhost:8000/security/resources/innocent-
victim-with-notify.html'; |
64 | 64 |
65 setTimeout(pollForTest2, 1); | 65 setTimeout(pollForTest2, 1); |
66 } | 66 } |
67 | 67 |
68 pollForTest2 = function() | 68 pollForTest2 = function() |
69 { | 69 { |
70 if (!testRunner.globalFlag) { | 70 if (window.testRunner && !testRunner.globalFlag) { |
71 setTimeout(pollForTest2, 1); | 71 setTimeout(pollForTest2, 1); |
72 return; | 72 return; |
73 } | 73 } |
74 runTest2(); | 74 runTest2(); |
75 } | 75 } |
76 | 76 |
77 runTest2 = function() | 77 runTest2 = function() |
78 { | 78 { |
79 openedWindow.document.write(code); | 79 openedWindow.document.write(code); |
80 openedWindow.document.close(); | 80 openedWindow.document.close(); |
81 if (window.testRunner) { | 81 if (window.testRunner) { |
82 testRunner.globalFlag = false; | 82 testRunner.globalFlag = false; |
83 setTimeout(pollForDone, 1); | 83 setTimeout(pollForDone, 1); |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 pollForDone = function() | 87 pollForDone = function() |
88 { | 88 { |
89 if (!testRunner.globalFlag) { | 89 if (window.testRunner && !testRunner.globalFlag) { |
90 setTimeout(pollForDone, 1); | 90 setTimeout(pollForDone, 1); |
91 return; | 91 return; |
92 } | 92 } |
93 closeWindowAndNotifyDone(openedWindow); | 93 closeWindowAndNotifyDone(openedWindow); |
94 } | 94 } |
95 </script> | 95 </script> |
96 </head> | 96 </head> |
97 <body> | 97 <body> |
98 <div>This page opens a window to "", injects malicious code, and | 98 <div>This page opens a window to "", injects malicious code, and |
99 then navigates its opener to the victim. The opened window then tries to | 99 then navigates its opener to the victim. The opened window then tries to |
100 scripts its opener after <code>document.write</code>ing a new document.</div> | 100 scripts its opener after <code>document.write</code>ing a new document.</div> |
101 <pre id="console"></pre> | 101 <pre id="console"></pre> |
102 <iframe style="border: solid 3px red;" src="../resources/open-window.html"></ifr
ame> | 102 <iframe style="border: solid 3px red;" src="../resources/open-window.html"></ifr
ame> |
103 <iframe style="border: solid 3px green;" src="../resources/innocent-victim.html"
></iframe> | 103 <iframe style="border: solid 3px green;" src="../resources/innocent-victim.html"
></iframe> |
104 </body> | 104 </body> |
105 </html> | 105 </html> |
OLD | NEW |