Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/shapedetection/detectface-HTMLVideoElement.html |
| diff --git a/third_party/WebKit/LayoutTests/shapedetection/detectface-HTMLVideoElement.html b/third_party/WebKit/LayoutTests/shapedetection/detectface-HTMLVideoElement.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3defba5c6ab990715fd12bb7f2bd4eaeea37779a |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/shapedetection/detectface-HTMLVideoElement.html |
| @@ -0,0 +1,50 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/mojo-helpers.js"></script> |
| +<script src="resources/mock-shapedetection.js"></script> |
| +<body> |
| +<video id='video' src='../imported/wpt/media/white.webm' autoplay loop/> |
| +</body> |
| +<script> |
| + |
| +// This test verifies that FaceDetector.detect works on an HTMLVideoElement. |
| +// Uses the mock mojo server implemented in mock-shapedetection.js. |
| +async_test(function(t) { |
| + var video = document.createElement('video'); |
| + video.src = "../imported/wpt/media/white.webm"; |
|
xianglu
2016/10/29 01:33:39
Do you still need this if it's specified in the ta
mcasas
2016/10/31 16:36:50
Oh, apologies, I should remove l.7 altogether.
|
| + video.loop = true; |
| + video.autoplay = true; |
| + video.onerror = this.unreached_func("<video> error"); |
| + video.onplay = this.step_func(function() { |
| + var theMock = null; |
| + mockShapeDetectionReady |
| + .then(mock => { |
| + theMock = mock; |
| + return new FaceDetector(); |
| + }) |
| + .catch(error => { |
| + assert_unreached("Error creating MockShapeDetection: " + error); |
| + }) |
| + .then(detector => { |
| + return detector.detect(video); |
| + }) |
| + .then(faceDetectionResult => { |
| + const imageReceivedByMock = theMock.getFrameData(); |
| + assert_equals(imageReceivedByMock.byteLength, 307200, |
| + "Image length"); |
| + const WHITE_PIXEL = 0xFFFFFFFF; |
| + assert_equals(imageReceivedByMock[0], WHITE_PIXEL, "Pixel color"); |
| + assert_equals(faceDetectionResult.length, 3, "Number of faces"); |
| + t.done(); |
| + }) |
| + .catch(error => { |
| + assert_unreached("Error during detect(img): " + error); |
| + }); |
| + }); |
| + |
| + video.load(); |
| + |
| +}, 'exercises the ShapeDetection API detect(HTMLVideoElement)'); |
| + |
| +</script> |