tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / script-tests / ValidityState-rangeOverflow.js
1 description('This test aims to check for rangeOverflow flag with input fields');
2
3 var input = document.createElement('input');
4
5 function checkOverflow(value, max, disabled)
6 {
7     input.value = value;
8     input.max = max;
9     input.disabled = !!disabled;
10     var overflow = input.validity.rangeOverflow;
11     var resultText = 'The value "' + input.value + '" ' +
12         (overflow ? 'overflows' : 'doesn\'t overflow') +
13         ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
14     if (overflow)
15         testPassed(resultText);
16     else
17         testFailed(resultText);
18 }
19
20 function checkNotOverflow(value, max, disabled)
21 {
22     input.value = value;
23     input.max = max;
24     input.disabled = !!disabled;
25     var overflow = input.validity.rangeOverflow;
26     var resultText = 'The value "' + input.value + '" ' +
27         (overflow ? 'overflows' : 'doesn\'t overflow') +
28         ' the maximum value "' + input.max + '"' + (disabled ? ' when disabled.' : '.');
29     if (overflow)
30         testFailed(resultText);
31     else
32         testPassed(resultText);
33 }
34
35 // ----------------------------------------------------------------
36 debug('Type=text');
37 input.type = 'text';  // No overflow for type=text.
38 checkNotOverflow('101', '100');
39
40 // ----------------------------------------------------------------
41 debug('');
42 debug('Type=number');
43 input.type = 'number';
44 input.min = '';
45 checkNotOverflow('99', '100');  // Very normal case.
46 checkNotOverflow('-101', '-100');
47 checkNotOverflow('99', '1E+2');
48 checkNotOverflow('0.99', '1.00');
49 checkNotOverflow('abc', '100');  // Invalid value.
50 checkNotOverflow('', '-1');  // No value.
51 checkNotOverflow('101', '');  // No max.
52 checkNotOverflow('101', 'xxx');  // Invalid max.
53 // The following case should be rangeOverflow==true ideally.  But the "double" type doesn't have enough precision.
54 checkNotOverflow('0.999999999999999999999999999999999999999999', '0.999999999999999999999999999999999999999998');
55
56 // Overflow cases
57 checkOverflow('101', '100');
58 checkOverflow('-99', '-100');
59 checkOverflow('101', '1E+2');
60 input.min = '200';  // value < min && value > max
61 checkOverflow('101', '100');
62
63 // Disabled
64 checkNotOverflow('101', '1E+2', true);