| 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 9f330c9bb9b20a76d272fbc45a13488b8746621a..bcdd690617d4c25c1fc0b8ef14d5efd0b1164df7 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
|
| @@ -3,15 +3,18 @@
|
| <script src=../../../../resources/testharnessreport.js></script>
|
| <script>
|
|
|
| +// http:// resources are considered cross-origin from the current file://.
|
| +const IMAGE_URL = "http://localhost:8080/security/resources/abe.png";
|
| +
|
| // TODO(xianglu): Move this helper function to a shared location for reuse.
|
| -function detectFaceAndExpectError(imageUrl) {
|
| +function detectFaceOnImageElementAndExpectError(imageUrl) {
|
| return new Promise(function(resolve, reject) {
|
| var image = new Image();
|
| - var faceDetector = new FaceDetector();
|
| var tryFaceDetection = function() {
|
| + var faceDetector = new FaceDetector();
|
| faceDetector.detect(image)
|
| .then(faceDetectionResult => {
|
| - reject("Promise for this test image should have been rejected.");
|
| + reject("Promise should have been rejected.");
|
| })
|
| .catch(error => {
|
| resolve(error);
|
| @@ -23,18 +26,43 @@ function detectFaceAndExpectError(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.");
|
| +function detectFaceOnImageBitmapAndExpectError(imageUrl) {
|
| + return new Promise(function(resolve, reject) {
|
| + var image = new Image();
|
| + image.onload = function() {
|
| + createImageBitmap(image)
|
| + .then(imageBitmap => {
|
| + var faceDetector = new FaceDetector();
|
| + return faceDetector.detect(imageBitmap);
|
| + })
|
| + .then(faceDetectionResult => {
|
| + reject("Promise should have been rejected.");
|
| + })
|
| + .catch(error => {
|
| + resolve(error);
|
| });
|
| - },
|
| - "FaceDetector should reject cross-origin-images with SecurityError.");
|
| + };
|
| + image.onerror = () => {}; // Explicitly ignore expected error events.
|
| + image.src = imageUrl;
|
| + });
|
| +}
|
| +
|
| +// Verifies that FaceDetector rejects a cross-origin HTMLImageElement.
|
| +promise_test(function(t) {
|
| + return detectFaceOnImageElementAndExpectError(IMAGE_URL)
|
| + .then(error => {
|
| + assert_equals(error.name, "SecurityError");
|
| + });
|
| +},
|
| +"FaceDetector should reject cross-origin HTMLImageElements with a SecurityError.");
|
| +
|
| +// Verifies that FaceDetector rejects a cross-origin ImageBitmap.
|
| +promise_test(function(t) {
|
| + return detectFaceOnImageBitmapAndExpectError(IMAGE_URL)
|
| + .then(error => {
|
| + assert_equals(error.name, "SecurityError");
|
| + });
|
| +},
|
| +"FaceDetector should reject cross-origin ImageBitmaps with a SecurityError.");
|
| +
|
| </script>
|
|
|