OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="../resources/mojo-helpers.js"></script> | 4 <script src="../resources/mojo-helpers.js"></script> |
5 <script src="resources/mock-barcodedetection.js"></script> | 5 <script src="resources/mock-barcodedetection.js"></script> |
6 <script src="resources/mock-facedetection.js"></script> | 6 <script src="resources/mock-facedetection.js"></script> |
7 <script> | 7 <script> |
8 | 8 |
9 var createTestForVideoElement = function(detectorName, mockReady, | 9 var createTestForVideoElement = function(detectorName, mockReady, |
10 detectionResultTest) { | 10 detectionResultTest) { |
11 async_test(function(t) { | 11 async_test(function(t) { |
12 var video = document.createElement('video'); | 12 var video = document.createElement('video'); |
13 video.src = "../imported/wpt/media/white.webm"; | 13 video.src = "../imported/wpt/media/white.webm"; |
14 video.loop = true; | 14 video.loop = true; |
15 video.autoplay = true; | 15 video.autoplay = true; |
16 video.onerror = this.unreached_func("<video> error"); | 16 video.onerror = this.unreached_func("<video> error"); |
17 video.onplay = this.step_func(function() { | 17 video.onplay = this.step_func(function() { |
18 var theMock = null; | 18 var theMock = null; |
19 mockReady() | 19 mockReady() |
20 .then(mock => { | 20 .then(mock => { |
21 theMock = mock; | 21 theMock = mock; |
22 var detector = eval("new " + detectorName + "();"); | 22 var detector = eval("new " + detectorName + "();"); |
23 return detector; | 23 return detector; |
24 }) | 24 }) |
25 .catch(error => { | 25 .catch(error => { |
26 assert_unreached("Error creating MockFaceDetection: " + error); | 26 assert_unreached("Error creating Mock Detector: " + error); |
27 }) | 27 }) |
28 .then(detector => { | 28 .then(detector => { |
29 return detector.detect(video); | 29 return detector.detect(video); |
30 }) | 30 }) |
31 .then(detectionResult => { | 31 .then(detectionResult => { |
32 detectionResultTest(detectionResult, theMock); | 32 detectionResultTest(detectionResult, theMock); |
33 t.done(); | 33 t.done(); |
34 }) | 34 }) |
35 .catch(error => { | 35 .catch(error => { |
36 assert_unreached("Error during detect(video): " + error); | 36 assert_unreached("Error during detect(video): " + error); |
(...skipping 30 matching lines...) Expand all Loading... |
67 ], | 67 ], |
68 [ | 68 [ |
69 "Barcode", | 69 "Barcode", |
70 "BarcodeDetector", | 70 "BarcodeDetector", |
71 () => { return mockBarcodeDetectionReady; }, | 71 () => { return mockBarcodeDetectionReady; }, |
72 BarcodeDetectorDetectionResultTest | 72 BarcodeDetectorDetectionResultTest |
73 ] | 73 ] |
74 ]); | 74 ]); |
75 | 75 |
76 </script> | 76 </script> |
OLD | NEW |