Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html b/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..192279b00dfebac9339810e96b01f78e3b438a64 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html |
| @@ -0,0 +1,56 @@ |
| +<!DOCTYPE html> |
| +<script src=../../resources/testharness.js></script> |
| +<script src=../../resources/testharnessreport.js></script> |
| +<script> |
| + |
| +// TODO(xianglu): Consider tests for image with only one dimension equal to zero. |
|
mcasas
2016/10/21 04:41:45
"Consider adding ..."
Although there's no hard li
xianglu
2016/10/21 21:08:30
Done.
|
| + |
| +// This test verifies that FaceDetector will reject an empty image. |
| +async_test(function(rejectEmptyImageTest){ |
| + var emptyImage = new Image(); |
| + rejectEmptyImageTest.step(function() { |
| + assert_equals(emptyImage.naturalWidth + emptyImage.naturalHeight, 0); |
|
mcasas
2016/10/21 04:41:46
Here you can just assert_equals(), no need to crea
xianglu
2016/10/21 21:08:30
The difference is that without a step function, th
|
| + }); |
| + //No need to call onload() because an empty image never fires this event. |
| + var faceDetector = new FaceDetector(); |
| + faceDetector.detect(emptyImage) |
| + .then(faceDetectionResult => { |
|
mcasas
2016/10/21 04:41:45
Usually .then() and .catch() clauses are indented
xianglu
2016/10/21 21:08:30
Done.
|
| + rejectEmptyImageTest.step(function() { |
| + assert_unreached("Promise for empty images should not be resolved."); |
| + }); |
| + rejectEmptyImageTest.done(); |
| + }) |
| + .catch(error => { |
| + rejectEmptyImageTest.step(function() { |
| + assert_equals(error.name, "InvalidStateError"); |
| + assert_equals(error.message, "HTMLImageElement is empty."); |
| + }); |
| + rejectEmptyImageTest.done(); |
| + }); |
|
mcasas
2016/10/21 04:41:45
This whole l.16-29 should be simplified to:
asser
xianglu
2016/10/21 21:08:30
I think instead throwing an exception itself, face
|
| +},"FaceDetector should reject empty images with InvalidStateError."); |
| + |
| +// This test verifies that FaceDetector will reject an undecodable image. |
| +async_test(function(rejectUndecodableImageTest){ |
| + var undecodableImage = new Image(); |
| + undecodableImage.onload = function () { |
| + var faceDetector = new FaceDetector(); |
| + faceDetector.detect(undecodableImage) |
| + .then(faceDetectionResult => { |
| + rejectUndecodableImageTest.step(function() { |
| + assert_unreached("Promise for undecodable images should not be resolved."); |
| + }); |
| + rejectUndecodableImageTest.done(); |
| + }) |
| + .catch(error => { |
| + rejectUndecodableImageTest.step(function() { |
| + assert_equals(error.name, "InvalidStateError"); |
| + assert_equals(error.message, "HTMLImageElement is broken."); |
| + }); |
| + rejectUndecodableImageTest.done(); |
| + }); |
| + }; |
| + undecodableImage.src = "../../imported/wpt/images/broken.png"; |
| +}, "FaceDetector should reject undecodable images with InvalidStateError."); |
| + |
| + |
| +</script> |