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 <script> |
| 12 "use strict"; |
| 13 |
| 14 // src tests |
| 15 // ------------------- |
| 16 promise_test(function(t) { |
| 17 var img = new Image(); |
| 18 img.src = "/images/green.png"; |
| 19 var promise = img.decode(); |
| 20 img.src = "/images/green.svg"; |
| 21 return promise_rejects(t, "EncodingError", promise); |
| 22 }, "(src) Path changes fail decode."); |
| 23 |
| 24 promise_test(function(t) { |
| 25 var img = new Image(); |
| 26 img.src = "/images/green.png"; |
| 27 var first_promise = img.decode(); |
| 28 img.src = "/images/green.svg"; |
| 29 var second_promise = img.decode(); |
| 30 assert_true(first_promise !== second_promise); |
| 31 return Promise.all([ |
| 32 promise_rejects(t, "EncodingError", first_promise), |
| 33 second_promise |
| 34 ]); |
| 35 }, "(src) Path changes fail decode; following good decode succeeds."); |
| 36 |
| 37 promise_test(function(t) { |
| 38 var img = new Image(); |
| 39 img.src = "/images/green.png"; |
| 40 var first_promise = img.decode(); |
| 41 img.src = "/non/existent/path.png"; |
| 42 var second_promise = img.decode(); |
| 43 assert_true(first_promise !== second_promise); |
| 44 return Promise.all([ |
| 45 promise_rejects(t, "EncodingError", first_promise), |
| 46 promise_rejects(t, "EncodingError", second_promise) |
| 47 ]); |
| 48 }, "(src) Path changes fail decode; following bad decode fails."); |
| 49 |
| 50 promise_test(function() { |
| 51 var img = new Image(); |
| 52 img.src = "/images/green.png"; |
| 53 var first_promise = img.decode(); |
| 54 img.src = "/images/green.png"; |
| 55 var second_promise = img.decode(); |
| 56 assert_true(first_promise !== second_promise); |
| 57 return Promise.all([ |
| 58 first_promise, |
| 59 second_promise |
| 60 ]); |
| 61 }, "(src) Path changes to the same path succeed."); |
| 62 |
| 63 // srcset tests |
| 64 // ------------------- |
| 65 promise_test(function(t) { |
| 66 var img = new Image(); |
| 67 img.srcset = "/images/green.png 100w"; |
| 68 var promise = img.decode(); |
| 69 img.srcset = "/images/green.svg 100w"; |
| 70 return promise_rejects(t, "EncodingError", promise); |
| 71 }, "(srcset) Path changes fail decode."); |
| 72 |
| 73 promise_test(function(t) { |
| 74 var img = new Image(); |
| 75 img.srcset = "/images/green.png 100w"; |
| 76 var first_promise = img.decode(); |
| 77 img.srcset = "/images/green.svg 100w"; |
| 78 var second_promise = img.decode(); |
| 79 assert_true(first_promise !== second_promise); |
| 80 return Promise.all([ |
| 81 promise_rejects(t, "EncodingError", first_promise), |
| 82 second_promise |
| 83 ]); |
| 84 }, "(srcset) Path changes fail decode; following good decode succeeds."); |
| 85 |
| 86 promise_test(function(t) { |
| 87 var img = new Image(); |
| 88 img.srcset = "/images/green.png 100w"; |
| 89 var first_promise = img.decode(); |
| 90 img.srcset = "/non/existent/path.png 100w"; |
| 91 var second_promise = img.decode(); |
| 92 assert_true(first_promise !== second_promise); |
| 93 return Promise.all([ |
| 94 promise_rejects(t, "EncodingError", first_promise), |
| 95 promise_rejects(t, "EncodingError", second_promise) |
| 96 ]); |
| 97 }, "(srcset) Path changes fail decode; following bad decode fails."); |
| 98 |
| 99 promise_test(function() { |
| 100 var img = new Image(); |
| 101 img.srcset = "/images/green.png 100w"; |
| 102 var first_promise = img.decode(); |
| 103 img.srcset = "/images/green.png 100w"; |
| 104 var second_promise = img.decode(); |
| 105 assert_true(first_promise !== second_promise); |
| 106 return Promise.all([ |
| 107 first_promise, |
| 108 second_promise |
| 109 ]); |
| 110 }, "(srcset) Path changes to the same path succeed."); |
| 111 |
| 112 </script> |
OLD | NEW |