Index: third_party/WebKit/LayoutTests/shapedetection/detectface.html |
diff --git a/third_party/WebKit/LayoutTests/shapedetection/detectface.html b/third_party/WebKit/LayoutTests/shapedetection/detectface.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e58de942e5fa41375593bfcd2963a6be999ab680 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/shapedetection/detectface.html |
@@ -0,0 +1,43 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="../resources/mojo-helpers.js"></script> |
+<script src="resources/mock-shapedetection.js"></script> |
+<body> |
+<img id='img' src='../media/content/greenbox.png'/> |
+</body> |
+<script> |
+ |
+// This test verifies that FaceDetector can detect(). A mock mojo |
+// server is implemented in mock-shapedetection.js. |
+ |
+async_test(function(t) { |
+ var img = document.getElementById("img"); |
+ |
+ var theMock = null; |
+ mockShapeDetectionReady |
+ .then(mock => { |
+ theMock = mock; |
+ return new FaceDetector(); |
+ }) |
+ .catch(error => { |
+ assert_unreached("Error creating MockShapeDetection: " + error); |
+ }) |
+ .then(detector => { |
+ return detector.detect(img); |
+ }) |
+ .then(faceDetectionResult => { |
+ const imageReceivedByMock = theMock.getFrameData(); |
+ assert_equals(imageReceivedByMock.byteLength, 2500, "imageReceivedByMock.byteLength"); |
+ const GREEN_PIXEL = 0xFF00FF00; |
+ assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be green"); |
+ assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.length"); |
+ t.done(); |
+ }) |
+ .catch(error => { |
+ assert_unreached("Error during detect(img): " + error); |
+ }); |
+ |
+}, 'exercises the ShapeDetection API detect()'); |
+ |
+</script> |