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> |