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

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: Addressing comments + a whitespace fix 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/image-adoption-events-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..682cc5777d8330377df15623c605aa8094e6cccf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/image-adoption-events.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<script src="../../resources/js-test.js"></script>
+<script>
+// Ensure that events are handled correctly when an image element is adopted.
+
+jsTestIsAsync = true;
+
+var doc = document.documentElement.appendChild(document.createElement("iframe")).contentDocument;
+var adopting = false;
+var readyStateChangeEventHandlerTriggeredWhenComplete = false;
+
+doc.open();
+doc.onreadystatechange = function() {
+ if (doc.readyState == "complete") {
+ readyStateChangeEventHandlerTriggeredWhenComplete = true;
+ testPassed("readystatechange event handler was executed when complete");
+ if (adopting)
+ testFailed("script triggered during adoption");
+ finishJSTest();
+ }
+}
+
+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) {
+ // TODO: This can be replaced with testFailed once https://crbug.com/606651 is fixed.
+ debug("FAIL readystatechange event was dispatched but the handler was suppressed");
+ finishJSTest();
+ }
+}
+x.open("get", "data:text/html,");
+x.send();
+</script>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/image-adoption-events-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698