-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for image.onerror (#11683)
* Add tests for image.onerror * Fixed nit issue * Add test for 404 response with actual image data and revert nonexistent-image.html
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
html/semantics/embedded-content/the-img-element/404-response-with-actual-image-data.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,18 @@ | ||
<!DOCTYPE HTML> | ||
<meta charset="utf-8"> | ||
<title>404 response with actual image data should be rendered and load event is fired</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<img id="img"> | ||
|
||
<script> | ||
async_test(t => { | ||
var img = document.getElementById("img"); | ||
img.onload = t.step_func_done(e => { | ||
assert_equals(e.type, "load", "image.onload() called"); | ||
}); | ||
img.onerror = t.unreached_func("image.onerror() was not supposed to be called"); | ||
img.src = "404-response-with-actual-image-data.py"; | ||
}, "404 response with actual image data should be rendered and load event is fired"); | ||
</script> |
3 changes: 3 additions & 0 deletions
3
html/semantics/embedded-content/the-img-element/404-response-with-actual-image-data.py
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,3 @@ | ||
import base64 | ||
def main(req, res): | ||
return 404, [('Content-Type', 'image/png')], base64.decodestring("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAhSURBVDhPY3wro/KfgQLABKXJBqMGjBoAAqMGDLwBDAwAEsoCTFWunmQAAAAASUVORK5CYII=") |