blob: c9acf3a21bd6e0fdb7cb50cd5d296cbfea8079f6 [file] [log] [blame]
<!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);
assert_equals(imgdata.width, 1);
assert_equals(imgdata.height, 1);
}
return promise_rejects(t, new DOMException('', 'IndexSizeError'), offscreen.convertToBlob());
}
</script>