-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shapedetection] Add some shapedetection tests
Cover following two checkpoints: - If the ImageBitmapSource is an HTMLVideoElement object whose readyState attribute is either HAVE_NOTHING or HAVE_METADATA then reject the Promise with a new DOMException whose name is InvalidStateError. - If the ImageBitmapSource argument is an HTMLCanvasElement whose bitmap’s origin-clean flag is false, then reject the Promise with a new DOMException whose name is SecurityError. spec: https://wicg.github.io/shape-detection-api/#image-sources-for-detection Change-Id: I0522d0340d3cb0291df6be65dfc1ab99037b30f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1666766 Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Wanming Lin <wanming.lin@intel.com> Cr-Commit-Position: refs/heads/master@{#671578}
- Loading branch information
1 parent
3cb5a99
commit ec977de
Showing
2 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
shape-detection/detection-HTMLVideoElement-invalid-state.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
const videoElementTests = | ||
[ | ||
{ | ||
createDetector: () => { return new FaceDetector(); }, | ||
name: "Face - detect(HTMLVideoElement)", | ||
}, | ||
{ | ||
createDetector: () => { return new BarcodeDetector(); }, | ||
name: "Barcode - detect(HTMLVideoElement)", | ||
} | ||
]; | ||
|
||
for (let videoElementTest of videoElementTests) { | ||
|
||
// Detector's detect() rejects on a HAVE_NOTHING HTMLVideoElement. | ||
promise_test(async t => { | ||
const video = document.createElement("video"); | ||
video.src = ""; | ||
const videoWatcher = new EventWatcher(t, video, ["play", "error"]); | ||
video.load(); | ||
await videoWatcher.wait_for("error"); | ||
assert_equals(video.readyState, video.HAVE_NOTHING); | ||
|
||
const detector = videoElementTest.createDetector(); | ||
await promise_rejects(t, 'InvalidStateError', detector.detect(video)); | ||
}, `${videoElementTest.name} - HAVE_NOTHING`); | ||
|
||
// Detector's detect() rejects on a HAVE_METADATA HTMLVideoElement. | ||
promise_test(async t => { | ||
const video = document.createElement("video"); | ||
video.src = "/media/white.webm"; | ||
video.loop = true; | ||
video.autoplay = true; | ||
const videoWatcher = new EventWatcher(t, video, ["loadedmetadata", "error"]); | ||
video.load(); | ||
await videoWatcher.wait_for("loadedmetadata"); | ||
assert_equals(video.readyState, video.HAVE_METADATA); | ||
|
||
const detector = videoElementTest.createDetector(); | ||
await promise_rejects(t, 'InvalidStateError', detector.detect(video)); | ||
}, `${videoElementTest.name} - HAVE_METADATA`); | ||
|
||
} | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters