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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/loading/onload/resources/onload-test.js

Issue 1833303002: [Not committed] Make image load completion async and remove EventSender from ImageLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Loader_asyncImageLoadEvent_1
Patch Set: Rebase. 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/http/tests/loading/onload/resources/onload-test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/loading/onload/resources/onload-test.js b/third_party/WebKit/LayoutTests/http/tests/loading/onload/resources/onload-test.js
new file mode 100644
index 0000000000000000000000000000000000000000..0d2438c01b9c7f7b725aca9c3eb610b7f2ee9d03
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/loading/onload/resources/onload-test.js
@@ -0,0 +1,50 @@
+jsTestIsAsync = true;
+
+var imgOnLoadCalled = false;
+var img2OnLoadCalled = false;
+var bodyOnLoadCalled = false;
+
+var img = document.createElement('img');
+var img2 = document.createElement('img');
+
+img.onload = imgOnLoad;
+img.src = url;
+document.body.appendChild(img);
+shouldBeFalse("bodyOnLoadCalled");
+shouldBeFalse("imgOnLoadCalled");
+shouldBeFalse("img.complete");
+
+function imgOnLoad() {
+ imgOnLoadCalled = true;
+ debug("img's onload");
+
+ shouldBeFalse("bodyOnLoadCalled");
+ shouldBeTrue("imgOnLoadCalled");
+ shouldBeTrue("img.complete");
+
+ img2.onload = img2OnLoad;
+ img2.src = url;
+ document.body.appendChild(img2);
+ shouldBeFalse("bodyOnLoadCalled");
+ shouldBeFalse("img2OnLoadCalled");
+ shouldBeFalse("img2.complete");
+}
+
+function img2OnLoad() {
+ img2OnLoadCalled = true;
+ debug("img2's onload");
+
+ shouldBeFalse("bodyOnLoadCalled");
+ shouldBeTrue("img2OnLoadCalled");
+ shouldBeTrue("img2.complete");
+}
+
+function bodyOnLoad() {
+ bodyOnLoadCalled = true;
+ debug("body's onload");
+ shouldBeTrue("imgOnLoadCalled");
+ shouldBeTrue("img.complete");
+ shouldBeTrue("img2OnLoadCalled");
+ shouldBeTrue("img2.complete");
+ finishJSTest();
+}

Powered by Google App Engine
This is Rietveld 408576698