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

Unified Diff: LayoutTests/fast/forms/reportValidity-002.html

Issue 660783002: Implement reportValidity() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Pull Created 6 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
Index: LayoutTests/fast/forms/reportValidity-002.html
diff --git a/LayoutTests/fast/forms/reportValidity-002.html b/LayoutTests/fast/forms/reportValidity-002.html
new file mode 100644
index 0000000000000000000000000000000000000000..6d82f9063a30b2190eaf96a3c02bbf46d4bb8328
--- /dev/null
+++ b/LayoutTests/fast/forms/reportValidity-002.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<style>
+:focus { background: rgb(0, 255, 0); }
+:not(:focus) { background: rgb(255, 0, 0); }
+</style>
+</head>
+<body>
+<p id="description"></p>
+<form method="get">
+<input id="input-empty" name="victim" type="text" required/>
+<input id="input-pattern-mismatch" name="victim" type="text" pattern="Lorem ipsum" value="Loremipsum"/>
+<textarea id="textarea" name="victim" required></textarea>
+<select id="select-no-explicit-value" required>
+ <option>empty</option>
+ <option>another</option>
+</select>
+<select id="select-placeholder" name="victim" required>
+ <option value="" selected />
+ <option value="X">X</option>
+</select>
+<select id="select-non-placeholder" name="victim" required>
+ <option value="X">X</option>
+ <option value="" selected />
+</select>
+</form>
+<div id="console"></div>
+<script>
+ function reportValidityFor(id) {
+ return document.getElementById(id).reportValidity();
+ }
+ function backgroundOf(id) {
+ return document.defaultView.getComputedStyle(document.getElementById(id), null).getPropertyValue('background-color');
+ }
+ var unfocusedColor = 'rgb(255, 0, 0)';
+ var focusedColor = 'rgb(0, 255, 0)';
+
+ description("This test checks if reportValidity() returns correctly a false (meaning error) result on invalid elements, and returns a true result on a blank but valid elements. Blank but non-placeholder label options are valid.");
+
+ shouldBeFalse('reportValidityFor("input-empty")');
+ shouldBe('backgroundOf("input-empty")', 'focusedColor');
+ shouldBeFalse('reportValidityFor("input-pattern-mismatch")');
+ shouldBe('backgroundOf("input-pattern-mismatch")', 'focusedColor');
+ shouldBeFalse('reportValidityFor("textarea")');
+ shouldBe('backgroundOf("textarea")', 'focusedColor');
+ shouldBeTrue('reportValidityFor("select-no-explicit-value")');
+ shouldBe('backgroundOf("select-no-explicit-value")', 'unfocusedColor');
+ shouldBeFalse('reportValidityFor("select-placeholder")');
+ shouldBe('backgroundOf("select-placeholder")', 'focusedColor');
+ shouldBeTrue('reportValidityFor("select-non-placeholder")');
+ shouldBe('backgroundOf("select-non-placeholder")', 'unfocusedColor');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698