Add layout test for input.setCustomValidity()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Nov 2016 20:48:18 +0000 (20:48 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Nov 2016 20:48:18 +0000 (20:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164419

Reviewed by Simon Fraser.

Add layout test for input.setCustomValidity().

* fast/forms/validation-custom-message-expected.txt: Added.
* fast/forms/validation-custom-message.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208397 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/validation-custom-message-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/validation-custom-message.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations

index 304ebfb..9403fc9 100644 (file)
@@ -1,3 +1,15 @@
+2016-11-04  Chris Dumez  <cdumez@apple.com>
+
+        Add layout test for input.setCustomValidity()
+        https://bugs.webkit.org/show_bug.cgi?id=164419
+
+        Reviewed by Simon Fraser.
+
+        Add layout test for input.setCustomValidity().
+
+        * fast/forms/validation-custom-message-expected.txt: Added.
+        * fast/forms/validation-custom-message.html: Added.
+
 2016-11-04  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Implement WebGL2RenderingContext::copyBufferSubData()
diff --git a/LayoutTests/fast/forms/validation-custom-message-expected.txt b/LayoutTests/fast/forms/validation-custom-message-expected.txt
new file mode 100644 (file)
index 0000000..c558f83
--- /dev/null
@@ -0,0 +1,11 @@
+Tests that the custom validation message set by JavaScript is displayed on UI side.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS validationBubbleContents.message is "This is a custom validity message."
+PASS validationBubbleContents.message is "Please fill out this field."
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Required text input: 
diff --git a/LayoutTests/fast/forms/validation-custom-message.html b/LayoutTests/fast/forms/validation-custom-message.html
new file mode 100644 (file)
index 0000000..a180996
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<form>
+  Required text input: <input type="text" id="required_text_input" required><input id="required_text_input_submit" type="submit">
+</form>
+<script>
+description("Tests that the custom validation message set by JavaScript is displayed on UI side.");
+jsTestIsAsync = true;
+
+function getValidationBubbleContents()
+{
+    return `
+    (function() {
+        return JSON.stringify(uiController.contentsOfUserInterfaceItem('validationBubble'));
+    })();`
+}
+
+onload = function() {
+    input = document.getElementById("required_text_input");
+    input.setCustomValidity("This is a custom validity message.");
+    submit = document.getElementById("required_text_input_submit");
+    submit.click();
+
+    testRunner.runUIScript(getValidationBubbleContents(), function(result) {
+        validationBubbleContents = JSON.parse(result).validationBubble;
+        shouldBeEqualToString("validationBubbleContents.message", "This is a custom validity message.");
+
+        // Reset the validity message to the default one.
+        input.setCustomValidity("");
+        submit.click();
+
+        testRunner.runUIScript(getValidationBubbleContents(), function(result) {
+            validationBubbleContents = JSON.parse(result).validationBubble;
+            shouldBeEqualToString("validationBubbleContents.message", "Please fill out this field.");
+            finishJSTest();
+        });
+    });
+}
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+<html>
index 0c86322..27887ea 100644 (file)
@@ -240,6 +240,7 @@ webkit.org/b/158585 webgl/webgl-backing-store-size-update.html [ Pass Timeout ]
 [ Sierra+ ] svg/hixie/text/003.html [ Failure ]
 
 # We do not support the new HTML validation UI on WebKit1 yet (rdar://problem/28944652).
+fast/forms/validation-custom-message.html [ Skip ]
 fast/forms/validation-messages.html [ Skip ]
 
 [ Yosemite ] http/tests/media/hls/video-controller-getStartDate.html [ Pass Timeout ]