Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / onload-after-document-close-with-subresource.html
blob07070c6ecc6ba2744dc4f800ace17011e3ebfab3
1 <p>This test verifies that the load event doesn't fire until subresource content has loaded, even if you manually call document.close beforehand. See <a href="http://bugs.webkit.org/show_bug.cgi?id=13241">bug 13241</a>.</p>
2 <hr>
3 <pre id="console"></pre>
5 <iframe></iframe>
7 <script>
8 function log(s)
10 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
13 function getDimensions()
15 var image = frames[0].document.images[0];
16 return "{ " + image.width + " x " + image.height + " }";
19 function beforeOnload()
21 log("dimensions before onload (should be { 0 x 0 }, otherwise the test will falsely pass): " + getDimensions());
24 function afterOnload()
26 log("dimensions during onload (should be { 215 x 174 }, otherwise onload fired too early): " + getDimensions());
27 if (window.testRunner)
28 testRunner.notifyDone();
31 function runTest()
33 if (window.testRunner) {
34 testRunner.dumpAsText();
36 // Quirkily, the FrameLoadDelegate API considers our <iframe> fully loaded
37 // once it has loaded its initial empty document. So, if we want DumpRenderTree
38 // to wait for the load event caused by our document.close() before dumping,
39 // we need to tell it so explicitly.
40 testRunner.waitUntilDone();
43 var doc = frames[0].document;
44 doc.open();
45 doc.write("<body onload=\"parent.afterOnload()\">");
46 // Append a random query string to force a non-cached load.
47 doc.write("<img src=\"resources/onload-image.png?" + Math.random() + "\">");
48 doc.write("<script\>parent.beforeOnload();</script\>");
49 doc.write("</body>");
50 doc.close();
53 runTest();
54 </script>