Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: LayoutTests/http/tests/security/javascriptURL/xss-ALLOWED-to-javascript-url-window-open.html

Issue 494343003: Eliminate globalFlag usage from http security layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: consistify Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../resources/cross-frame-access.js"></script> 3 <script src="../resources/cross-frame-access.js"></script>
4 <script> 4 <script>
5 var openedWindow; 5 var openedWindow;
6 6
7 window.onload = function() 7 window.onload = function()
8 { 8 {
9 if (window.testRunner) { 9 if (window.testRunner) {
10 testRunner.dumpAsText(); 10 testRunner.dumpAsText();
11 testRunner.waitUntilDone(); 11 testRunner.waitUntilDone();
12 testRunner.setCanOpenWindows(); 12 testRunner.setCanOpenWindows();
13 } 13 }
14 14
15 var url = "javascript:\"<html><head><scr" + "ipt>window.onload = fun ction() { if (window.testRunner) testRunner.globalFlag = true; }</scr" + "ipt></ head><body><p>Opened Frame</p><p id='accessMe'>FAIL</p></body></html>\""; 15 var url = "javascript:\"<html><head><scr" + "ipt>window.onload = fun ction() { window.opener.postMessage('run test', '*'); }</scr" + "ipt></head><bod y><p>Opened Frame</p><p id='accessMe'>FAIL</p></body></html>\"";
16 openedWindow = window.open(url); 16 openedWindow = window.open(url);
17 17
18 if (window.testRunner) { 18 window.addEventListener('message', function ()
19 setTimeout(pollForTest, 1); 19 {
20 } else { 20 runTest();
21 log("To run the test, click the button below when the opened win dow finishes loading."); 21 closeWindowAndNotifyDone(openedWindow);
22 var button = document.createElement("button"); 22 });
23 button.appendChild(document.createTextNode("Run Test"));
24 button.onclick = runTest;
25 document.body.appendChild(button);
26 }
27
28 }
29
30 pollForTest = function()
31 {
32 if (!testRunner.globalFlag) {
33 setTimeout(pollForTest, 1);
34 return;
35 }
36 runTest();
37 closeWindowAndNotifyDone(openedWindow);
38 } 23 }
39 24
40 runTest = function() 25 runTest = function()
41 { 26 {
42 try { 27 try {
43 openedWindow.document.getElementById('accessMe').innerHTML = "PA SS: Access to a window opened with a javascript: URL was allowed!"; 28 openedWindow.document.getElementById('accessMe').innerHTML = "PA SS: Access to a window opened with a javascript: URL was allowed!";
44 log("PASS: Access to a window opened with a javascript: URL was allowed!"); 29 log("PASS: Access to a window opened with a javascript: URL was allowed!");
45 } catch (e) { 30 } catch (e) {
46 log("FAIL: Access to a window opened with a javascript: URL was denied."); 31 log("FAIL: Access to a window opened with a javascript: URL was denied.");
47 } 32 }
48 } 33 }
49 </script> 34 </script>
50 </head> 35 </head>
51 <body> 36 <body>
52 <p>Opener Frame</p> 37 <p>Opener Frame</p>
53 <pre id="console"></pre> 38 <pre id="console"></pre>
54 </body> 39 </body>
55 </html> 40 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698