OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <meta name="timeout" content="long"> |
| 4 <title>img.decode()</title> |
| 5 <link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org"> |
| 6 <link rel=help href=""> |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <div id="log"></div> |
| 10 |
| 11 <iframe id="frame_loaded" srcdoc="iframe"></iframe> |
| 12 <iframe id="frame_notloaded" srcdoc="iframe"></iframe> |
| 13 <iframe id="frame_notloaded2" srcdoc="iframe"></iframe> |
| 14 |
| 15 <script> |
| 16 "use strict"; |
| 17 |
| 18 promise_test(function() { |
| 19 return new Promise(function(resolve, reject) { |
| 20 var frame = document.getElementById("frame_loaded"); |
| 21 var img = frame.contentDocument.createElement("img"); |
| 22 img.src = "/images/green.png"; |
| 23 img.onload = function() { |
| 24 // At this point the frame which created the img is removed, so decode() s
hould fail. |
| 25 frame.parentNode.removeChild(frame); |
| 26 img.decode().then(function() { |
| 27 assert_false(true, "Unexpected success"); |
| 28 }, function() { |
| 29 resolve(); |
| 30 }); |
| 31 }; |
| 32 }); |
| 33 }, "(misc) Decode from removed iframe fails (loaded img)"); |
| 34 |
| 35 promise_test(function(t) { |
| 36 var frame = document.getElementById("frame_notloaded"); |
| 37 var img = frame.contentDocument.createElement("img"); |
| 38 img.src = "/images/green.png"; |
| 39 frame.parentNode.removeChild(frame); |
| 40 var promise = img.decode(); |
| 41 return promise_rejects(t, "EncodingError", promise); |
| 42 }, "(misc) Decode from removed iframe fails (img not loaded)"); |
| 43 |
| 44 promise_test(function(t) { |
| 45 var frame = document.getElementById("frame_notloaded2"); |
| 46 var img = frame.contentDocument.createElement("img"); |
| 47 img.src = "/images/green.png"; |
| 48 // First request a promise, then remove the iframe. |
| 49 var promise = img.decode(); |
| 50 frame.parentNode.removeChild(frame); |
| 51 return promise_rejects(t, "EncodingError", promise); |
| 52 }, "(misc) Decode from iframe, later removed, fails (img not loaded)"); |
| 53 |
| 54 </script> |
| 55 |
OLD | NEW |