blob: 11376a8dd275887bef8184a5ec79b1847207ae45 [file] [log] [blame]
<!DOCTYPE html>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<script>
// This test verifies *Detector.detect() returns an empty list when fed with
// an empty HTMLImageElement.
var createTestForEmptyInput = function(createDetector) {
async_test(function(t) {
var image = new Image();
var detector = createDetector();
var tryDetection = function() {
detector.detect(image)
.then(detectionResult => {
assert_equals(detectionResult.length, 0);
t.done();
})
.catch(error => {
assert_unreached("detect() rejected with error: " + error)
});
};
image.onload = tryDetection;
image.onerror = tryDetection;
image.src = "";
});
};
generate_tests(createTestForEmptyInput, [
[ "Face - detect(empty)", () => { return new FaceDetector(); } ],
[ "Barcode - detect(empty)", () => { return new BarcodeDetector(); } ],
[ "Text - detect(empty)", () => { return new TextDetector(); } ]
]);
</script>