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

Side by Side Diff: LayoutTests/http/tests/misc/image-onerror-no-load-event.html

Issue 113633005: Cancel load event on a failed image resource fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test for broken images Created 7 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/misc/image-onerror-no-load-event-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <script src="/js-test-resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 description("Tests if repeated loading of non-existent img.src resources doesn't deliver onload.");
9
10 window.jsTestIsAsync = true;
11 if (window.testRunner) {
12 testRunner.dumpAsText();
13 testRunner.waitUntilDone();
14 }
15
16 function finish(final)
17 {
18 // Test handling for missing image resources and
19 // ones that load, but with status 404.
20 if (!final) {
21 testImageOnError(true);
22 return;
23 }
24 window.finishJSTest();
25 }
26
27 function testImageOnError(broken)
28 {
29 var img = new Image();
30 img.expectOnLoad = broken;
31 img.onload = function() {
32 if (img.expectOnLoad)
33 testPassed("Received onload for broken img.src");
34 else
35 testFailed("Received onload for non-existent img.src");
36
37 finish(img.expectOnLoad);
38 };
39 img.onerror = function () {
40 if (img.expectOnLoad) {
41 img.onerror = null;
42 testFailed("Received onload for boken img.src");
43 finish(img.expectOnLoad);
44 return;
45 }
46 else
47 testPassed("Received onerror for non-existent img.src");
48
49 if (img.haveFailedAlready) {
50 img.onerror = null;
51 testPassed("Received error event repeatedly.");
52 finish(img.expectOnLoad);
53 return;
54 }
55 img.haveFailedAlready = true;
56 img.src = "invalidinvalid2.jpg";
57 };
58 img.src = broken ? "resources/404image.php" : "resources/non-existent.png";
59 }
60 testImageOnError(false);
61 </script>
62 <div id="console"></div>
63 </body>
64 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/misc/image-onerror-no-load-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698