Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Unified Diff: third_party/WebKit/LayoutTests/fast/events/image-adoption-events.html

Issue 1921853004: Move the ScriptForbiddenScope in TreeScope::adoptIfNeeded to the top of the function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698