Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/events/image-adoption-events.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/events/image-adoption-events.html b/third_party/WebKit/LayoutTests/fast/events/image-adoption-events.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..33731b380d80afa16e51e688f858cab4271d8517 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/events/image-adoption-events.html |
| @@ -0,0 +1,56 @@ |
| +<html> |
|
esprehn
2016/04/26 20:17:18
Add doctype, you can also remove the head, title a
|
| +<head> |
| +<title>Ensure that events are handled correctly when an image element is adopted.</title> |
| +</head> |
| +<body> |
| +<pre id="console"></pre> |
| +<script> |
| +if (window.testRunner) { |
| + testRunner.dumpAsText(); |
| + testRunner.waitUntilDone(); |
| +} |
| + |
| +function log(msg) { |
| + document.getElementById("console").appendChild(document.createTextNode(msg + "\n")); |
|
esprehn
2016/04/26 20:17:18
can you use js-test instead?
|
| +} |
| + |
| +var doc = document.body.appendChild(document.createElement("iframe")).contentDocument; |
| +var adopting = false; |
| +var readyStateChangeEventHandlerTriggeredWhenComplete = false; |
| + |
| +doc.open(); |
| +doc.onreadystatechange = function() { |
| + if (doc.readyState == "complete") { |
| + readyStateChangeEventHandlerTriggeredWhenComplete = true; |
| + log("PASS: readystatechange event handler was executed when complete"); |
| + if (adopting) |
| + log("FAIL: script triggered during adoption"); |
| + if (window.testRunner) |
| + testRunner.notifyDone(); |
| + } |
| +} |
| + |
| +var img = doc.appendChild(doc.createElement("img")); |
| +var blobUrl = URL.createObjectURL(new Blob); |
| + |
| +var x = new XMLHttpRequest; |
| +x.onload = function() { |
| + img.src = blobUrl; |
| +} |
| +x.onloadend = function() { |
| + doc.close(); |
| + URL.revokeObjectURL(blobUrl); |
| + adopting = true; |
| + document.adoptNode(img); |
| + adopting = false; |
| + if (doc.readyState == "complete" && !readyStateChangeEventHandlerTriggeredWhenComplete) { |
| + log("FAIL: readystatechange event was dispatched but the handler was suppressed"); |
| + if (window.testRunner) |
| + testRunner.notifyDone(); |
| + } |
| +} |
| +x.open("get", "data:text/html,"); |
| +x.send(); |
| +</script> |
| +</body> |
| +</html> |