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

Unified Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-input-element/input-textselection-01.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/imported/web-platform-tests/html/semantics/forms/the-input-element/input-textselection-01.html
diff --git a/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-input-element/input-textselection-01.html b/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-input-element/input-textselection-01.html
new file mode 100644
index 0000000000000000000000000000000000000000..51fc09785b1cddf6cab9acc1b13c5d6e2af7544b
--- /dev/null
+++ b/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-input-element/input-textselection-01.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<title>The selection interface members</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#textFieldSelection">
+<script src="../../../../../../resources/testharness.js"></script>
+<script src="../../../../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var valid = ["text", "search", "url", "tel", "email", "password"];
+ var invalid = ["hidden", "datetime", "date", "month", "week", "datetime-local",
+ "number", "range", "color", "checkbox", "radio", "button",
+ "file", "submit", "image", "reset"];
+ valid.forEach(function(aType) {
+ test(function() {
+ var input = document.createElement("input");
+ input.type = aType;
+ assert_equals(input.type, aType, "Input type unsupported")
+ input.select();
+ var a = input.selectionStart;
+ input.selectionStart = 0;
+ a = input.selectionEnd;
+ input.selectionEnd = 0;
+ input.setSelectionRange(0, 0);
+ }, "Selection attributes should apply to type " + aType)
+ })
+
+ invalid.forEach(function(aType) {
+ test(function() {
+ var input = document.createElement("input");
+ input.type = aType;
+ assert_equals(input.type, aType, "Input type unsupported")
+ assert_throws("INVALID_STATE_ERR", function() { input.select(); }, "Should throw with type " + aType);
+ assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionStart; });
+ assert_throws("INVALID_STATE_ERR", function() { input.selectionStart = 0; });
+ assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionEnd; });
+ assert_throws("INVALID_STATE_ERR", function() { input.selectionEnd = 0; });
+ assert_throws("INVALID_STATE_ERR", function() { input.setSelectionRange(0, 0); });
+ }, "Selection attributes should not apply to type " + aType)
+ })
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698