|
6 | 6 | <script src="/resources/testharnessreport.js"></script> |
7 | 7 | <div id="log"></div> |
8 | 8 | <script> |
9 | | - var types = [ |
10 | | - { type: "hidden", mode: "default" }, |
11 | | - { type: "text", mode: "value", sanitizedValue: "foo" }, |
12 | | - { type: "search", mode: "value", sanitizedValue: "foo" }, |
13 | | - { type: "tel", mode: "value", sanitizedValue: "foo" }, |
14 | | - { type: "url", mode: "value", sanitizedValue: "foo" }, |
15 | | - { type: "email", mode: "value", sanitizedValue: "foo" }, |
16 | | - { type: "password", mode: "value", sanitizedValue: "foo" }, |
17 | | - { type: "datetime-local", mode: "value", sanitizedValue: "" }, |
18 | | - { type: "date", mode: "value", sanitizedValue: "" }, |
19 | | - { type: "month", mode: "value", sanitizedValue: "" }, |
20 | | - { type: "week", mode: "value", sanitizedValue: "" }, |
21 | | - { type: "time", mode: "value", sanitizedValue: "" }, |
22 | | - { type: "number", mode: "value", sanitizedValue: "" }, |
23 | | - { type: "range", mode: "value", sanitizedValue: "50" }, |
24 | | - { type: "color", mode: "value", sanitizedValue: "#000000" }, |
25 | | - { type: "checkbox", mode: "default/on" }, |
26 | | - { type: "radio", mode: "default/on" }, |
27 | | - { type: "submit", mode: "default" }, |
28 | | - { type: "image", mode: "default" }, |
29 | | - { type: "reset", mode: "default" }, |
30 | | - { type: "button", mode: "default" } |
31 | | - ]; |
32 | | - for (var i = 0; i < types.length; i++) { |
33 | | - test(function() { |
34 | | - var input = document.createElement("input"), |
35 | | - expected; |
36 | | - input.type = types[i].type; |
37 | | - input.value = "foo"; |
38 | | - switch(types[i].mode) { |
39 | | - case "default": |
40 | | - expected = ""; |
41 | | - break; |
42 | | - case "default/on": |
43 | | - expected = "on"; |
44 | | - break; |
45 | | - case "value": |
46 | | - expected = types[i].sanitizedValue; |
47 | | - break; |
48 | | - } |
49 | | - assert_equals(input.value, expected); |
50 | | - }, "value IDL attribute of input type " + types[i].type + " without value attribute"); |
51 | | - |
52 | | - test(function() { |
53 | | - var input = document.createElement("input"), |
54 | | - expected; |
55 | | - input.type = types[i].type; |
56 | | - input.setAttribute("value", "bar"); |
57 | | - input.value = "foo"; |
58 | | - switch(types[i].mode) { |
59 | | - case "default": |
60 | | - expected = "bar"; |
61 | | - break; |
62 | | - case "default/on": |
63 | | - expected = "bar"; |
64 | | - break; |
65 | | - case "value": |
66 | | - expected = types[i].sanitizedValue; |
67 | | - break; |
68 | | - } |
69 | | - assert_equals(input.value, expected); |
70 | | - }, "value IDL attribute of input type " + types[i].type + " with value attribute"); |
71 | | - } |
| 9 | +// MODE DEFAULT |
| 10 | +test(function () { |
| 11 | + var input = document.createElement("input"); |
| 12 | + input.type = "hidden"; |
| 13 | + input.value = "foo"; |
| 14 | + assert_equals(input.value, "foo"); |
| 15 | +}, "value IDL attribute of input type hidden without value attribute"); |
| 16 | +test(function() { |
| 17 | + var input = document.createElement("input"); |
| 18 | + input.type = "hidden"; |
| 19 | + input.setAttribute("value", "bar"); |
| 20 | + input.value = "foo"; |
| 21 | + assert_equals(input.value, "foo"); |
| 22 | +}, "value IDL attribute of input type hidden with value attribute"); |
| 23 | + |
| 24 | +test(function () { |
| 25 | + var input = document.createElement("input"); |
| 26 | + input.type = "submit"; |
| 27 | + input.value = "foo"; |
| 28 | + assert_equals(input.value, "foo"); |
| 29 | +}, "value IDL attribute of input type submit without value attribute"); |
| 30 | +test(function() { |
| 31 | + var input = document.createElement("input"); |
| 32 | + input.type = "submit"; |
| 33 | + input.setAttribute("value", "bar"); |
| 34 | + input.value = "foo"; |
| 35 | + assert_equals(input.value, "foo"); |
| 36 | +}, "value IDL attribute of input type submit with value attribute"); |
| 37 | + |
| 38 | +test(function () { |
| 39 | + var input = document.createElement("input"); |
| 40 | + input.type = "image"; |
| 41 | + input.value = "foo"; |
| 42 | + assert_equals(input.value, "foo"); |
| 43 | +}, "value IDL attribute of input type image without value attribute"); |
| 44 | +test(function() { |
| 45 | + var input = document.createElement("input"); |
| 46 | + input.type = "image"; |
| 47 | + input.setAttribute("value", "bar"); |
| 48 | + input.value = "foo"; |
| 49 | + assert_equals(input.value, "foo"); |
| 50 | +}, "value IDL attribute of input type image with value attribute"); |
| 51 | + |
| 52 | +test(function () { |
| 53 | + var input = document.createElement("input"); |
| 54 | + input.type = "reset"; |
| 55 | + input.value = "foo"; |
| 56 | + assert_equals(input.value, "foo"); |
| 57 | +}, "value IDL attribute of input type reset without value attribute"); |
| 58 | +test(function() { |
| 59 | + var input = document.createElement("input"); |
| 60 | + input.type = "reset"; |
| 61 | + input.setAttribute("value", "bar"); |
| 62 | + input.value = "foo"; |
| 63 | + assert_equals(input.value, "foo"); |
| 64 | +}, "value IDL attribute of input type reset with value attribute"); |
| 65 | + |
| 66 | +test(function () { |
| 67 | + var input = document.createElement("input"); |
| 68 | + input.type = "button"; |
| 69 | + input.value = "foo"; |
| 70 | + assert_equals(input.value, "foo"); |
| 71 | +}, "value IDL attribute of input type button without value attribute"); |
| 72 | +test(function() { |
| 73 | + var input = document.createElement("input"); |
| 74 | + input.type = "button"; |
| 75 | + input.setAttribute("value", "bar"); |
| 76 | + input.value = "foo"; |
| 77 | + assert_equals(input.value, "foo"); |
| 78 | +}, "value IDL attribute of input type button with value attribute"); |
| 79 | + |
| 80 | +// MODE DEFAULT/ON |
| 81 | +test(function () { |
| 82 | + var input = document.createElement("input"); |
| 83 | + input.type = "checkbox"; |
| 84 | + input.value = "foo"; |
| 85 | + assert_equals(input.value, "on"); |
| 86 | +}, "value IDL attribute of input type checkbox without value attribute"); |
| 87 | +test(function() { |
| 88 | + var input = document.createElement("input"); |
| 89 | + input.type = "checkbox"; |
| 90 | + input.setAttribute("value", "bar"); |
| 91 | + input.value = "foo"; |
| 92 | + assert_equals(input.value, "bar"); |
| 93 | +}, "value IDL attribute of input type checkbox with value attribute"); |
| 94 | + |
| 95 | +test(function () { |
| 96 | + var input = document.createElement("input"); |
| 97 | + input.type = "radio"; |
| 98 | + input.value = "foo"; |
| 99 | + assert_equals(input.value, "on"); |
| 100 | +}, "value IDL attribute of input type radio without value attribute"); |
| 101 | +test(function() { |
| 102 | + var input = document.createElement("input"); |
| 103 | + input.type = "radio"; |
| 104 | + input.setAttribute("value", "bar"); |
| 105 | + input.value = "foo"; |
| 106 | + assert_equals(input.value, "bar"); |
| 107 | +}, "value IDL attribute of input type radio with value attribute"); |
| 108 | + |
| 109 | +// MODE VALUE |
| 110 | +test(function () { |
| 111 | + var input = document.createElement("input"); |
| 112 | + input.type = "text"; |
| 113 | + input.value = "foo"; |
| 114 | + assert_equals(input.value, "foo"); |
| 115 | +}, "value IDL attribute of input type text without value attribute"); |
| 116 | +test(function() { |
| 117 | + var input = document.createElement("input"); |
| 118 | + input.type = "text"; |
| 119 | + input.setAttribute("value", "bar"); |
| 120 | + input.value = "foo"; |
| 121 | + assert_equals(input.value, "foo"); |
| 122 | +}, "value IDL attribute of input type text with value attribute"); |
| 123 | + |
| 124 | +test(function () { |
| 125 | + var input = document.createElement("input"); |
| 126 | + input.type = "search"; |
| 127 | + input.value = "foo"; |
| 128 | + assert_equals(input.value, "foo"); |
| 129 | +}, "value IDL attribute of input type search without value attribute"); |
| 130 | +test(function() { |
| 131 | + var input = document.createElement("input"); |
| 132 | + input.type = "search"; |
| 133 | + input.setAttribute("value", "bar"); |
| 134 | + input.value = "foo"; |
| 135 | + assert_equals(input.value, "foo"); |
| 136 | +}, "value IDL attribute of input type search with value attribute"); |
| 137 | + |
| 138 | +test(function () { |
| 139 | + var input = document.createElement("input"); |
| 140 | + input.type = "tel"; |
| 141 | + input.value = "foo"; |
| 142 | + assert_equals(input.value, "foo"); |
| 143 | +}, "value IDL attribute of input type tel without value attribute"); |
| 144 | +test(function() { |
| 145 | + var input = document.createElement("input"); |
| 146 | + input.type = "tel"; |
| 147 | + input.setAttribute("value", "bar"); |
| 148 | + input.value = "foo"; |
| 149 | + assert_equals(input.value, "foo"); |
| 150 | +}, "value IDL attribute of input type tel with value attribute"); |
| 151 | + |
| 152 | +test(function () { |
| 153 | + var input = document.createElement("input"); |
| 154 | + input.type = "url"; |
| 155 | + input.value = "foo"; |
| 156 | + assert_equals(input.value, "foo"); |
| 157 | +}, "value IDL attribute of input type url without value attribute"); |
| 158 | +test(function() { |
| 159 | + var input = document.createElement("input"); |
| 160 | + input.type = "url"; |
| 161 | + input.setAttribute("value", "bar"); |
| 162 | + input.value = "foo"; |
| 163 | + assert_equals(input.value, "foo"); |
| 164 | +}, "value IDL attribute of input type url with value attribute"); |
| 165 | + |
| 166 | +test(function () { |
| 167 | + var input = document.createElement("input"); |
| 168 | + input.type = "email"; |
| 169 | + input.value = "foo"; |
| 170 | + assert_equals(input.value, "foo"); |
| 171 | +}, "value IDL attribute of input type email without value attribute"); |
| 172 | +test(function() { |
| 173 | + var input = document.createElement("input"); |
| 174 | + input.type = "email"; |
| 175 | + input.setAttribute("value", "bar"); |
| 176 | + input.value = "foo"; |
| 177 | + assert_equals(input.value, "foo"); |
| 178 | +}, "value IDL attribute of input type email with value attribute"); |
| 179 | + |
| 180 | +test(function () { |
| 181 | + var input = document.createElement("input"); |
| 182 | + input.type = "password"; |
| 183 | + input.value = "foo"; |
| 184 | + assert_equals(input.value, "foo"); |
| 185 | +}, "value IDL attribute of input type password without value attribute"); |
| 186 | +test(function() { |
| 187 | + var input = document.createElement("input"); |
| 188 | + input.type = "password"; |
| 189 | + input.setAttribute("value", "bar"); |
| 190 | + input.value = "foo"; |
| 191 | + assert_equals(input.value, "foo"); |
| 192 | +}, "value IDL attribute of input type password with value attribute"); |
| 193 | + |
| 194 | +test(function () { |
| 195 | + var input = document.createElement("input"); |
| 196 | + input.type = "datetime-local"; |
| 197 | + input.value = "foo"; |
| 198 | + assert_equals(input.value, ""); |
| 199 | +}, "value IDL attribute of input type datetime-local without value attribute"); |
| 200 | +test(function() { |
| 201 | + var input = document.createElement("input"); |
| 202 | + input.type = "datetime-local"; |
| 203 | + input.setAttribute("value", "bar"); |
| 204 | + input.value = "foo"; |
| 205 | + assert_equals(input.value, ""); |
| 206 | +}, "value IDL attribute of input type datetime-local with value attribute"); |
| 207 | + |
| 208 | +test(function () { |
| 209 | + var input = document.createElement("input"); |
| 210 | + input.type = "date"; |
| 211 | + input.value = "foo"; |
| 212 | + assert_equals(input.value, ""); |
| 213 | +}, "value IDL attribute of input type date without value attribute"); |
| 214 | +test(function() { |
| 215 | + var input = document.createElement("input"); |
| 216 | + input.type = "date"; |
| 217 | + input.setAttribute("value", "bar"); |
| 218 | + input.value = "foo"; |
| 219 | + assert_equals(input.value, ""); |
| 220 | +}, "value IDL attribute of input type date with value attribute"); |
| 221 | + |
| 222 | +test(function () { |
| 223 | + var input = document.createElement("input"); |
| 224 | + input.type = "month"; |
| 225 | + input.value = "foo"; |
| 226 | + assert_equals(input.value, ""); |
| 227 | +}, "value IDL attribute of input type month without value attribute"); |
| 228 | +test(function() { |
| 229 | + var input = document.createElement("input"); |
| 230 | + input.type = "month"; |
| 231 | + input.setAttribute("value", "bar"); |
| 232 | + input.value = "foo"; |
| 233 | + assert_equals(input.value, ""); |
| 234 | +}, "value IDL attribute of input type month with value attribute"); |
| 235 | + |
| 236 | +test(function () { |
| 237 | + var input = document.createElement("input"); |
| 238 | + input.type = "week"; |
| 239 | + input.value = "foo"; |
| 240 | + assert_equals(input.value, ""); |
| 241 | +}, "value IDL attribute of input type week without value attribute"); |
| 242 | +test(function() { |
| 243 | + var input = document.createElement("input"); |
| 244 | + input.type = "week"; |
| 245 | + input.setAttribute("value", "bar"); |
| 246 | + input.value = "foo"; |
| 247 | + assert_equals(input.value, ""); |
| 248 | +}, "value IDL attribute of input type week with value attribute"); |
| 249 | + |
| 250 | +test(function () { |
| 251 | + var input = document.createElement("input"); |
| 252 | + input.type = "time"; |
| 253 | + input.value = "foo"; |
| 254 | + assert_equals(input.value, ""); |
| 255 | +}, "value IDL attribute of input type time without value attribute"); |
| 256 | +test(function() { |
| 257 | + var input = document.createElement("input"); |
| 258 | + input.type = "time"; |
| 259 | + input.setAttribute("value", "bar"); |
| 260 | + input.value = "foo"; |
| 261 | + assert_equals(input.value, ""); |
| 262 | +}, "value IDL attribute of input type time with value attribute"); |
| 263 | + |
| 264 | +test(function () { |
| 265 | + var input = document.createElement("input"); |
| 266 | + input.type = "number"; |
| 267 | + input.value = "foo"; |
| 268 | + assert_equals(input.value, ""); |
| 269 | +}, "value IDL attribute of input type number without value attribute"); |
| 270 | +test(function() { |
| 271 | + var input = document.createElement("input"); |
| 272 | + input.type = "number"; |
| 273 | + input.setAttribute("value", "bar"); |
| 274 | + input.value = "foo"; |
| 275 | + assert_equals(input.value, ""); |
| 276 | +}, "value IDL attribute of input type number with value attribute"); |
| 277 | + |
| 278 | +test(function () { |
| 279 | + var input = document.createElement("input"); |
| 280 | + input.type = "range"; |
| 281 | + input.value = "foo"; |
| 282 | + assert_equals(input.value, "50"); |
| 283 | +}, "value IDL attribute of input type range without value attribute"); |
| 284 | +test(function() { |
| 285 | + var input = document.createElement("input"); |
| 286 | + input.type = "range"; |
| 287 | + input.setAttribute("value", "bar"); |
| 288 | + input.value = "foo"; |
| 289 | + assert_equals(input.value, "50"); |
| 290 | +}, "value IDL attribute of input type range with value attribute"); |
| 291 | + |
| 292 | +test(function () { |
| 293 | + var input = document.createElement("input"); |
| 294 | + input.type = "color"; |
| 295 | + input.value = "foo"; |
| 296 | + assert_equals(input.value, "#000000"); |
| 297 | +}, "value IDL attribute of input type color without value attribute"); |
| 298 | +test(function() { |
| 299 | + var input = document.createElement("input"); |
| 300 | + input.type = "color"; |
| 301 | + input.setAttribute("value", "bar"); |
| 302 | + input.value = "foo"; |
| 303 | + assert_equals(input.value, "#000000"); |
| 304 | +}, "value IDL attribute of input type color with value attribute"); |
72 | 305 | </script> |
0 commit comments