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