Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ad23e7cea9f5c889d3a64bb0f270a893b1869cc7 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html |
| @@ -0,0 +1,64 @@ |
| +<!DOCTYPE html> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script> |
| +promise_test( |
| + t => { return zeroSizeReadback("width", "none", t); }, |
| + "Verify convertToBlob on a 0 width OffscreenCanvas with no context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("width", "2d", t); }, |
| + "Verify convertToBlob and getImageData on a 0 width OffscreenCanvas with a 2d context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("width", "webgl", t); }, |
| + "Verify convertToBlob on a 0 width OffscreenCanvas with a webgl context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("width", "webgl2", t); }, |
| + "Verify convertToBlob on a 0 width OffscreenCanvas with a webgl2 context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("height", "none", t); }, |
| + "Verify convertToBlob on a 0 height OffscreenCanvas with no context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("height", "2d", t); }, |
| + "Verify convertToBlob and getImageData on a 0 height OffscreenCanvas with a 2d context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("height", "webgl", t); }, |
| + "Verify convertToBlob on a 0 height OffscreenCanvas with a webgl context." |
| +); |
| + |
| +promise_test( |
| + t => { return zeroSizeReadback("height", "webgl2", t); }, |
| + "Verify convertToBlob on a 0 height OffscreenCanvas with a webgl2 context." |
| +); |
| + |
| +function zeroSizeReadback(zeroDimension, contextType, t) { |
| + var offscreen = new OffscreenCanvas(10, 10); |
| + eval("offscreen." + zeroDimension + " = 0"); |
| + // Verify that one of the dimensions was indeed zeroed. |
| + assert_equals(offscreen.width * offscreen.height, 0); |
| + |
| + var ctx; |
| + if (contextType != "none") { |
| + ctx = offscreen.getContext(contextType); |
| + } |
| + |
| + if (contextType == '2d') { |
| + var imgdata = ctx.getImageData(0, 0, 1, 1); |
|
xidachen
2016/12/01 19:46:02
nits: indent is in-consistent for this line.
Justin Novosad
2016/12/01 20:09:39
Oops, it is a tab character. And there are more ab
|
| + assert_equals(imgdata.width, 1); |
| + assert_equals(imgdata.height, 1); |
| + } |
| + |
| + return promise_rejects(t, new DOMException('', 'IndexSizeError'), offscreen.convertToBlob()); |
| +} |
| +</script> |