Chromium Code Reviews| 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..a9e8ff052967d1353f8fbf08c75bcd44cb4da05b |
| --- /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> |
| + |
| +// Returns a Promise that is resolve()d if detect() fails. |
| +function detectFaceAndExpectError(imageUrl) { |
|
mcasas
2016/10/24 17:55:43
Could you add a TODO() here to move this helper fu
|
| + return new Promise(function(resolve, reject) { |
| + var image = new Image(); |
| + var faceDetector = new FaceDetector(); |
| + image.onload = makePromise; |
| + image.onerror = makePromise; |
| + function makePromise () { |
| + faceDetector.detect(image) |
| + .then(faceDetectionResult => { |
| + reject("Promise for this test image should have been rejected."); |
| + }) |
| + .catch(error => { |
| + resolve(error); |
| + }); |
| + }; |
| + 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> |