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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html
diff --git a/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html b/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html
index 9fdfd5bc106630f5135a8ff0c4266c97d673c046..99b5083b1fd20400eec32928d02312d562c6769f 100644
--- a/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html
+++ b/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html
@@ -3,33 +3,45 @@
<script src=../../resources/testharnessreport.js></script>
<script>
-// Returns a Promise that is resolve()d if detect() fails.
-function detectFaceAndExpectError(imageUrl) {
+// Returns a Promise that is resolve()d if detect() is rejected. Needs an input
+// |element| (e.g. an HTMLImageElement or HTMLVideoElement) and a |url| to load.
+function detectFaceOnElementAndExpectError(element, url) {
return new Promise(function(resolve, reject) {
- var image = new Image();
- var faceDetector = new FaceDetector();
var tryFaceDetection = function() {
- faceDetector.detect(image)
+ var faceDetector = new FaceDetector();
+ faceDetector.detect(element)
.then(faceDetectionResult => {
- reject("Promise for this test image should have been rejected.");
+ reject("Promise should have been rejected.");
})
.catch(error => {
resolve(error);
});
};
- image.onload = tryFaceDetection;
- image.onerror = tryFaceDetection;
- image.src = imageUrl;
+ element.onload = tryFaceDetection;
+ element.onerror = tryFaceDetection;
+ element.src = url;
});
}
// This test verifies that FaceDetector will reject an undecodable image.
promise_test(function(t) {
- return detectFaceAndExpectError("../../imported/wpt/images/broken.png")
+ var image = new Image();
+ return detectFaceOnElementAndExpectError(image,
+ "../../imported/wpt/images/broken.png")
.then(function(error) {
assert_equals(error.name, "InvalidStateError");
assert_regexp_match(error.message, /Unable to decompress*/);
});
-}, "FaceDetector should reject undecodable images with InvalidStateError.");
+}, "FaceDetector should reject undecodable images with an InvalidStateError.");
+
+// This test verifies that FaceDetector will reject a broken video.
+promise_test(function(t) {
+ var video = document.createElement('video');
+ return detectFaceOnElementAndExpectError(video, "content/garbage.webm")
+ .then(function(error) {
+ assert_equals(error.name, "InvalidStateError");
+ });
+}, "FaceDetector should reject undecodable videos with an InvalidStateError.");
+
</script>

Powered by Google App Engine
This is Rietveld 408576698