Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/detectface-HTMLVideoElement.html

Issue 2455973007: FaceDetection: add support for <video> input (Closed)
Patch Set: xianglu@s comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-shapedetection.js"></script>
6 <script>
7
8 // This test verifies that FaceDetector.detect works on an HTMLVideoElement.
9 // Uses the mock mojo server implemented in mock-shapedetection.js.
10 async_test(function(t) {
11 var video = document.createElement('video');
12 video.src = "../imported/wpt/media/white.webm";
13 video.loop = true;
14 video.autoplay = true;
15 video.onerror = this.unreached_func("<video> error");
16 video.onplay = this.step_func(function() {
17 var theMock = null;
18 mockShapeDetectionReady
19 .then(mock => {
20 theMock = mock;
21 return new FaceDetector();
22 })
23 .catch(error => {
24 assert_unreached("Error creating MockShapeDetection: " + error);
25 })
26 .then(detector => {
27 return detector.detect(video);
28 })
29 .then(faceDetectionResult => {
30 const imageReceivedByMock = theMock.getFrameData();
31 assert_equals(imageReceivedByMock.byteLength, 307200,
32 "Image length");
33 const WHITE_PIXEL = 0xFFFFFFFF;
34 assert_equals(imageReceivedByMock[0], WHITE_PIXEL, "Pixel color");
35 assert_equals(faceDetectionResult.length, 3, "Number of faces");
36 t.done();
37 })
38 .catch(error => {
39 assert_unreached("Error during detect(img): " + error);
40 });
41 });
42
43 video.load();
44
45 }, 'exercises the ShapeDetection API detect(HTMLVideoElement)');
46
47 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698