Changeset 189679 in webkit


Ignore:
Timestamp:
Sep 13, 2015 9:18:18 PM (9 years ago)
Author:
Chris Dumez
Message:

document.lastModified should use the user's local time zone
https://bugs.webkit.org/show_bug.cgi?id=149092
LayoutTests/imported/w3c:

<rdar://problem/22567705>

Reviewed by Ryosuke Niwa.

Rebaseline a couple of W3C tests now that more checks are passing.

  • web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt:
  • web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt:

Source/WebCore:

<rdar://problem/22567705>

Reviewed by Ryosuke Niwa.

document.lastModified should use the user's local time zone:
https://html.spec.whatwg.org/multipage/dom.html#dom-document-lastmodified

Chrome and Firefox comply with the specification but WebKit was using
UTC. This patch aligns WebKit's behavior with the specification and
other browsers.

No new tests, already covered by existing tests.

  • dom/Document.cpp:

(WebCore::Document::lastModified):
(WebCore::Document::setCookieURL): Deleted.

LayoutTests:

Reviewed by Ryosuke Niwa.

Update test so that it converts document.lastModified to UTF before
printing it. This is so that we can consistent layout tests results, no
matter the system's timezone.

  • http/tests/misc/last-modified-parsing-expected.txt:
  • http/tests/resources/last-modified.php:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r189678 r189679  
     12015-09-13  Chris Dumez  <cdumez@apple.com>
     2
     3        document.lastModified should use the user's local time zone
     4        https://bugs.webkit.org/show_bug.cgi?id=149092
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Update test so that it converts document.lastModified to UTF before
     9        printing it. This is so that we can consistent layout tests results, no
     10        matter the system's timezone.
     11
     12        * http/tests/misc/last-modified-parsing-expected.txt:
     13        * http/tests/resources/last-modified.php:
     14
    1152015-09-13  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
    216
  • trunk/LayoutTests/http/tests/misc/last-modified-parsing-expected.txt

    r67513 r189679  
    44Frame: '<!--framePath //<!--frame0-->-->'
    55--------
    6 11/21/2008 01:03:33
     6Fri, 21 Nov 2008 01:03:33 GMT
    77
    88--------
    99Frame: '<!--framePath //<!--frame1-->-->'
    1010--------
    11 11/21/2008 01:03:33
     11Fri, 21 Nov 2008 01:03:33 GMT
    1212
    1313--------
    1414Frame: '<!--framePath //<!--frame2-->-->'
    1515--------
    16 11/21/1997 01:03:33
     16Fri, 21 Nov 1997 01:03:33 GMT
    1717
    1818--------
    1919Frame: '<!--framePath //<!--frame3-->-->'
    2020--------
    21 11/21/2008 01:03:33
     21Fri, 21 Nov 2008 01:03:33 GMT
    2222
    2323--------
    2424Frame: '<!--framePath //<!--frame4-->-->'
    2525--------
    26 02/21/2008 01:03:33
     26Thu, 21 Feb 2008 01:03:33 GMT
    2727
    2828--------
    2929Frame: '<!--framePath //<!--frame5-->-->'
    3030--------
    31 02/03/2008 01:03:33
     31Sun, 03 Feb 2008 01:03:33 GMT
    3232
    3333--------
    3434Frame: '<!--framePath //<!--frame6-->-->'
    3535--------
    36 03/03/2008 01:03:33
     36Mon, 03 Mar 2008 01:03:33 GMT
  • trunk/LayoutTests/http/tests/resources/last-modified.php

    r67513 r189679  
    44?>
    55<script>
    6 document.write(document.lastModified);
     6document.write((new Date(document.lastModified)).toUTCString());
    77</script>
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r189677 r189679  
     12015-09-13  Chris Dumez  <cdumez@apple.com>
     2
     3        document.lastModified should use the user's local time zone
     4        https://bugs.webkit.org/show_bug.cgi?id=149092
     5        <rdar://problem/22567705>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Rebaseline a couple of W3C tests now that more checks are passing.
     10
     11        * web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt:
     12        * web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt:
     13
    1142015-09-13  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt

    r189472 r189679  
    11
    2 FAIL Date returned by lastModified is current at page load assert_true: expected true got false
     2PASS Date returned by lastModified is current at page load
    33PASS Date returned by lastModified is in the form "MM/DD/YYYY hh:mm:ss".
    4 FAIL Date returned by lastModified is in the user's local time zone. assert_true: expected true got false
    5 FAIL Date returned by lastModified is current after timeout. assert_true: expected true got false
     4PASS Date returned by lastModified is in the user's local time zone.
     5PASS Date returned by lastModified is current after timeout.
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt

    r189472 r189679  
    11
    2 FAIL lastModified should return the last modified date and time assert_equals: expected "12/31/1969 17:23:45" but got "01/01/1970 01:23:45"
     2PASS lastModified should return the last modified date and time
    33
  • trunk/Source/WebCore/ChangeLog

    r189677 r189679  
     12015-09-13  Chris Dumez  <cdumez@apple.com>
     2
     3        document.lastModified should use the user's local time zone
     4        https://bugs.webkit.org/show_bug.cgi?id=149092
     5        <rdar://problem/22567705>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        document.lastModified should use the user's local time zone:
     10        https://html.spec.whatwg.org/multipage/dom.html#dom-document-lastmodified
     11
     12        Chrome and Firefox comply with the specification but WebKit was using
     13        UTC. This patch aligns WebKit's behavior with the specification and
     14        other browsers.
     15
     16        No new tests, already covered by existing tests.
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::lastModified):
     20        (WebCore::Document::setCookieURL): Deleted.
     21
    1222015-09-13  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/dom/Document.cpp

    r189677 r189679  
    162162#include "htmlediting.h"
    163163#include <JavaScriptCore/Profile.h>
     164#include <ctime>
    164165#include <inspector/ScriptCallStack.h>
    165166#include <wtf/CurrentTime.h>
     
    42374238String Document::lastModified() const
    42384239{
    4239     DateComponents date;
    4240     bool foundDate = false;
    4241     if (m_frame) {
    4242         auto lastModifiedDate = loader() ? loader()->response().lastModified() : Nullopt;
    4243         if (lastModifiedDate) {
    4244             using namespace std::chrono;
    4245             date.setMillisecondsSinceEpochForDateTime(duration_cast<milliseconds>(lastModifiedDate.value().time_since_epoch()).count());
    4246             foundDate = true;
    4247         }
    4248     }
     4240    using namespace std::chrono;
     4241    Optional<system_clock::time_point> dateTime;
     4242    if (m_frame && loader())
     4243        dateTime = loader()->response().lastModified();
     4244
    42494245    // FIXME: If this document came from the file system, the HTML5
    4250     // specificiation tells us to read the last modification date from the file
     4246    // specification tells us to read the last modification date from the file
    42514247    // system.
    4252     if (!foundDate) {
    4253         double fallbackDate = currentTimeMS();
     4248    if (!dateTime) {
     4249        dateTime = system_clock::now();
    42544250#if ENABLE(WEB_REPLAY)
    42554251        InputCursor& cursor = inputCursor();
    42564252        if (cursor.isCapturing())
    4257             cursor.appendInput<DocumentLastModifiedDate>(fallbackDate);
     4253            cursor.appendInput<DocumentLastModifiedDate>(duration_cast<milliseconds>(dateTime.value().time_since_epoch()).count());
    42584254        else if (cursor.isReplaying()) {
    42594255            if (DocumentLastModifiedDate* input = cursor.fetchInput<DocumentLastModifiedDate>())
    4260                 fallbackDate = input->fallbackValue();
     4256                dateTime = system_clock::time_point(milliseconds(static_cast<long long>(input->fallbackValue())));
    42614257        }
    42624258#endif
    4263         date.setMillisecondsSinceEpochForDateTime(fallbackDate);
    4264     }
    4265 
    4266     return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
     4259    }
     4260
     4261    auto ctime = system_clock::to_time_t(dateTime.value());
     4262    auto localDateTime = std::localtime(&ctime);
     4263    return String::format("%02d/%02d/%04d %02d:%02d:%02d", localDateTime->tm_mon + 1, localDateTime->tm_mday, 1900 + localDateTime->tm_year, localDateTime->tm_hour, localDateTime->tm_min, localDateTime->tm_sec);
    42674264}
    42684265
Note: See TracChangeset for help on using the changeset viewer.