| 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 <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> |
| OLD | NEW |