Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src=../../../../resources/testharness.js></script> | |
| 3 <script src=../../../../resources/testharnessreport.js></script> | |
| 4 <script> | |
| 5 | |
| 6 // Returns a Promise that is resolve()d if detect() fails. | |
| 7 function detectFaceAndExpectError(imageUrl) { | |
|
mcasas
2016/10/24 17:55:43
Could you add a TODO() here to move this helper fu
| |
| 8 return new Promise(function(resolve, reject) { | |
| 9 var image = new Image(); | |
| 10 var faceDetector = new FaceDetector(); | |
| 11 image.onload = makePromise; | |
| 12 image.onerror = makePromise; | |
| 13 function makePromise () { | |
| 14 faceDetector.detect(image) | |
| 15 .then(faceDetectionResult => { | |
| 16 reject("Promise for this test image should have been rejected."); | |
| 17 }) | |
| 18 .catch(error => { | |
| 19 resolve(error); | |
| 20 }); | |
| 21 }; | |
| 22 image.src = imageUrl; | |
| 23 }); | |
| 24 } | |
| 25 | |
| 26 // This test verifies that FaceDetector will reject a cross-origin-image. | |
| 27 promise_test( | |
| 28 function(t) { | |
| 29 // Since security origin is under file://, images using http protocol | |
| 30 // is considered of a different origin. | |
| 31 return detectFaceAndExpectError( | |
| 32 "http://localhost:8080/security/resources/abe.png") | |
| 33 .then(function(error) { | |
| 34 assert_equals(error.name, "SecurityError"); | |
| 35 assert_equals(error.message, | |
| 36 "Image source from a different origin."); | |
| 37 }); | |
| 38 }, | |
| 39 "FaceDetector should reject cross-origin-images with SecurityError."); | |
| 40 </script> | |
| OLD | NEW |