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

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: Created 4 years, 2 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>
5
6 // TODO(xianglu): Consider tests for image with only one dimension equal to zero .
mcasas 2016/10/21 04:41:45 "Consider adding ..." Although there's no hard li
xianglu 2016/10/21 21:08:30 Done.
7
8 // This test verifies that FaceDetector will reject an empty image.
9 async_test(function(rejectEmptyImageTest){
10 var emptyImage = new Image();
11 rejectEmptyImageTest.step(function() {
12 assert_equals(emptyImage.naturalWidth + emptyImage.naturalHeight, 0);
mcasas 2016/10/21 04:41:46 Here you can just assert_equals(), no need to crea
xianglu 2016/10/21 21:08:30 The difference is that without a step function, th
13 });
14 //No need to call onload() because an empty image never fires this event.
15 var faceDetector = new FaceDetector();
16 faceDetector.detect(emptyImage)
17 .then(faceDetectionResult => {
mcasas 2016/10/21 04:41:45 Usually .then() and .catch() clauses are indented
xianglu 2016/10/21 21:08:30 Done.
18 rejectEmptyImageTest.step(function() {
19 assert_unreached("Promise for empty images should not be resolved.");
20 });
21 rejectEmptyImageTest.done();
22 })
23 .catch(error => {
24 rejectEmptyImageTest.step(function() {
25 assert_equals(error.name, "InvalidStateError");
26 assert_equals(error.message, "HTMLImageElement is empty.");
27 });
28 rejectEmptyImageTest.done();
29 });
mcasas 2016/10/21 04:41:45 This whole l.16-29 should be simplified to: asser
xianglu 2016/10/21 21:08:30 I think instead throwing an exception itself, face
30 },"FaceDetector should reject empty images with InvalidStateError.");
31
32 // This test verifies that FaceDetector will reject an undecodable image.
33 async_test(function(rejectUndecodableImageTest){
34 var undecodableImage = new Image();
35 undecodableImage.onload = function () {
36 var faceDetector = new FaceDetector();
37 faceDetector.detect(undecodableImage)
38 .then(faceDetectionResult => {
39 rejectUndecodableImageTest.step(function() {
40 assert_unreached("Promise for undecodable images should not be resolved. ");
41 });
42 rejectUndecodableImageTest.done();
43 })
44 .catch(error => {
45 rejectUndecodableImageTest.step(function() {
46 assert_equals(error.name, "InvalidStateError");
47 assert_equals(error.message, "HTMLImageElement is broken.");
48 });
49 rejectUndecodableImageTest.done();
50 });
51 };
52 undecodableImage.src = "../../imported/wpt/images/broken.png";
53 }, "FaceDetector should reject undecodable images with InvalidStateError.");
54
55
56 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698