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

Unified Diff: LayoutTests/fast/forms/number/number-reject-invalid.html

Issue 1100273002: input[type=number] UI should reject invalid characters. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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/number/number-reject-invalid.html
diff --git a/LayoutTests/fast/forms/number/number-reject-invalid.html b/LayoutTests/fast/forms/number/number-reject-invalid.html
new file mode 100644
index 0000000000000000000000000000000000000000..bacab09854932c7d9cd4feec6163b72904327052
--- /dev/null
+++ b/LayoutTests/fast/forms/number/number-reject-invalid.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<script>
+if (window.internals)
+ internals.settings.setLangAttributeAwareFormControlUIEnabled(true);
+else
+ debug('Require testRunner.');
+</script>
+
+<input id="input-ar" lang="ar-eg" type="number">
+<input id="input-fr" lang="fr-fr" type="number">
+<input id="input-en" lang="en-us" type="number">
+
+<script>
+function displayValueForKeyInput(inputElement, keyInputs) {
+ inputElement.value = '';
+ inputElement.focus();
+ document.execCommand('InsertText', false, keyInputs);
+ inputElement.select();
+ return window.getSelection().toString();
+}
+
+debug('Arabic number input should accept ASCII digits and Arabic digits, and reject others.');
+var arabicInput = document.getElementById('input-ar');
+shouldBeEqualToString('displayValueForKeyInput(arabicInput, "123.4")', '123.4');
+shouldBeEqualToString('displayValueForKeyInput(arabicInput, "1.23E+19")', '1.23E+19');
+shouldBeEqualToString('displayValueForKeyInput(arabicInput, "1.23e-1")', '1.23e-1');
+shouldBeEqualToString('displayValueForKeyInput(arabicInput, "\u0661\u0669\u0660")', '\u0661\u0669\u0660');
+shouldBeEqualToString('displayValueForKeyInput(arabicInput, "acdef")', 'e');
+
+debug('');
+debug('French number input should accept ASCII digits, comma, and full stop.');
+var frenchInput = document.getElementById('input-fr');
+shouldBeEqualToString('displayValueForKeyInput(frenchInput, "1234.56")', '1234.56');
+shouldBeEqualToString('displayValueForKeyInput(frenchInput, "1234,56")', '1234.56');
+
+debug('');
+debug('English number input should accept ASCII digits and full stop, and no comma.');
+var englishInput = document.getElementById('input-en');
+shouldBeEqualToString('displayValueForKeyInput(englishInput, "1234.56")', '1234.56');
+shouldBeEqualToString('displayValueForKeyInput(englishInput, "-1234,56")', '-123456');
+shouldBeEqualToString('displayValueForKeyInput(englishInput, " abcdef ")', 'e');
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698