| <body onload="test()"> |
| <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=31660">bug 31660</a>: |
| Image load event fires before the document fragment is attached.</p> |
| <div id=result>FAIL - script did not run</div> |
| <div id=target></div> |
| <!-- Preload an image, possibly making second load synchronous --> |
| <img src="resources/boston.gif" style="visibility:hidden"> |
| <script> |
| if (window.testRunner) { |
| testRunner.waitUntilDone(); |
| testRunner.dumpAsText(); |
| } |
| function test() |
| { |
| // Parsing a fragment immediately triggers image load. This is true in WebKit and Firefox even |
| // if a fragment created with Range.createContextualFragment() does not get attached. |
| var r = document.createRange(); |
| r.setStartAfter(document.body); |
| r.setEndAfter(document.body); |
| var frag = r.createContextualFragment('<img style="visibility:hidden" src="resources/boston.gif" onload="loaded()" id="new">'); |
| |
| document.getElementById("target").appendChild(frag); |
| } |
| function loaded() |
| { |
| // There is code on the Web expecting that an image is in the document by the time its load event fires. |
| document.getElementById("result").innerHTML = (document.getElementById("new")) ? "PASS" : "FAIL"; |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| </script> |
| </body> |