OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
tkent
2014/07/18 14:16:56
This test is flaky, and unacceptable. We make ano
tkent
2014/07/18 14:17:26
make -> need to make
kangil_
2014/07/21 02:34:41
Done.
kangil_
2014/07/21 02:34:41
Done.
| |
2 <title>document.lastModified should return current local time</title> | |
3 <script src="../../../resources/testharness.js"></script> | |
4 <script src="../../../resources/testharnessreport.js"></script> | |
5 <link rel="stylesheet" href="../../../resources/testharness.css"> | |
6 <div id="log"></div> | |
7 <script> | |
8 var d = new Date(); | |
9 var localTimeFormatted = ("0" + (d.getHours())).slice(-2) + ":" + ("0" + (d. getMinutes())).slice(-2); | |
10 test(function() { | |
11 assert_equals(document.lastModified.substring(11, 16), localTimeFormatte d, | |
tkent
2014/07/18 14:16:56
We have no guarantee that |d| and document.lastMod
kangil_
2014/07/21 02:34:41
Done.
| |
12 "Hours and minutes should match local time."); | |
13 }, "Date returned by lastModified is in the user's local time zone."); | |
tkent
2014/07/18 14:16:56
Actually, this test doesn't make sense if we run t
kangil_
2014/07/21 02:34:41
Done.
| |
14 var lastMod = document.lastModified; | |
15 var pattern = /[0-9]{2}\/[0-9]{2}\/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}/ | |
16 var currentDate = new Date(); | |
tkent
2014/07/18 14:16:56
|lastMod| and |currentDate| can have different dig
kangil_
2014/07/21 02:34:41
Done.
| |
17 var month = ("0" + (currentDate.getMonth() + 1)).slice(-2) | |
18 var day = ("0" + (currentDate.getDate())).slice(-2) | |
19 var year = currentDate.getFullYear().toString() | |
20 var hours = ("0" + (currentDate.getHours())).slice(-2) | |
21 var minutes = ("0" + (currentDate.getMinutes())).slice(-2) | |
22 var seconds = ("0" + (currentDate.getSeconds())).slice(-2); | |
23 test(function() { | |
24 assert_regexp_match(lastMod, pattern, | |
25 "Format should match the pattern \"NN/NN/NNNN NN:NN:NN\"."); | |
26 assert_equals(lastMod.substring(0,2), month, "MM part should match month ."); | |
27 assert_equals(lastMod.substring(3,5), day, "DD part should match day."); | |
28 assert_equals(lastMod.substring(6,10), year, "YYYY part should match yea r."); | |
tkent
2014/07/18 14:16:56
This doesn't work in A.D. 10000+.
kangil_
2014/07/21 02:34:41
Done.
| |
29 assert_equals(lastMod.substring(11,13), hours, "hh part should match hou rs."); | |
30 assert_equals(lastMod.substring(14,16), minutes, "mm part should match m inutes."); | |
31 assert_approx_equals(parseInt(lastMod.substring(17,19), 10), | |
32 parseInt(seconds), 1, "ss part should match seconds."); | |
33 }, "Date returned by lastModified is in the form \"MM/DD/YYYY hh:mm:ss\"."); | |
34 var t = async_test('Date returned by lastModified is current.'); | |
35 var old = Date.parse(document.lastModified); | |
36 setTimeout(function() { | |
37 t.step(function() { | |
38 assert_equals((new Date(Date.parse(document.lastModified))).toString (), | |
39 (new Date(old + 1000)).toString()); | |
40 t.done(); | |
41 }); | |
42 }, 1000); | |
43 </script> | |
OLD | NEW |