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

Unified Diff: third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html

Issue 2441953002: Shape Detection: Add two layout tests for face detection (Closed)
Patch Set: reillyg@ comments on naming and description 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 | third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..56def7be6c874f4e4374539ff0a9b73bf52fb375
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<script src=../../resources/testharness.js></script>
+<script src=../../resources/testharnessreport.js></script>
+<script>
+
+// TODO(xianglu): Consider adding tests for image with only one dimension
+// equal to zero.
+
+// Returns a Promise that is resolve()d if detect() fails.
+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 an empty image.
+promise_test(function(t) {
+ return detectFaceAndExpectError("")
+ .then(function(error) {
+ assert_equals(error.name, "InvalidStateError");
+ assert_equals(error.message, "HTMLImageElement is empty.");
+ });
+}, "FaceDetector should reject empty images with InvalidStateError.");
+
+// This test verifies that FaceDetector will reject an undecodable image.
+promise_test(function(t) {
+ return detectFaceAndExpectError("../../imported/wpt/images/broken.png")
+ .then(function(error) {
+ assert_equals(error.name, "InvalidStateError");
+ assert_regexp_match(error.message, /Unable to decompress*/);
+ });
+}, "FaceDetector should reject undecodable images with InvalidStateError.");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698