mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 21:58:41 +02:00
Automatic update from web-platform-tests Upstream shapedetection tests to WPT Moved shapedetection 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/, excludes the Text detection part as which is still a sister informative specification of Shape Detection. Copyed third_party/blink/web_tests/shapedetection/resources/big-buffer-helpers.js to wpt/shape-detection/resources/shapedetection-helpers.js and extended it by adding a wrapper promise test, detection_test. Moved third_party/blink/web_tests/shapedetection/resources/mock-barcodedetection.js and third_party/blink/web_tests/shapedetection/resources/mock-facedetection.js to wpt/resources/chromium/ Used the testharness from wpt/ and rewrited tests to remove use of generate_tests as which is discouraged in wpt. Rewrite detection-on-worker.html as detection-on-worker.worker.js by using wpt preferred worker test framework. Rename detection-support.html as detection-getSupportedFormats.html as *-support.html is treated as support file rather than test file in wpt. No new tests have been added. BUG=932382 Change-Id: I321e7b9f986f407b83325bb4c6bdc366c9769264 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1510754 Commit-Queue: Wanming Lin <wanming.lin@intel.com> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#641504} -- wpt-commits: 7183ea12000b9edaac650b1211c35aa6e0abba88 wpt-pr: 15761
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
// META: script=/resources/WebIDLParser.js
|
|
// META: script=/resources/idlharness.js
|
|
// META: script=/shape-detection/resources/shapedetection-helpers.js
|
|
|
|
// See: https://wicg.github.io/shape-detection-api/
|
|
|
|
'use strict';
|
|
|
|
idl_test(
|
|
['shape-detection-api'],
|
|
['dom', 'geometry'],
|
|
async idl_array => {
|
|
let faceDetectionTest, barcodeDetectionTest;
|
|
try {
|
|
faceDetectionTest =
|
|
await initialize_detection_tests("FaceDetectionTest");
|
|
barcodeDetectionTest =
|
|
await initialize_detection_tests("BarcodeDetectionTest");
|
|
const img = createTestImage();
|
|
const theImageBitmap = await createImageBitmap(img);
|
|
|
|
self.faceDetector = new FaceDetector();
|
|
const faceDetectionResult = await faceDetector.detect(theImageBitmap);
|
|
self.detectedFace = faceDetectionResult[0];
|
|
|
|
self.barcodeDetector = new BarcodeDetector();
|
|
const barcodeDetectionResult =
|
|
await barcodeDetector.detect(theImageBitmap);
|
|
self.detectedBarcode = barcodeDetectionResult[0];
|
|
} catch (e) {
|
|
// Surfaced in idlharness.js's test_object below.
|
|
} finally {
|
|
faceDetectionTest.reset();
|
|
barcodeDetectionTest.reset();
|
|
}
|
|
|
|
idl_array.add_objects({
|
|
FaceDetector: ['faceDetector'],
|
|
DetectedFace: ['detectedFace'],
|
|
BarcodeDetector: ['barcodeDetector'],
|
|
DetectedBarcode: ['detectedBarcode']
|
|
});
|
|
}
|
|
);
|
|
|
|
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;
|
|
}
|