Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 <body> | |
| 7 <video id='video' src='../imported/wpt/media/white.webm' autoplay loop/> | |
| 8 </body> | |
| 9 <script> | |
| 10 | |
| 11 // This test verifies that FaceDetector.detect works on an HTMLVideoElement. | |
| 12 // Uses the mock mojo server implemented in mock-shapedetection.js. | |
| 13 async_test(function(t) { | |
| 14 var video = document.createElement('video'); | |
| 15 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.
| |
| 16 video.loop = true; | |
| 17 video.autoplay = true; | |
| 18 video.onerror = this.unreached_func("<video> error"); | |
| 19 video.onplay = this.step_func(function() { | |
| 20 var theMock = null; | |
| 21 mockShapeDetectionReady | |
| 22 .then(mock => { | |
| 23 theMock = mock; | |
| 24 return new FaceDetector(); | |
| 25 }) | |
| 26 .catch(error => { | |
| 27 assert_unreached("Error creating MockShapeDetection: " + error); | |
| 28 }) | |
| 29 .then(detector => { | |
| 30 return detector.detect(video); | |
| 31 }) | |
| 32 .then(faceDetectionResult => { | |
| 33 const imageReceivedByMock = theMock.getFrameData(); | |
| 34 assert_equals(imageReceivedByMock.byteLength, 307200, | |
| 35 "Image length"); | |
| 36 const WHITE_PIXEL = 0xFFFFFFFF; | |
| 37 assert_equals(imageReceivedByMock[0], WHITE_PIXEL, "Pixel color"); | |
| 38 assert_equals(faceDetectionResult.length, 3, "Number of faces"); | |
| 39 t.done(); | |
| 40 }) | |
| 41 .catch(error => { | |
| 42 assert_unreached("Error during detect(img): " + error); | |
| 43 }); | |
| 44 }); | |
| 45 | |
| 46 video.load(); | |
| 47 | |
| 48 }, 'exercises the ShapeDetection API detect(HTMLVideoElement)'); | |
| 49 | |
| 50 </script> | |
| OLD | NEW |