| 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 can detect(ImageBitmap). Uses the mock |
| 9 // mojo server under mock-shapedetection.js. |
| 10 async_test(function(t) { |
| 11 var img = new Image(); |
| 12 |
| 13 img.onload = function() { |
| 14 var theImageBitmap = null; |
| 15 var theMock = null; |
| 16 |
| 17 createImageBitmap(img) |
| 18 .then(imageBitmap => { |
| 19 theImageBitmap = imageBitmap; |
| 20 return mockShapeDetectionReady; |
| 21 }) |
| 22 .catch(error => { |
| 23 assert_unreached('createImageBitmap() error: ' + error); |
| 24 }) |
| 25 .then(mock => { |
| 26 theMock = mock; |
| 27 return new FaceDetector(); |
| 28 }) |
| 29 .catch(error => { |
| 30 assert_unreached("Error creating MockShapeDetection: " + error); |
| 31 }) |
| 32 .then(detector => { |
| 33 return detector.detect(theImageBitmap); |
| 34 }) |
| 35 .then(faceDetectionResult => { |
| 36 const imageReceivedByMock = theMock.getFrameData(); |
| 37 assert_equals(imageReceivedByMock.byteLength, 2500, |
| 38 "imageReceivedByMock.byteLength"); |
| 39 const GREEN_PIXEL = 0xFF00FF00; |
| 40 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be gree
n"); |
| 41 assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.leng
th"); |
| 42 t.done(); |
| 43 }) |
| 44 .catch(error => { |
| 45 assert_unreached("Error during detect(img): " + error); |
| 46 }); |
| 47 } |
| 48 img.src = '../media/content/greenbox.png'; |
| 49 }, 'exercises the ShapeDetection API detect(ImageBitmap)'); |
| 50 |
| 51 </script> |
| OLD | NEW |