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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/detectface-ImageBitmap.html

Issue 2448193002: ShapeDetection: support CanvasImageSource as detect() source (Closed)
Patch Set: esprehn@ comments and specific LayoutTest for empty HTMLImageElement Created 4 years, 1 month 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-shapedetection.js"></script>
6 <script>
7
8 // This test verifies that FaceDetector can detect(ImageBitmap). Uses the mock
9 // mojo server under mock-shapedetection.js.
10 async_test(function(t) {
11 var img = new Image();
12
13 img.onload = function() {
14 var theImageBitmap = null;
15 var theMock = null;
16
17 createImageBitmap(img)
18 .then(imageBitmap => {
19 theImageBitmap = imageBitmap;
20 return mockShapeDetectionReady;
21 })
22 .catch(error => {
23 assert_unreached('createImageBitmap() error: ' + error);
24 })
25 .then(mock => {
26 theMock = mock;
27 return new FaceDetector();
28 })
29 .catch(error => {
30 assert_unreached("Error creating MockShapeDetection: " + error);
31 })
32 .then(detector => {
33 return detector.detect(theImageBitmap);
34 })
35 .then(faceDetectionResult => {
36 const imageReceivedByMock = theMock.getFrameData();
37 assert_equals(imageReceivedByMock.byteLength, 2500,
38 "imageReceivedByMock.byteLength");
39 const GREEN_PIXEL = 0xFF00FF00;
40 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be gree n");
41 assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.leng th");
42 t.done();
43 })
44 .catch(error => {
45 assert_unreached("Error during detect(img): " + error);
46 });
47 }
48 img.src = '../media/content/greenbox.png';
49 }, 'exercises the ShapeDetection API detect(ImageBitmap)');
50
51 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698