JS Test Harness: Insert the stylesheet dynamically
[WebKit-https.git] / LayoutTests / fast / forms / datetime / datetime-stepup-stepdown.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Check stepUp() and stepDown() bahevior for type=datetime.');
11
12 var input = document.createElement('input');
13 var invalidStateErr = '"Error: INVALID_STATE_ERR: DOM Exception 11"';
14
15 function setInputAttributes(min, max, step, value) {
16     input.min = min;
17     input.max = max;
18     input.step = step;
19     input.value = value;
20 }
21
22 function stepUp(value, step, max, optionalStepCount) {
23     setInputAttributes(null, max, step, value);
24     if (typeof optionalStepCount != "undefined")
25         input.stepUp(optionalStepCount);
26     else
27         input.stepUp();
28     return input.value;
29 }
30
31 function stepDown(value, step, min, optionalStepCount) {
32     setInputAttributes(min, null, step, value);
33     if (typeof optionalStepCount != "undefined")
34         input.stepDown(optionalStepCount);
35     else
36         input.stepDown();
37     return input.value;
38 }
39
40 input.type = 'datetime';
41 debug('Invalid value');
42 shouldThrow('stepUp("", null, null)', invalidStateErr);
43 shouldThrow('stepDown("", null, null)', invalidStateErr);
44 debug('Non-number arguments');
45 shouldBe('stepUp("2010-02-10T20:13Z", null, null, "0")', '"2010-02-10T20:13Z"');
46 shouldBe('stepDown("2010-02-10T20:13Z", null, null, "0")', '"2010-02-10T20:13Z"');
47 shouldBe('stepUp("2010-02-10T20:13Z", null, null, "foo")', '"2010-02-10T20:13Z"');
48 shouldBe('stepDown("2010-02-10T20:13Z", null, null, "foo")', '"2010-02-10T20:13Z"');
49 shouldBe('stepUp("2010-02-10T20:13Z", null, null, null)', '"2010-02-10T20:13Z"');
50 shouldBe('stepDown("2010-02-10T20:13Z", null, null, null)', '"2010-02-10T20:13Z"');
51 debug('Normal cases');
52 shouldBe('stepUp("2010-02-10T20:13Z", null, null)', '"2010-02-10T20:14Z"');
53 shouldBe('stepDown("2010-02-10T20:13Z", null, null)', '"2010-02-10T20:12Z"');
54 shouldBe('stepUp("2010-02-10T20:13Z", null, null, 10)', '"2010-02-10T20:23Z"');
55 shouldBe('stepDown("2010-02-10T20:13Z", null, null, 11)', '"2010-02-10T20:02Z"');
56 shouldBe('stepUp("1970-01-01T20:13Z", "4", null, 2)', '"1970-01-01T20:13:08Z"');
57 shouldBe('stepDown("1970-01-01T20:13Z", "4", null, 3)', '"1970-01-01T20:12:48Z"');
58 debug('Step=any');
59 shouldThrow('stepUp("2010-02-10T20:13Z", "any", null)', invalidStateErr);
60 shouldThrow('stepDown("2010-02-10T20:13Z", "any", null)', invalidStateErr);
61 debug('Overflow/underflow');
62 shouldThrow('stepUp("2010-02-10T20:13Z", "3.40282346e+38", null)', invalidStateErr);
63 shouldThrow('stepDown("2010-02-10T20:13Z", "3.40282346e+38", null)', invalidStateErr);
64 shouldThrow('stepUp("2010-02-10T20:13Z", "1", "2010-02-10T20:13Z")', invalidStateErr);
65 shouldThrow('stepDown("2010-02-10T20:13Z", "1", "2010-02-10T20:13Z")', invalidStateErr);
66
67 var successfullyParsed = true;
68 </script>
69 <script src="../../js/resources/js-test-post.js"></script>
70 </body>
71 </html>