Use dumpJSConsoleLogInStdErr=true webkit-test-runner option for non-imported tests...
[WebKit-https.git] / LayoutTests / http / tests / security / frame-loading-via-document-write-async-delegates.html
1 <!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
2 <html>
3 <head>
4 <title></title>
5
6 <script language="JavaScript">
7
8 const expectedLoadCount = 7;
9 let loadCount = 0;
10 function finishTestIfLastLoad()
11 {
12     if (++loadCount == expectedLoadCount && window.testRunner)
13         testRunner.notifyDone();
14 }
15
16 function buildFrameset()
17 {
18     if (window.testRunner) {
19         testRunner.waitUntilDone();
20         testRunner.dumpAsText();
21         testRunner.dumpChildFramesAsText();
22         if (testRunner.setShouldDecideNavigationPolicyAfterDelay)
23             testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
24     }
25
26     var outHTML="<frameset rows=\"33%, 33%, 33%\">"+
27                 "<frame src=\"\" onload=\"finishTestIfLastLoad()\" name=\"topRow\">"+
28                 "<frame src=\"\" onload=\"finishTestIfLastLoad()\" name=\"middleRow\">"+
29                 "<frame src=\"\" onload=\"finishTestIfLastLoad()\" name=\"bottomRow\">"+
30                 "</frameset>";
31
32     document.open("text/html","replace");
33     document.write(outHTML);
34     document.close();
35
36     outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+
37               "</scr" + "ipt></head><body onLoad=\"clickAnchor()\"><table><tr><td>"+
38               "<a href=\"resources/success.html\" target=\"topRow\" id=\"anchorLink\">Click me. If nothing loads above we have a problem.</a>"+
39               "</td></tr></table></body></html>";
40
41     frames['topRow'].document.open("text/html","replace");
42     frames['topRow'].document.charset=document.charset;
43     frames['topRow'].document.write(outHTML);
44     frames['topRow'].document.close();
45
46     var localImageLocation = "file:///tmp/LayoutTests/fast/dom/resources/abe.png";
47     if (window.testRunner)
48         localImageLocation = testRunner.pathToLocalResource(localImageLocation);
49
50     outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+
51               "</scr" + "ipt></head><body onLoad=\"didImageLoad()\"><table><tr><td>"+
52               "<div id=\"result\"></div>"+
53               "<img src=\"" + localImageLocation + "\" id=\"myImg\">"+
54               "</td></tr></table></body></html>";
55
56     frames['middleRow'].document.open("text/html","replace");
57     frames['middleRow'].document.charset=document.charset;
58     frames['middleRow'].document.write(outHTML);
59     frames['middleRow'].document.close();
60
61     outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+
62               "</scr" + "ipt></head><body onLoad=\"didImageLoad()\"><table><tr><td>"+
63               "<div id=\"result\"></div>"+
64               "<img src=\"/resources/abe.png\" id=\"myImg\">"+
65               "</td></tr></table></body></html>";
66
67     frames['bottomRow'].document.open("text/html","replace");
68     frames['bottomRow'].document.charset=document.charset;
69     frames['bottomRow'].document.write(outHTML);
70     frames['bottomRow'].document.close();
71 }
72
73 buildFrameset();
74
75 </script>
76 </head>
77
78 <body>
79 <p>JavaScript FAILED! you should not see this.</p>
80 </body>
81
82 </html>
83