mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 21:28:04 +02:00
Automatic update from web-platform-tests Reland: [shapedetection] Upstream TextDetection tests to WPT The original CL has been reverted because the test external/wpt/shape-detection/idlharness.https.any.shareworker.html is flaky on Mac. This reland CL disables this test on Mac. Original change's description: > [shapedetection] Upstream TextDetection tests to WPT > > This CL upstreams the reset of shapedetection tests(mainly > TextDetection tests) to WPT. > > - Moves tests under > third_party/blink/web_tests/shapedetection/, > third_party/blink/web_tests/fast/shapedetection/, > third_party/blink/web_tests/http/tests/shapedetection/, > to third_party/blink/web_tests/external/wpt/shape-detection. > - Moves third_party/blink/web_tests/shapedetection/resources/mock-textdetection.js > to third_party/blink/web_tests/external/wpt/resources/chromium/. > - Removes third_party/blink/web_tests/fast/shapedetection/shapedetection-creation.html > as which should be covered in idlharness tests. > - Introduces simulateClosedPipe() to MockBarcodeDetectionProvider to simulate > 'no implementation available' case for > third_party/blink/web_tests/external/wpt/shape-detection/detection-getSupportedFormats.https.html > - Improves third_party/blink/web_tests/external/wpt/shape-detection/detection-options.https.html > by using assert_throws_js BTW. > > Bug: 932382 > Change-Id: I2f795e4fa4f23b33c49b7924cdbcbccde5ac6ed4 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131154 > Reviewed-by: Reilly Grant <reillyg@chromium.org> > Commit-Queue: Wanming Lin <wanming.lin@intel.com> > Cr-Commit-Position: refs/heads/master@{#756131} Bug: 932382, 1067533 Change-Id: I85b5dcc841185e2edd20a76ed3aec8add7f08954 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134924 Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Wanming Lin <wanming.lin@intel.com> Cr-Commit-Position: refs/heads/master@{#756647} -- wpt-commits: dfc0080d132ac25c4cf824a25735203b3a2b6853 wpt-pr: 22690
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
importScripts("/resources/testharness.js");
|
|
importScripts("resources/shapedetection-helpers.js");
|
|
|
|
'use strict';
|
|
|
|
// These tests verify that a Detector's detect() works on an
|
|
// ImageBitmap on workers.
|
|
const imageBitmapTests =
|
|
[
|
|
{
|
|
createDetector: () => { return new FaceDetector(); },
|
|
mockTestName: "FaceDetectionTest",
|
|
resultSize: 3, // Number of faces
|
|
detectorType: "Face"
|
|
},
|
|
{
|
|
createDetector: () => { return new BarcodeDetector(); },
|
|
mockTestName: "BarcodeDetectionTest",
|
|
resultSize: 2, // Number of barcodes
|
|
detectorType: "Barcode"
|
|
},
|
|
{
|
|
createDetector: () => { return new TextDetector(); },
|
|
mockTestName: "TextDetectionTest",
|
|
resultSize: 2, // Number of text blocks
|
|
detectorType: "Text"
|
|
}
|
|
];
|
|
|
|
for (let imageBitmapTest of imageBitmapTests) {
|
|
// ImageBitmap is of transferable type and can be sent to and
|
|
// tested on worker.
|
|
detection_test(imageBitmapTest.mockTestName, async (t, detectionTest) => {
|
|
const img = createTestImage();
|
|
const theImageBitmap = await createImageBitmap(img);
|
|
const detector = imageBitmapTest.createDetector();
|
|
const detectionResult = await detector.detect(theImageBitmap);
|
|
assert_equals(detectionResult.length, imageBitmapTest.resultSize,
|
|
`Number of ${imageBitmapTest.detectorType}`);
|
|
}, `${imageBitmapTest.detectorType} Detector detect(ImageBitmap) on worker`);
|
|
}
|
|
|
|
function createTestImage() {
|
|
const image = new OffscreenCanvas(100, 50);
|
|
const imgctx = image.getContext('2d');
|
|
imgctx.fillStyle = "#F00";
|
|
imgctx.fillRect(0, 0, 2, 2);
|
|
imgctx.fillStyle = "#0F0";
|
|
imgctx.fillRect(0, 0, 1, 1);
|
|
return image;
|
|
}
|
|
|
|
done();
|