Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/month/input-valueasdate.html

Issue 2265443002: Fix an overflow in valueAsDate setter of temporal input types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: accept null Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p id="description"></p> 7 <p id="description"></p>
8 <div id="console"></div> 8 <div id="console"></div>
9 <script> 9 <script>
10 description('Test HTMLInputElement::valueAsDate binding.'); 10 description('Test HTMLInputElement::valueAsDate binding.');
11 11
12 var input = document.createElement('input'); 12 var input = document.createElement('input');
13 var date = new Date();
13 14
14 debug('Unsuppported type:'); 15 debug('Unsuppported type:');
15 input.type = 'text'; 16 input.type = 'text';
16 shouldBe('input.valueAsDate', 'null'); 17 shouldBe('input.valueAsDate', 'null');
17 shouldThrow('input.valueAsDate = date'); 18 shouldThrow('input.valueAsDate = date');
18 19
19 debug(''); 20 debug('');
20 debug('Supported type:'); 21 debug('Supported type:');
21 input.type = 'month'; 22 input.type = 'month';
22 input.value = '2009-12'; 23 input.value = '2009-12';
23 var valueAsDate = input.valueAsDate; 24 var valueAsDate = input.valueAsDate;
24 shouldBeTrue('valueAsDate != null'); 25 shouldBeTrue('valueAsDate != null');
25 shouldBe('typeof valueAsDate', '"object"'); 26 shouldBe('typeof valueAsDate', '"object"');
26 shouldBe('valueAsDate.constructor.name', '"Date"'); 27 shouldBe('valueAsDate.constructor.name', '"Date"');
27 28
28 debug('Sets an Epoch Date:'); 29 debug('Sets an Epoch Date:');
29 var date = new Date();
30 date.setTime(0); 30 date.setTime(0);
31 input.valueAsDate = date; 31 input.valueAsDate = date;
32 shouldBe('input.value', '"1970-01"'); 32 shouldBe('input.value', '"1970-01"');
33 shouldBe('input.valueAsDate.getTime()', '0'); 33 shouldBe('input.valueAsDate.getTime()', '0');
34 debug('Sets a number 0:'); 34 debug('Sets a number 0:');
35 input.valueAsDate = 0; 35 shouldThrow('input.valueAsDate = 0');
36 shouldBe('input.value', '"1970-01"');
37 shouldBe('input.valueAsDate.getTime()', '0');
38 debug('Sets other types:'); 36 debug('Sets other types:');
39 input.value = '1970-01'; 37 input.value = '1970-01';
40 input.valueAsDate = null; 38 input.valueAsDate = null;
41 shouldBe('input.value', '""'); 39 shouldBe('input.value', '""');
42 input.value = '1970-01'; 40 shouldThrow('input.valueAsDate = undefined');
43 input.valueAsDate = undefined; 41 shouldThrow('input.valueAsDate = document');
44 shouldBe('input.value', '""');
45 input.value = '1970-01';
46 input.valueAsDate = document;
47 shouldBe('input.value', '""');
48 </script> 42 </script>
49 </body> 43 </body>
50 </html> 44 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698