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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-barcodedetection.js"></script>
6 <script src="resources/mock-facedetection.js"></script>
7 <script src="resources/mock-textdetection.js"></script>
8 <script>
9
10 // ImageBitmap is of transferable type and can be sent to and tested on worker.
11 var createTestForImageBitmap = function(detectorType, mockReady,
12 resultSize) {
13 async_test(function(t) {
14 var img = new Image();
15
16 img.onload = function() {
17 var theImageBitmap = null;
18 var theMock = null;
19
20 createImageBitmap(img)
21 .then(imageBitmap => {
22 theImageBitmap = imageBitmap;
23 return mockReady();
24 })
25 .catch(error => {
26 assert_unreached("createImageBitmap() error: " + error);
27 })
28 .then(mock => {
29 theMock = mock;
30 return new Worker("resources/worker.js");
31 })
32 .catch(error => {
33 assert_unreached("Error creating Mock: " + error);
34 })
35 .then(worker => {
36 worker.postMessage({
37 detectorType: detectorType,
38 bitmap: theImageBitmap,
39 expectedLength: resultSize
40 }, [theImageBitmap]);
41 worker.onmessage = function(e) {
42 if(e.data=="PASS")
43 t.done();
44 }
45 })
46 .catch(error => {
47 assert_unreached("Error creating detector: " + error);
48 });
49 }
50 img.src = "../media/content/greenbox.png";
51 }, detectorType + "Detector detect(ImageBitmap) on worker");
52 };
53
54 // These tests verify that a Detector's detect() works on an ImageBitmap on
55 // workers. Use the mock mojo server implemented in mock-*detection.js.
56 generate_tests(createTestForImageBitmap, [
57 [
58 "Face",
59 "Face",
60 () => { return mockFaceDetectionProviderReady; },
61 3 // Number of faces
62 ],
63 [
64 "Barcode",
65 "Barcode",
66 () => { return mockBarcodeDetectionReady; },
67 2 // Number of barcodes
68 ],
69 [
70 "Text",
71 "Text",
72 () => { return mockTextDetectionReady; },
73 2 // Number of text blocks
74 ]
75 ]);
76
77 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698