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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.html

Issue 2440243002: Shape Detection: Add cross-origin layout test for face detection (Closed)
Patch Set: mcasas@ comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..9f330c9bb9b20a76d272fbc45a13488b8746621a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/shapedetection/shapedetection-cross-origin.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<script src=../../../../resources/testharness.js></script>
+<script src=../../../../resources/testharnessreport.js></script>
+<script>
+
+// TODO(xianglu): Move this helper function to a shared location for reuse.
+function detectFaceAndExpectError(imageUrl) {
+ return new Promise(function(resolve, reject) {
+ var image = new Image();
+ var faceDetector = new FaceDetector();
+ var tryFaceDetection = function() {
+ faceDetector.detect(image)
+ .then(faceDetectionResult => {
+ reject("Promise for this test image should have been rejected.");
+ })
+ .catch(error => {
+ resolve(error);
+ });
+ };
+ image.onload = tryFaceDetection;
+ image.onerror = tryFaceDetection;
+ image.src = imageUrl;
+ });
+}
+
+// This test verifies that FaceDetector will reject a cross-origin-image.
+promise_test(
+ function(t) {
+ // Since security origin is under file://, images using http protocol
+ // is considered of a different origin.
+ return detectFaceAndExpectError(
+ "http://localhost:8080/security/resources/abe.png")
+ .then(function(error) {
+ assert_equals(error.name, "SecurityError");
+ assert_equals(error.message,
+ "Image source from a different origin.");
+ });
+ },
+ "FaceDetector should reject cross-origin-images with SecurityError.");
+</script>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698