Bug 1557456 [wpt PR 17211] - test correct exception when attempting to draw a closed ImageBitmap to a canvas., a=testonly

Automatic update from web-platform-tests
test correct exception when attempting to draw a closed ImageBitmap to a canvas. (#17211)

* add test for drawImage of closed canvas

* make consistent with existing imageBitmap tests

--

wpt-commits: f0ed5874274b40b1fbe14f8ab6a072ef3df12a6e
wpt-pr: 17211
This commit is contained in:
aardgoose 2019-07-19 18:18:26 +00:00 коммит произвёл James Graham
Родитель a8d8b383a9
Коммит 9234c53355
1 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<title>attempt to draw a closed ImageBitmap to a 2d canvas throws INVALID_STATE_ERR</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<script>
promise_test(function(t) {
return new Promise(function(resolve, reject) {
const image = new Image();
image.onload = function() { resolve(image); };
image.onerror = function() { reject(); };
image.src = "/images/green-16x16.png";
}).then(function(image) {
return createImageBitmap(image, 0, 0, 16, 16);
}).then(function(imageBitmap) {
imageBitmap.close();
const canvas = document.createElement("canvas");
canvas.width = 16;
canvas.height = 16;
const ctx = canvas.getContext("2d");
assert_throws("InvalidStateError", function() { ctx.drawImage(imageBitmap, 0, 0); });
});
});
</script>