-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In particular, now: * complete returns true if src="" is unset or empty. * complete returns true if an error occurs loading the image. * complete returns false if src="" is reset to a not-yet-loaded URL. Closes #2967 by superseding it. Co-authored-by: Matthew Glazar <strager.nds@gmail.com>
- Loading branch information
Showing
5 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...orm-tests/to-upstream/html/semantics/embedded-content/the-img-element/img.complete-2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTMLImageElement#complete</title> | ||
<link rel="help" href="https://html.spec.whatwg.org/#the-img-element"> | ||
|
||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
async_test(t => { | ||
const img = document.createElement("img"); | ||
img.src = "file-does-not-exist.png"; | ||
assert_false(img.complete); | ||
|
||
img.onload = img.onerror = t.step_func_done(event => { | ||
assert_equals(event.type, "error"); | ||
assert_true(img.complete); | ||
}); | ||
|
||
// JSDOM specific: when image loading is not supported (i.e. when node-canvas is not installed), skip the test. | ||
t.step_timeout(() => { | ||
t.done(); | ||
}, 1000); | ||
}, "src 404 error"); | ||
|
||
async_test(t => { | ||
const img = document.createElement("img"); | ||
img.src = "http://malformed:url"; | ||
assert_false(img.complete); | ||
|
||
img.onload = img.onerror = t.step_func_done(event => { | ||
assert_equals(event.type, "error"); | ||
assert_true(img.complete); | ||
}); | ||
|
||
// JSDOM specific: when image loading is not supported (i.e. when node-canvas is not installed), skip the test. | ||
t.step_timeout(() => { | ||
t.done(); | ||
}, 1000); | ||
}, "src malformed URL"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters