-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #775 from deniak/text-field-selection-not-applicable
tests on text field selection on non applicable inputs
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
html/semantics/forms/textfieldselection/selection-not-application-textarea.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>text field selection (textarea)</title> | ||
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> | ||
<link rel=help href="http://www.w3.org/html/wg/drafts/html/master/#textFieldSelection"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
test(function() { | ||
var el = document.createElement("textarea"); | ||
assert_equals(el.selectionStart, 0); | ||
assert_equals(el.selectionEnd, 0); | ||
el.selectionStart = 1; | ||
el.selectionEnd = 1; | ||
el.selectionDirection = "forward"; | ||
el.setRangeText("foobar"); | ||
el.setSelectionRange(0, 1); | ||
}, "text field selection for the input textarea"); | ||
</script> |
48 changes: 48 additions & 0 deletions
48
html/semantics/forms/textfieldselection/selection-not-application.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>text field selection</title> | ||
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> | ||
<link rel=help href="http://www.w3.org/html/wg/drafts/html/master/#textFieldSelection"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="log"></div> | ||
<script> | ||
var types = ["hidden", "email", "datetime", "date", "month", "week", "time", "number", "range", "color", "checkbox", "radio", "file", "submit", "image", "reset", "button"]; //types for which the API doesn't apply | ||
var types2 = ["text", "search", "tel", "url", "password"]; //types for which the API applies | ||
|
||
types.forEach(function(type){ | ||
test(function(){ | ||
var el = document.createElement("input"); | ||
el.type = type; | ||
assert_throws("InvalidStateError", function(){ | ||
el.selectionStart; | ||
}); | ||
assert_throws("InvalidStateError", function(){ | ||
el.selectionEnd; | ||
}); | ||
assert_throws("InvalidStateError", function(){ | ||
el.selectionDirection; | ||
}); | ||
assert_throws("InvalidStateError", function(){ | ||
el.setRangeText("foobar"); | ||
}); | ||
assert_throws("InvalidStateError", function(){ | ||
el.setSelectionRange(0, 1); | ||
}); | ||
}, "text field selection for the input " + type); | ||
}); | ||
|
||
types2.forEach(function(type) { | ||
test(function() { | ||
var el = document.createElement("input"); | ||
el.type = type; | ||
assert_equals(el.selectionStart, 0); | ||
assert_equals(el.selectionEnd, 0); | ||
el.selectionStart = 1; | ||
el.selectionEnd = 1; | ||
el.selectionDirection = "forward"; | ||
el.setRangeText("foobar"); | ||
el.setSelectionRange(0, 1); | ||
}, "text field selection for the input " + type); | ||
}); | ||
</script> |