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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.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/http/tests/shapedetection/shapedetection-cross-origin.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.html b/third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.html
index bcdd690617d4c25c1fc0b8ef14d5efd0b1164df7..d54c4fe56841be8f4553d2d72d26b6829e10b4a6 100644
--- a/third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.html
+++ b/third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.html
@@ -5,14 +5,15 @@
// http:// resources are considered cross-origin from the current file://.
const IMAGE_URL = "http://localhost:8080/security/resources/abe.png";
+const VIDEO_URL = "http://localhost:8080/imported/wpt/media/white.webm";
-// TODO(xianglu): Move this helper function to a shared location for reuse.
-function detectFaceOnImageElementAndExpectError(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 tryFaceDetection = function() {
var faceDetector = new FaceDetector();
- faceDetector.detect(image)
+ faceDetector.detect(element)
.then(faceDetectionResult => {
reject("Promise should have been rejected.");
})
@@ -20,9 +21,9 @@ function detectFaceOnImageElementAndExpectError(imageUrl) {
resolve(error);
});
};
- image.onload = tryFaceDetection;
- image.onerror = tryFaceDetection;
- image.src = imageUrl;
+ element.onload = tryFaceDetection;
+ element.onerror = tryFaceDetection;
+ element.src = url;
});
}
@@ -49,7 +50,8 @@ function detectFaceOnImageBitmapAndExpectError(imageUrl) {
// Verifies that FaceDetector rejects a cross-origin HTMLImageElement.
promise_test(function(t) {
- return detectFaceOnImageElementAndExpectError(IMAGE_URL)
+ var image = new Image();
+ return detectFaceOnElementAndExpectError(image, IMAGE_URL)
.then(error => {
assert_equals(error.name, "SecurityError");
});
@@ -65,4 +67,14 @@ promise_test(function(t) {
},
"FaceDetector should reject cross-origin ImageBitmaps with a SecurityError.");
+// Verifies that FaceDetector rejects a cross-origin HTMLVideoElement.
+promise_test(function(t) {
+ var video = document.createElement('video');
+ return detectFaceOnElementAndExpectError(video, VIDEO_URL)
+ .then(error => {
+ assert_equals(error.name, "SecurityError");
+ });
+},
+"FaceDetector should reject cross-origin HTMLImageElements with a SecurityError.");
+
</script>

Powered by Google App Engine
This is Rietveld 408576698