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