| 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 <img id='img' src='../media/content/greenbox.png'/> | |
| 8 </body> | |
| 9 <script> | |
| 10 | |
| 11 // This test verifies that FaceDetector can detect(). A mock mojo | |
| 12 // server is implemented in mock-shapedetection.js. | |
| 13 | |
| 14 async_test(function(t) { | |
| 15 var img = document.getElementById("img"); | |
| 16 | |
| 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(img); | |
| 28 }) | |
| 29 .then(faceDetectionResult => { | |
| 30 const imageReceivedByMock = theMock.getFrameData(); | |
| 31 assert_equals(imageReceivedByMock.byteLength, 2500, "imageReceivedByMock.b
yteLength"); | |
| 32 const GREEN_PIXEL = 0xFF00FF00; | |
| 33 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be green"); | |
| 34 assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.length")
; | |
| 35 t.done(); | |
| 36 }) | |
| 37 .catch(error => { | |
| 38 assert_unreached("Error during detect(img): " + error); | |
| 39 }); | |
| 40 | |
| 41 }, 'exercises the ShapeDetection API detect()'); | |
| 42 | |
| 43 </script> | |
| OLD | NEW |