Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / forms / input-type-change3.html
1 <!DOCTYPE HTML>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 description('Tests for writing and reading .type property of HTMLInputElement.');
5
6 var input = document.createElement('input');
7
8 // The default type is "text".
9 shouldBe('input.type', '"text"');
10 shouldBeNull("input.getAttribute('type')");
11
12 function check(value, expected, expectedAttributeValue)
13 {
14     input.type = value;
15     if (input.type === expected)
16         testPassed('input.type for "' + value + '" is correctly "' + input.type + '".');
17     else
18         testFailed('input.type for "' + value + '" is incorrectly "' + input.type + '", should be "' + expected + '".');
19
20     if (typeof expectedAttributeValue === "undefined")
21         expectedAttributeValue = expected;
22
23     if (input.getAttribute('type') === expectedAttributeValue)
24         testPassed('input.getAttribute("type") for "' + value + '" is correctly "' + expectedAttributeValue + '".');
25     else
26         testFailed('input.getAttribute("type") for "' + value + '" is incorrectly "' + input.getAttribute('type') + '", should be "' + expectedAttributeValue + '".');
27 }
28
29 check("text", "text");
30 check("TEXT", "text", "TEXT");  // input.type must return a lower case value according to DOM Level 2.
31 check(" text ", "text", " text ");
32 check("button", "button");
33 check(" button ", "text", " button ");
34 check("checkbox", "checkbox");
35 check("email", "email");
36 check("file", "file");
37 check("hidden", "hidden");
38 check("image", "image");
39 check("isindex", "text", "isindex");
40 check("number", "number");
41 check("password", "password");
42 check("passwd", "text", "passwd");
43 check("radio", "radio");
44 check("range", "range");
45 check("reset", "reset");
46 check("search", "search");
47 check("submit", "submit");
48 check("tel", "tel");
49 check("telephone", "text", "telephone");
50 check("url", "url");
51 check("uri", "text", "uri");
52
53 // Empty and unknown value handling.
54 check("", "text", "");
55 check("x-unknown", "text", "x-unknown");
56 shouldBeNull("input.removeAttribute('type'); input.getAttribute('type')");
57 </script>