blob: f4a71612e4a8e498fb6e45be786553e3584f0933 [file] [log] [blame]
<!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", "password"];
var invalid = ["hidden", "datetime", "date", "month", "week", "datetime-local",
"number", "range", "color", "checkbox", "radio", "button",
"file", "email", "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>