4 <script src=
"../../resources/testharness.js"></script>
5 <script src=
"../../resources/testharnessreport.js"></script>
9 assert_true('autocapitalize' in document
.createElement('input'));
10 }, "Test that the autocapitalize is avaible on HTMLInputElement.")
13 assert_true('autocapitalize' in document
.createElement('textarea'));
14 }, "Test that the autocapitalize is avaible on HTMLTextAreaElement.")
17 var elements
= [ document
.createElement('input'),
18 document
.createElement('textarea') ];
20 elements
.forEach(function(e
) {
21 e
.autocapitalize
= 'on';
22 assert_equals(e
.autocapitalize
, 'sentences');
24 e
.autocapitalize
= 'off';
25 assert_equals(e
.autocapitalize
, 'none');
27 }, "Test deprecated values of autocapitalize.");
30 var elements
= [ document
.createElement('input'),
31 document
.createElement('textarea') ];
32 var knownValues
= [ 'none', 'characters', 'words', 'sentences' ];
34 var defaultValue
= 'sentences';
35 elements
.forEach(function(e
) {
37 assert_equals(e
.autocapitalize
, defaultValue
);
40 e
.autocapitalize
= 'foo';
41 assert_equals(e
.autocapitalize
, defaultValue
);
42 assert_equals(e
.getAttribute('autocapitalize'), 'foo');
43 e
.setAttribute('autocapitalize', 'bar');
44 assert_equals(e
.autocapitalize
, defaultValue
);
45 assert_equals(e
.getAttribute('autocapitalize'), 'bar');
48 e
.removeAttribute('autocapitalize');
49 assert_equals(defaultValue
, e
.autocapitalize
);
50 assert_equals(e
.getAttribute('autocapitalize'), null);
53 e
.setAttribute('autocapitalize', 'NoNe');
54 assert_equals(e
.autocapitalize
, 'none');
55 assert_equals(e
.getAttribute('autocapitalize'), 'NoNe');
56 e
.autocapitalize
= 'WORDS';
57 assert_equals(e
.autocapitalize
, 'words');
58 assert_equals(e
.getAttribute('autocapitalize'), 'WORDS');
60 knownValues
.forEach(function(value
) {
61 e
.setAttribute('autocapitalize', value
);
62 assert_equals(e
.autocapitalize
, value
);
63 assert_equals(e
.getAttribute('autocapitalize'), value
);
65 e
.removeAttribute('autocapitalize');
67 e
.autocapitalize
= value
;
68 assert_equals(e
.autocapitalize
, value
);
69 assert_equals(e
.getAttribute('autocapitalize'), value
);
71 e
.removeAttribute('autocapitalize');
74 }, "Test reflection of autocapitalize.");
78 // Types with sentences as default value.
79 { type
: 'text', value
: 'sentences' },
80 { type
: 'search', value
: 'sentences' },
81 // Types supporting the features with none as default value.
82 { type
: 'email', value
: 'none' },
83 { type
: 'url', value
: 'none' },
84 { type
: 'tel', value
: 'none' },
85 // Other types that do not support the value.
86 { type
: 'number', value
: 'none' },
87 { type
: 'date', value
: 'none' },
88 { type
: 'color', value
: 'none' }
91 testData
.forEach(function(data
) {
92 var input
= document
.createElement('input');
93 input
.type
= data
.type
;
94 assert_equals(input
.autocapitalize
, data
.value
);
96 }, "Test the default value depending on <input> type.")