Skip to content

Commit

Permalink
Add tests for image.onerror (#11683)
Browse files Browse the repository at this point in the history
* 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
xiuqijix authored and jdm committed Dec 24, 2018
1 parent e751708 commit a357943
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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>
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=")

0 comments on commit a357943

Please sign in to comment.