33a66f737f64c9b9d00a89686816fbc3e85de43b
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / script-tests / input-minmax.js
1 description('Tests the behavior of .min and .max of HTMLInputElement.');
2
3 var input = document.createElement('input');
4
5 // .min and .max just reflect the corresponding attributes.
6 input.type = 'text';
7 shouldBe('input.min', '""');
8 shouldBe('input.max', '""');
9 input.setAttribute('min', '0');
10 input.setAttribute('max', '100');
11 shouldBe('input.min', '"0"');
12 shouldBe('input.max', '"100"');
13 input.setAttribute('min', 'abc');
14 input.setAttribute('max', 'qwerty');
15 shouldBe('input.min', '"abc"');
16 shouldBe('input.max', '"qwerty"');
17
18 input.min = 'foo';
19 input.max = 'bar';
20 shouldBe('input.getAttribute("min")', '"foo"');
21 shouldBe('input.getAttribute("max")', '"bar"');
22 input.min = '';
23 input.max = '';
24 shouldBe('input.getAttribute("min")', '""');
25 shouldBe('input.getAttribute("max")', '""');
26
27 // Null.
28 debug('Setting null to min:');
29 input.min = null;
30 shouldBe('input.min', '""');
31 shouldBe('input.getAttribute("min")', 'null');
32 input.setAttribute('min', null);
33 shouldBe('input.min', '"null"');
34
35 debug('Setting null to max:');
36 input.max = null;
37 shouldBe('input.max', '""');
38 shouldBe('input.getAttribute("max")', 'null');
39 input.setAttribute('max', null);
40 shouldBe('input.max', '"null"');
41
42 // Undefined.
43 debug('Setting undefined to min:');
44 input.min = undefined;
45 shouldBe('input.min', '"undefined"');
46 shouldBe('input.getAttribute("min")', '"undefined"');
47 input.setAttribute('min', undefined);
48 shouldBe('input.min', '"undefined"');
49
50 debug('Setting undefined to max:');
51 input.max = undefined;
52 shouldBe('input.max', '"undefined"');
53 shouldBe('input.getAttribute("max")', '"undefined"');
54 input.setAttribute('max', undefined);
55 shouldBe('input.max', '"undefined"');
56
57 // Non-string.
58 debug('Setting non-string to min:');
59 input.min = 256;
60 shouldBe('input.min', '"256"');
61 shouldBe('input.getAttribute("min")', '"256"');
62 input.setAttribute('min', 256);
63 shouldBe('input.min', '"256"');
64
65 debug('Setting non-string to max:');
66 input.max = 256;
67 shouldBe('input.max', '"256"');
68 shouldBe('input.getAttribute("max")', '"256"');
69 input.setAttribute('max', 256);
70 shouldBe('input.max', '"256"');
71
72 // The range type has the default minimum and the default maximum.
73 // But they aren't exposed by .min .max IDL attributes.
74 debug('Check implicit min/max of type=range:');
75 input.type = 'range';
76 input.setAttribute('min', '');
77 input.setAttribute('max', '');
78 shouldBe('input.min', '""');
79 shouldBe('input.max', '""');