Index: third_party/WebKit/LayoutTests/external/wpt/image-decodes/image-decode-iframe.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/image-decodes/image-decode-iframe.html b/third_party/WebKit/LayoutTests/external/wpt/image-decodes/image-decode-iframe.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e64ea98afeb70b181c9d8993902ee2c72dac5570 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/external/wpt/image-decodes/image-decode-iframe.html |
@@ -0,0 +1,55 @@ |
+<!DOCTYPE html> |
+<meta charset=utf-8> |
+<meta name="timeout" content="long"> |
+<title>img.decode()</title> |
+<link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org"> |
+<link rel=help href=""> |
+<script src="/resources/testharness.js"></script> |
+<script src="/resources/testharnessreport.js"></script> |
+<div id="log"></div> |
+ |
+<iframe id="frame_loaded" srcdoc="iframe"></iframe> |
+<iframe id="frame_notloaded" srcdoc="iframe"></iframe> |
+<iframe id="frame_notloaded2" srcdoc="iframe"></iframe> |
+ |
+<script> |
+"use strict"; |
+ |
+promise_test(function() { |
+ return new Promise(function(resolve, reject) { |
+ var frame = document.getElementById("frame_loaded"); |
+ var img = frame.contentDocument.createElement("img"); |
+ img.src = "/images/green.png"; |
+ img.onload = function() { |
+ // At this point the frame which created the img is removed, so decode() should fail. |
+ frame.parentNode.removeChild(frame); |
+ img.decode().then(function() { |
+ assert_false(true, "Unexpected success"); |
+ }, function() { |
+ resolve(); |
+ }); |
+ }; |
+ }); |
+}, "(misc) Decode from removed iframe fails (loaded img)"); |
+ |
+promise_test(function(t) { |
+ var frame = document.getElementById("frame_notloaded"); |
+ var img = frame.contentDocument.createElement("img"); |
+ img.src = "/images/green.png"; |
+ frame.parentNode.removeChild(frame); |
+ var promise = img.decode(); |
+ return promise_rejects(t, "EncodingError", promise); |
+}, "(misc) Decode from removed iframe fails (img not loaded)"); |
+ |
+promise_test(function(t) { |
+ var frame = document.getElementById("frame_notloaded2"); |
+ var img = frame.contentDocument.createElement("img"); |
+ img.src = "/images/green.png"; |
+ // First request a promise, then remove the iframe. |
+ var promise = img.decode(); |
+ frame.parentNode.removeChild(frame); |
+ return promise_rejects(t, "EncodingError", promise); |
+}, "(misc) Decode from iframe, later removed, fails (img not loaded)"); |
+ |
+</script> |
+ |