mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision 7bfa241671d6ca921229f6601d2d7b70dd55da90
This commit is contained in:
parent
f78dd6142e
commit
441c1fa235
47 changed files with 888 additions and 163 deletions
|
@ -0,0 +1,64 @@
|
|||
// META: global=window,worker
|
||||
// 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 => {
|
||||
idl_array.add_objects({
|
||||
FaceDetector: ['faceDetector'],
|
||||
DetectedFace: ['detectedFace'],
|
||||
BarcodeDetector: ['barcodeDetector'],
|
||||
DetectedBarcode: ['detectedBarcode']
|
||||
});
|
||||
|
||||
let faceDetectionTest;
|
||||
try {
|
||||
faceDetectionTest =
|
||||
await initialize_detection_tests("FaceDetectionTest");
|
||||
const img = createTestImage();
|
||||
const theImageBitmap = await createImageBitmap(img);
|
||||
|
||||
self.faceDetector = new FaceDetector();
|
||||
const faceDetectionResult = await faceDetector.detect(theImageBitmap);
|
||||
self.detectedFace = faceDetectionResult[0];
|
||||
} catch (e) {
|
||||
// Surfaced in idlharness.js's test_object.
|
||||
} finally {
|
||||
faceDetectionTest && faceDetectionTest.reset();
|
||||
}
|
||||
|
||||
let barcodeDetectionTest;
|
||||
try {
|
||||
barcodeDetectionTest =
|
||||
await initialize_detection_tests("BarcodeDetectionTest");
|
||||
const img = createTestImage();
|
||||
const theImageBitmap = await createImageBitmap(img);
|
||||
|
||||
self.barcodeDetector = new BarcodeDetector();
|
||||
const barcodeDetectionResult =
|
||||
await barcodeDetector.detect(theImageBitmap);
|
||||
self.detectedBarcode = barcodeDetectionResult[0];
|
||||
} catch (e) {
|
||||
// Surface in idlharness.js's test_object.
|
||||
} finally {
|
||||
barcodeDetectionTest && barcodeDetectionTest.reset();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue