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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script> 2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script> 3 <script src=../../resources/testharnessreport.js></script>
4 <script> 4 <script>
5 5
6 // TODO(xianglu): Consider adding tests for image with only one dimension
7 // equal to zero.
8
9 // Returns a Promise that is resolve()d if detect() fails. 6 // Returns a Promise that is resolve()d if detect() fails.
10 function detectFaceAndExpectError(imageUrl) { 7 function detectFaceAndExpectError(imageUrl) {
11 return new Promise(function(resolve, reject) { 8 return new Promise(function(resolve, reject) {
12 var image = new Image(); 9 var image = new Image();
13 var faceDetector = new FaceDetector(); 10 var faceDetector = new FaceDetector();
14 var tryFaceDetection = function() { 11 var tryFaceDetection = function() {
15 faceDetector.detect(image) 12 faceDetector.detect(image)
16 .then(faceDetectionResult => { 13 .then(faceDetectionResult => {
17 reject("Promise for this test image should have been rejected."); 14 reject("Promise for this test image should have been rejected.");
18 }) 15 })
19 .catch(error => { 16 .catch(error => {
20 resolve(error); 17 resolve(error);
21 }); 18 });
22 }; 19 };
23 image.onload = tryFaceDetection; 20 image.onload = tryFaceDetection;
24 image.onerror = tryFaceDetection; 21 image.onerror = tryFaceDetection;
25 image.src = imageUrl; 22 image.src = imageUrl;
26 }); 23 });
27 } 24 }
28 25
29 // This test verifies that FaceDetector will reject an empty image.
30 promise_test(function(t) {
31 return detectFaceAndExpectError("")
32 .then(function(error) {
33 assert_equals(error.name, "InvalidStateError");
34 assert_equals(error.message, "HTMLImageElement is empty.");
35 });
36 }, "FaceDetector should reject empty images with InvalidStateError.");
37
38 // This test verifies that FaceDetector will reject an undecodable image. 26 // This test verifies that FaceDetector will reject an undecodable image.
39 promise_test(function(t) { 27 promise_test(function(t) {
40 return detectFaceAndExpectError("../../imported/wpt/images/broken.png") 28 return detectFaceAndExpectError("../../imported/wpt/images/broken.png")
41 .then(function(error) { 29 .then(function(error) {
42 assert_equals(error.name, "InvalidStateError"); 30 assert_equals(error.name, "InvalidStateError");
43 assert_regexp_match(error.message, /Unable to decompress*/); 31 assert_regexp_match(error.message, /Unable to decompress*/);
44 }); 32 });
45 }, "FaceDetector should reject undecodable images with InvalidStateError."); 33 }, "FaceDetector should reject undecodable images with InvalidStateError.");
46 34
47 </script> 35 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698