Skip to content

Commit

Permalink
Reland "[Shape Detection] Use IDL dictionaries for result types"
Browse files Browse the repository at this point in the history
This reverts commit 00f576f288655f9a52a48caf5216664f56c8df01.

Reason for revert: Failed build was missing the expectation changes from this CL.

Original change's description:
> Revert "[Shape Detection] Use IDL dictionaries for result types"
>
> This reverts commit bae2a7ee57bb5f420d4450234b904425310d303e.
>
> Reason for revert: Suspect for failing webkit_layout_tests on (none)
> GPU on Mac
> https://ci.chromium.org/p/chromium/builders/ci/Mac10.10%20Tests/51385
>
> Original change's description:
> > [Shape Detection] Use IDL dictionaries for result types
> >
> > This change updates the DetectedBarcode, DetectedFace and DetectedText
> > types to be dictionaries rather than interfaces. This is okay because
> > they have only attributes and no methods. This reduces the amount of
> > manually written code necessary to implement them.
> >
> > This enables implementing a new field for issue 1023177 without having
> > to update the manual serialization and deserialization routines.
> >
> > Spec PR: WICG/shape-detection-api#86
> >
> > Bug: 1023177
> > Change-Id: I3b93d1869c5457e2ce3da5b5690a5ff968a3c77c
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040378
> > Auto-Submit: Reilly Grant <[email protected]>
> > Reviewed-by: Victor Costan <[email protected]>
> > Reviewed-by: Yuki Shiino <[email protected]>
> > Reviewed-by: Kentaro Hara <[email protected]>
> > Commit-Queue: Reilly Grant <[email protected]>
> > Cr-Commit-Position: refs/heads/master@{#740356}
>
> [email protected],[email protected],[email protected],[email protected],[email protected]
>
> Change-Id: Ib2075266871bdae5651e684ac652617de91e2bb2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1023177
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049945
> Reviewed-by: Kristi Park <[email protected]>
> Commit-Queue: Kristi Park <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#740493}

[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]

Change-Id: Ib66d8b28cff5650c608c4e995fea350cedcf313f
Bug: 1023177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2049947
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Commit-Queue: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#740786}
  • Loading branch information
reillyeon authored and chromium-wpt-export-bot committed Feb 12, 2020
1 parent 3bd5f27 commit c70a773
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
1 change: 0 additions & 1 deletion IndexedDB/structured-clone.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ cloneObjectTest({foo: true, bar: false}, (orig, clone) => {
// TODO: Test these additional interfaces:
// * DOMQuad
// * DOMException
// * DetectedText, DetectedFace, DetectedBarcode
// * RTCCertificate

// Geometry types
Expand Down
69 changes: 69 additions & 0 deletions shape-detection/detected-postMessage.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/shapedetection-helpers.js"></script>
<script>

// These tests verify that Detected{Face, Barcode} can be passed to
// postMessage().
const postMessageTests =
[
{
createDetector: () => { return new FaceDetector(); },
mockTestName: "FaceDetectionTest",
detectionResultTest: FaceDetectorDetectionResultTest,
name: "Face - DetectedFace can be passed to postMessage()"
},
{
createDetector: () => { return new BarcodeDetector(); },
mockTestName: "BarcodeDetectionTest",
detectionResultTest: BarcodeDetectorDetectionResultTest,
name: "Barcode - DetectedBarcode can be passed to postMessage()"
}
];

for (let postMessageTest of postMessageTests) {
detection_test(postMessageTest.mockTestName, async t => {
const img = new Image();
const imgWatcher = new EventWatcher(t, img, ["load", "error"]);
img.src = "/images/green-16x16.png";
await imgWatcher.wait_for("load");

const canvas = document.createElement("canvas");
canvas.getContext("2d").drawImage(img, 0, 0);

const detector = postMessageTest.createDetector();
const detectionResult = await detector.detect(canvas.getContext("2d")
.getImageData(0, 0, canvas.width, canvas.height));

const msgWatcher = new EventWatcher(t, window, ['message']);
window.postMessage(detectionResult);
const evt = await msgWatcher.wait_for('message');
postMessageTest.detectionResultTest(evt.data)
}, postMessageTest.name);
}

function FaceDetectorDetectionResultTest(detectionResult) {
assert_equals(detectionResult.length, 3, "Number of faces");
assert_equals(detectionResult[0].landmarks.length, 2, "Number of landmarks");
assert_object_equals(detectionResult[0].landmarks[0],
{type : 'eye', locations : [{x : 4.0, y : 5.0}]},
"landmark #1");
assert_equals(detectionResult[0].landmarks[1].locations.length, 8,
"Number of locations along eye");
assert_object_equals(detectionResult[1].landmarks[0],
{type : 'nose', locations : [{x : 100.0, y : 50.0}]},
"landmark #2");
assert_equals(detectionResult[1].landmarks[1].locations.length, 9,
"Number of locations along nose");
}

function BarcodeDetectorDetectionResultTest(detectionResult) {
assert_equals(detectionResult.length, 2, "Number of barcodes");
assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
assert_equals(detectionResult[0].format, "qr_code", "barcode 1 format");
assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
assert_equals(detectionResult[1].format, "code_128", "barcode 2 format");
}

</script>

0 comments on commit c70a773

Please sign in to comment.