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

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

Issue 2455973007: FaceDetection: add support for <video> input (Closed)
Patch Set: xianglu@ 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
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 // Returns a Promise that is resolve()d if detect() fails. 6 // Returns a Promise that is resolve()d if detect() is rejected. Needs an input
7 function detectFaceAndExpectError(imageUrl) { 7 // |element| (e.g. an HTMLImageElement or HTMLVideoElement) and a |url| to load.
8 function detectFaceOnElementAndExpectError(element, url) {
8 return new Promise(function(resolve, reject) { 9 return new Promise(function(resolve, reject) {
9 var image = new Image();
10 var faceDetector = new FaceDetector();
11 var tryFaceDetection = function() { 10 var tryFaceDetection = function() {
12 faceDetector.detect(image) 11 var faceDetector = new FaceDetector();
12 faceDetector.detect(element)
13 .then(faceDetectionResult => { 13 .then(faceDetectionResult => {
14 reject("Promise for this test image should have been rejected."); 14 reject("Promise should have been rejected.");
15 }) 15 })
16 .catch(error => { 16 .catch(error => {
17 resolve(error); 17 resolve(error);
18 }); 18 });
19 }; 19 };
20 image.onload = tryFaceDetection; 20 element.onload = tryFaceDetection;
21 image.onerror = tryFaceDetection; 21 element.onerror = tryFaceDetection;
22 image.src = imageUrl; 22 element.src = url;
23 }); 23 });
24 } 24 }
25 25
26 // This test verifies that FaceDetector will reject an undecodable image. 26 // This test verifies that FaceDetector will reject an undecodable image.
27 promise_test(function(t) { 27 promise_test(function(t) {
28 return detectFaceAndExpectError("../../imported/wpt/images/broken.png") 28 var image = new Image();
29 return detectFaceOnElementAndExpectError(image,
30 "../../imported/wpt/images/broken.png ")
29 .then(function(error) { 31 .then(function(error) {
30 assert_equals(error.name, "InvalidStateError"); 32 assert_equals(error.name, "InvalidStateError");
31 assert_regexp_match(error.message, /Unable to decompress*/); 33 assert_regexp_match(error.message, /Unable to decompress*/);
32 }); 34 });
33 }, "FaceDetector should reject undecodable images with InvalidStateError."); 35 }, "FaceDetector should reject undecodable images with an InvalidStateError.");
36
37 // This test verifies that FaceDetector will reject a broken video.
38 promise_test(function(t) {
39 var video = document.createElement('video');
40 return detectFaceOnElementAndExpectError(video, "content/garbage.webm")
41 .then(function(error) {
42 assert_equals(error.name, "InvalidStateError");
43 });
44 }, "FaceDetector should reject undecodable videos with an InvalidStateError.");
45
34 46
35 </script> 47 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698