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

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: Use promise_test() instead of async_test() 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>
5
6 // TODO(xianglu): Consider adding tests for image with only one dimension
7 // equal to zero.
8
9 // Returns a promise that will resolve to a rejection from detect method.
mcasas 2016/10/21 23:43:16 This reads a bit confusing, suggest instead: // Re
xianglu 2016/10/22 02:19:09 Done.
10 function makeTestPromiseWithImageUrl(url) {
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 () {
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 = url;
26 });
27 }
28
29 // This test verifies that FaceDetector will reject an empty image.
30 promise_test(function(t) {
31 return makeTestPromiseWithImageUrl("")
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 makeTestPromiseWithImageUrl("../../imported/wpt/images/broken.png")
41 .then(function(error) {
42 assert_equals(error.name, "InvalidStateError");
43 assert_regexp_match(error.message, /Image is broken*/);
44 });
45 }, "FaceDetector should reject undecodable images with InvalidStateError.");
46
47 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698