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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html

Issue 2441953002: Shape Detection: Add two layout tests for face detection (Closed)
Patch Set: Modify discription mcasas@comments 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script>
4 <script>
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.
10 function detectFaceAndExpectError(imageUrl) {
11 return new Promise(function(resolve, reject) {
12 var image = new Image();
13 var faceDetector = new FaceDetector();
14 image.onload = makePromise;
15 image.onerror = makePromise;
16 function makePromise () {
Reilly Grant (use Gerrit) 2016/10/24 20:07:23 Defining this function after it is used feels weir
17 faceDetector.detect(image)
18 .then(faceDetectionResult => {
19 reject("Promise for this test image should have been rejected.");
20 })
21 .catch(error => {
22 resolve(error);
23 });
24 };
25 image.src = imageUrl;
26 });
27 }
28
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.
39 promise_test(function(t) {
40 return detectFaceAndExpectError("../../imported/wpt/images/broken.png")
41 .then(function(error) {
42 assert_equals(error.name, "InvalidStateError");
43 assert_regexp_match(error.message, /Unable to decompress the image*/);
44 });
45 }, "FaceDetector should reject undecodable images with InvalidStateError.");
46
47 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698