blob: 0031ff250b67cd683a7662c154840c8d2f9ad850 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
// ImageBitmap is of transferable type and can be sent to and tested on worker.
var createTestForImageBitmap = function(detectorType, resultSize) {
async_test(function(t) {
let img = new Image();
img.onload = async function() {
let theImageBitmap = await createImageBitmap(img);
let worker = new Worker("resources/worker.js");
worker.postMessage({
detectorType: detectorType,
bitmap: theImageBitmap,
expectedLength: resultSize
}, [theImageBitmap]);
worker.onmessage = function(e) {
if(e.data=="PASS")
t.done();
}
}
img.src = "../media/content/greenbox.png";
}, detectorType + "Detector detect(ImageBitmap) on worker");
};
// These tests verify that a Detector's detect() works on an ImageBitmap on
// workers. Use the mock mojo server implemented in mock-*detection.js.
generate_tests(createTestForImageBitmap, [
[
"Face",
"Face",
3 // Number of faces
],
[
"Barcode",
"Barcode",
2 // Number of barcodes
],
[
"Text",
"Text",
2 // Number of text blocks
]
]);
</script>