Chromium Code Reviews| Index: LayoutTests/fast/dom/Document/lastModified-01.html |
| diff --git a/LayoutTests/fast/dom/Document/lastModified-01.html b/LayoutTests/fast/dom/Document/lastModified-01.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a94870bebb9ba4ad41d79bb6cee5a1cf2358cd50 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/Document/lastModified-01.html |
| @@ -0,0 +1,43 @@ |
| +<!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.
|
| +<title>document.lastModified should return current local time</title> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<link rel="stylesheet" href="../../../resources/testharness.css"> |
| +<div id="log"></div> |
| +<script> |
| + var d = new Date(); |
| + var localTimeFormatted = ("0" + (d.getHours())).slice(-2) + ":" + ("0" + (d.getMinutes())).slice(-2); |
| + test(function() { |
| + assert_equals(document.lastModified.substring(11, 16), localTimeFormatted, |
|
tkent
2014/07/18 14:16:56
We have no guarantee that |d| and document.lastMod
kangil_
2014/07/21 02:34:41
Done.
|
| + "Hours and minutes should match local time."); |
| + }, "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.
|
| + var lastMod = document.lastModified; |
| + var pattern = /[0-9]{2}\/[0-9]{2}\/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}/ |
| + 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.
|
| + var month = ("0" + (currentDate.getMonth() + 1)).slice(-2) |
| + var day = ("0" + (currentDate.getDate())).slice(-2) |
| + var year = currentDate.getFullYear().toString() |
| + var hours = ("0" + (currentDate.getHours())).slice(-2) |
| + var minutes = ("0" + (currentDate.getMinutes())).slice(-2) |
| + var seconds = ("0" + (currentDate.getSeconds())).slice(-2); |
| + test(function() { |
| + assert_regexp_match(lastMod, pattern, |
| + "Format should match the pattern \"NN/NN/NNNN NN:NN:NN\"."); |
| + assert_equals(lastMod.substring(0,2), month, "MM part should match month."); |
| + assert_equals(lastMod.substring(3,5), day, "DD part should match day."); |
| + assert_equals(lastMod.substring(6,10), year, "YYYY part should match year."); |
|
tkent
2014/07/18 14:16:56
This doesn't work in A.D. 10000+.
kangil_
2014/07/21 02:34:41
Done.
|
| + assert_equals(lastMod.substring(11,13), hours, "hh part should match hours."); |
| + assert_equals(lastMod.substring(14,16), minutes, "mm part should match minutes."); |
| + assert_approx_equals(parseInt(lastMod.substring(17,19), 10), |
| + parseInt(seconds), 1, "ss part should match seconds."); |
| + }, "Date returned by lastModified is in the form \"MM/DD/YYYY hh:mm:ss\"."); |
| + var t = async_test('Date returned by lastModified is current.'); |
| + var old = Date.parse(document.lastModified); |
| + setTimeout(function() { |
| + t.step(function() { |
| + assert_equals((new Date(Date.parse(document.lastModified))).toString(), |
| + (new Date(old + 1000)).toString()); |
| + t.done(); |
| + }); |
| + }, 1000); |
| +</script> |