Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/WebKit/LayoutTests/shapedetection/detection-on-worker.html

Issue 2629523008: Shape Detection: Remove ConstructorCallWith=Document (Closed)
Patch Set: Add layout test for worker Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/shapedetection/detection-on-worker.html
diff --git a/third_party/WebKit/LayoutTests/shapedetection/detection-on-worker.html b/third_party/WebKit/LayoutTests/shapedetection/detection-on-worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..09438fd241dcc9b1fb0ac2d4598a15b9ffd3de40
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shapedetection/detection-on-worker.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/mock-barcodedetection.js"></script>
+<script src="resources/mock-facedetection.js"></script>
+<script src="resources/mock-textdetection.js"></script>
+<script>
+
+// ImageBitmap is of transferable type and can be sent to and tested on worker.
+var createTestForImageBitmap = function(detectorType, mockReady,
+ resultSize) {
+ async_test(function(t) {
+ var img = new Image();
+
+ img.onload = function() {
+ var theImageBitmap = null;
+ var theMock = null;
+
+ createImageBitmap(img)
+ .then(imageBitmap => {
+ theImageBitmap = imageBitmap;
+ return mockReady();
+ })
+ .catch(error => {
+ assert_unreached("createImageBitmap() error: " + error);
+ })
+ .then(mock => {
+ theMock = mock;
+ return new Worker("resources/worker.js");
+ })
+ .catch(error => {
+ assert_unreached("Error creating Mock: " + error);
+ })
+ .then(worker => {
+ worker.postMessage({
+ detectorType: detectorType,
+ bitmap: theImageBitmap,
+ expectedLength: resultSize
+ }, [theImageBitmap]);
+ worker.onmessage = function(e) {
+ if(e.data=="PASS")
+ t.done();
+ }
+ })
+ .catch(error => {
+ assert_unreached("Error creating detector: " + error);
+ });
+ }
+ 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",
+ () => { return mockFaceDetectionProviderReady; },
+ 3 // Number of faces
+ ],
+ [
+ "Barcode",
+ "Barcode",
+ () => { return mockBarcodeDetectionReady; },
+ 2 // Number of barcodes
+ ],
+ [
+ "Text",
+ "Text",
+ () => { return mockTextDetectionReady; },
+ 2 // Number of text blocks
+ ]
+]);
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698