forked from mirrors/gecko-dev
Automatic update from web-platform-tests shapedetection: Check for a neutered ImageBitmap This change adds checks for whether the provided ImageBitmap has been neutered before attempting detection. Bug: 1256876 Change-Id: Icf9283f1bc2bb5e0cf023adaf5066186d97b9386 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3208990 Auto-Submit: Reilly Grant <reillyg@chromium.org> Reviewed-by: Chris Mumford <cmumford@google.com> Commit-Queue: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/main@{#928792} -- wpt-commits: af5002262402a2ac2fbae533fd6d243144c5a095 wpt-pr: 31137
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
async function createClosedImageBitmap(t) {
|
|
const img = new Image();
|
|
const imgWatcher = new EventWatcher(t, img, ['load', 'error']);
|
|
img.src = '/images/green-16x16.png';
|
|
await imgWatcher.wait_for('load');
|
|
const imageBitmap = await createImageBitmap(img);
|
|
imageBitmap.close();
|
|
return imageBitmap;
|
|
}
|
|
|
|
promise_test(async (t) => {
|
|
const imageBitmap = await createClosedImageBitmap(t);
|
|
const detector = new FaceDetector();
|
|
try {
|
|
await detector.detect(imageBitmap);
|
|
assert_unreached();
|
|
} catch (e) {
|
|
assert_equals(e.code, DOMException.INVALID_STATE_ERR);
|
|
}
|
|
}, 'FaceDetector.detect() rejects on a closed ImageBitmap');
|
|
|
|
promise_test(async (t) => {
|
|
const imageBitmap = await createClosedImageBitmap(t);
|
|
const detector = new BarcodeDetector();
|
|
try {
|
|
await detector.detect(imageBitmap);
|
|
assert_unreached();
|
|
} catch (e) {
|
|
assert_equals(e.code, DOMException.INVALID_STATE_ERR);
|
|
}
|
|
}, 'BarcodeDetector.detect() rejects on a closed ImageBitmap');
|
|
|
|
promise_test(async (t) => {
|
|
const imageBitmap = await createClosedImageBitmap(t);
|
|
const detector = new TextDetector();
|
|
try {
|
|
await detector.detect(imageBitmap);
|
|
assert_unreached();
|
|
} catch (e) {
|
|
assert_equals(e.code, DOMException.INVALID_STATE_ERR);
|
|
}
|
|
}, 'TextDetector.detect() rejects on a closed ImageBitmap');
|