-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #153 from kinu/submissions/kinu
Adding test cases for input type="text" and type="search" (4.10.7.1.2)
- Loading branch information
Showing
2 changed files
with
134 additions
and
49 deletions.
There are no files selected for viewing
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
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,104 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Text input element</title> | ||
<link rel="author" title="Kinuko Yasuda" href="mailto:kinuko@chromium.org"> | ||
<link rel="help" href="http://www.w3.org/html/wg/drafts/html/master/forms.html#text-(type=text)-state-and-search-state-(type=search)"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1>Text input element</h1> | ||
<div style="display: none"> | ||
|
||
<input id="text" type="text" /> | ||
<input id="text_with_value" type="text" value="foo" /> | ||
|
||
<input id="search" type="search" /> | ||
<input id="search_with_value" type="search" value="foo" /> | ||
|
||
</div> | ||
<div id="log"></div> | ||
<script type="text/javascript"> | ||
var types = [ 'text', 'search' ]; | ||
|
||
for (var i = 0; i < types.length; ++i) { | ||
test( | ||
function() { | ||
assert_equals(document.getElementById(types[i]).value, ""); | ||
assert_equals(document.getElementById(types[i] + "_with_value").value, "foo"); | ||
}, "Value returns the current value for " + types[i]); | ||
|
||
test( | ||
function() { | ||
document.getElementById(types[i]).value = "A"; | ||
assert_equals(document.getElementById(types[i]).value, "A"); | ||
document.getElementById(types[i]).value = "B"; | ||
}, "Setting value changes the current value for " + types[i]); | ||
|
||
test( | ||
function() { | ||
// Any LF (\n) must be stripped. | ||
document.getElementById(types[i]).value = "\nAB"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "A\nB"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "AB\n"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
|
||
// Any CR (\r) must be stripped. | ||
document.getElementById(types[i]).value = "\rAB"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "A\rB"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "AB\r"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
|
||
// Any combinations of LF CR must be stripped. | ||
document.getElementById(types[i]).value = "\r\nAB"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "A\r\nB"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "AB\r\n"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
document.getElementById(types[i]).value = "\r\nA\n\rB\r\n"; | ||
assert_equals(document.getElementById(types[i]).value, "AB"); | ||
}, "Value sanitization algorithm should strip line breaks for " + types[i]); | ||
|
||
test( | ||
function() { | ||
assert_equals(document.getElementById(types[i]).files, null); | ||
}, "files attribute must return null for " + types[i]); | ||
|
||
test( | ||
function() { | ||
assert_equals(document.getElementById(types[i]).valueAsDate, null); | ||
}, "valueAsDate attribute must return null for " + types[i]); | ||
|
||
test( | ||
function() { | ||
assert_equals(document.getElementById(types[i]).valueAsNumber, NaN); | ||
}, "valueAsNumber attribute must return NaN for " + types[i]); | ||
|
||
test( | ||
function() { | ||
assert_equals(document.getElementById("text").list, null); | ||
}, "list attribute must return null for " + types[i]); | ||
|
||
test( | ||
function() { | ||
var el = document.getElementById(types[i]); | ||
assert_throws("InvalidStateError", function() { el.stepDown(); }, ""); | ||
}, "stepDown does not apply for " + types[i]); | ||
|
||
test( | ||
function() { | ||
var el = document.getElementById(types[i]); | ||
assert_throws("InvalidStateError", function() { el.stepUp(); }, ""); | ||
}, "stepUp does not apply for " + types[i]); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |