<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[189679] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/189679">189679</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-09-13 21:18:18 -0700 (Sun, 13 Sep 2015)</dd>
</dl>

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

&lt;rdar://problem/22567705&gt;

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:

&lt;rdar://problem/22567705&gt;

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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsmisclastmodifiedparsingexpectedtxt">trunk/LayoutTests/http/tests/misc/last-modified-parsing-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsresourceslastmodifiedphp">trunk/LayoutTests/http/tests/resources/last-modified.php</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomdocumentsresourcemetadatamanagementdocumentlastModified01expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomdocumentsresourcemetadatamanagementdocumentlastModifiedexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/LayoutTests/ChangeLog        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-09-13  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        document.lastModified should use the user's local time zone
+        https://bugs.webkit.org/show_bug.cgi?id=149092
+
+        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:
+
</ins><span class="cx"> 2015-09-13  Gyuyoung Kim  &lt;gyuyoung.kim@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed EFL gardening.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsmisclastmodifiedparsingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/misc/last-modified-parsing-expected.txt (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/misc/last-modified-parsing-expected.txt        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/LayoutTests/http/tests/misc/last-modified-parsing-expected.txt        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -3,34 +3,34 @@
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame0--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-11/21/2008 01:03:33
</del><ins>+Fri, 21 Nov 2008 01:03:33 GMT
</ins><span class="cx"> 
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame1--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-11/21/2008 01:03:33
</del><ins>+Fri, 21 Nov 2008 01:03:33 GMT
</ins><span class="cx"> 
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame2--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-11/21/1997 01:03:33
</del><ins>+Fri, 21 Nov 1997 01:03:33 GMT
</ins><span class="cx"> 
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame3--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-11/21/2008 01:03:33
</del><ins>+Fri, 21 Nov 2008 01:03:33 GMT
</ins><span class="cx"> 
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame4--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-02/21/2008 01:03:33
</del><ins>+Thu, 21 Feb 2008 01:03:33 GMT
</ins><span class="cx"> 
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame5--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-02/03/2008 01:03:33
</del><ins>+Sun, 03 Feb 2008 01:03:33 GMT
</ins><span class="cx"> 
</span><span class="cx"> --------
</span><span class="cx"> Frame: '&lt;!--framePath //&lt;!--frame6--&gt;--&gt;'
</span><span class="cx"> --------
</span><del>-03/03/2008 01:03:33
</del><ins>+Mon, 03 Mar 2008 01:03:33 GMT
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsresourceslastmodifiedphp"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/resources/last-modified.php (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resources/last-modified.php        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/LayoutTests/http/tests/resources/last-modified.php        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -3,5 +3,5 @@
</span><span class="cx">     header(&quot;Last-Modified: $date&quot;);
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-document.write(document.lastModified);
</del><ins>+document.write((new Date(document.lastModified)).toUTCString());
</ins><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2015-09-13  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        document.lastModified should use the user's local time zone
+        https://bugs.webkit.org/show_bug.cgi?id=149092
+        &lt;rdar://problem/22567705&gt;
+
+        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:
+
+2015-09-13  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Node.baseURI should not return null for detached nodes
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=149104
</span><span class="cx">         &lt;rdar://problem/22559535&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomdocumentsresourcemetadatamanagementdocumentlastModified01expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-01-expected.txt        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> 
</span><del>-FAIL Date returned by lastModified is current at page load assert_true: expected true got false
</del><ins>+PASS Date returned by lastModified is current at page load 
</ins><span class="cx"> PASS Date returned by lastModified is in the form &quot;MM/DD/YYYY hh:mm:ss&quot;. 
</span><del>-FAIL Date returned by lastModified is in the user's local time zone. assert_true: expected true got false
-FAIL Date returned by lastModified is current after timeout. assert_true: expected true got false
</del><ins>+PASS Date returned by lastModified is in the user's local time zone. 
+PASS Date returned by lastModified is current after timeout. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomdocumentsresourcemetadatamanagementdocumentlastModifiedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/resource-metadata-management/document-lastModified-expected.txt        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL lastModified should return the last modified date and time assert_equals: expected &quot;12/31/1969 17:23:45&quot; but got &quot;01/01/1970 01:23:45&quot;
</del><ins>+PASS lastModified should return the last modified date and time 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/Source/WebCore/ChangeLog        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -1,5 +1,26 @@
</span><span class="cx"> 2015-09-13  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        document.lastModified should use the user's local time zone
+        https://bugs.webkit.org/show_bug.cgi?id=149092
+        &lt;rdar://problem/22567705&gt;
+
+        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.
+
+2015-09-13  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Node.baseURI should not return null for detached nodes
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=149104
</span><span class="cx">         &lt;rdar://problem/22559535&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (189678 => 189679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2015-09-14 03:07:48 UTC (rev 189678)
+++ trunk/Source/WebCore/dom/Document.cpp        2015-09-14 04:18:18 UTC (rev 189679)
</span><span class="lines">@@ -161,6 +161,7 @@
</span><span class="cx"> #include &quot;XPathResult.h&quot;
</span><span class="cx"> #include &quot;htmlediting.h&quot;
</span><span class="cx"> #include &lt;JavaScriptCore/Profile.h&gt;
</span><ins>+#include &lt;ctime&gt;
</ins><span class="cx"> #include &lt;inspector/ScriptCallStack.h&gt;
</span><span class="cx"> #include &lt;wtf/CurrentTime.h&gt;
</span><span class="cx"> #include &lt;wtf/TemporaryChange.h&gt;
</span><span class="lines">@@ -4236,34 +4237,30 @@
</span><span class="cx"> // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
</span><span class="cx"> String Document::lastModified() const
</span><span class="cx"> {
</span><del>-    DateComponents date;
-    bool foundDate = false;
-    if (m_frame) {
-        auto lastModifiedDate = loader() ? loader()-&gt;response().lastModified() : Nullopt;
-        if (lastModifiedDate) {
-            using namespace std::chrono;
-            date.setMillisecondsSinceEpochForDateTime(duration_cast&lt;milliseconds&gt;(lastModifiedDate.value().time_since_epoch()).count());
-            foundDate = true;
-        }
-    }
</del><ins>+    using namespace std::chrono;
+    Optional&lt;system_clock::time_point&gt; dateTime;
+    if (m_frame &amp;&amp; loader())
+        dateTime = loader()-&gt;response().lastModified();
+
</ins><span class="cx">     // FIXME: If this document came from the file system, the HTML5
</span><del>-    // specificiation tells us to read the last modification date from the file
</del><ins>+    // specification tells us to read the last modification date from the file
</ins><span class="cx">     // system.
</span><del>-    if (!foundDate) {
-        double fallbackDate = currentTimeMS();
</del><ins>+    if (!dateTime) {
+        dateTime = system_clock::now();
</ins><span class="cx"> #if ENABLE(WEB_REPLAY)
</span><span class="cx">         InputCursor&amp; cursor = inputCursor();
</span><span class="cx">         if (cursor.isCapturing())
</span><del>-            cursor.appendInput&lt;DocumentLastModifiedDate&gt;(fallbackDate);
</del><ins>+            cursor.appendInput&lt;DocumentLastModifiedDate&gt;(duration_cast&lt;milliseconds&gt;(dateTime.value().time_since_epoch()).count());
</ins><span class="cx">         else if (cursor.isReplaying()) {
</span><span class="cx">             if (DocumentLastModifiedDate* input = cursor.fetchInput&lt;DocumentLastModifiedDate&gt;())
</span><del>-                fallbackDate = input-&gt;fallbackValue();
</del><ins>+                dateTime = system_clock::time_point(milliseconds(static_cast&lt;long long&gt;(input-&gt;fallbackValue())));
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><del>-        date.setMillisecondsSinceEpochForDateTime(fallbackDate);
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return String::format(&quot;%02d/%02d/%04d %02d:%02d:%02d&quot;, date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
</del><ins>+    auto ctime = system_clock::to_time_t(dateTime.value());
+    auto localDateTime = std::localtime(&amp;ctime);
+    return String::format(&quot;%02d/%02d/%04d %02d:%02d:%02d&quot;, localDateTime-&gt;tm_mon + 1, localDateTime-&gt;tm_mday, 1900 + localDateTime-&gt;tm_year, localDateTime-&gt;tm_hour, localDateTime-&gt;tm_min, localDateTime-&gt;tm_sec);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Document::setCookieURL(const URL&amp; url)
</span></span></pre>
</div>
</div>

</body>
</html>