[XHR] Document.lastModified doesn't work for non-rendered documents
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2018 20:28:07 +0000 (20:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2018 20:28:07 +0000 (20:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179375

Patch by Rob Buis <rbuis@igalia.com> on 2018-11-28
Reviewed by Alexey Proskuryakov.

LayoutTests/imported/w3c:

* web-platform-tests/xhr/responsexml-document-properties-expected.txt:

Source/WebCore:

Add setOverrideLastModified to override last modified date for
standalone Documents.

Behavior matches Firefox and Chrome.

Test: web-platform-tests/xhr/responsexml-document-properties.htm

* dom/Document.cpp:
(WebCore::Document::overrideLastModified):
(WebCore::Document::lastModified const): no need to test m_frame since that's already done in loader().
(WebCore::Document::lastModified): Deleted.
* dom/Document.h:
* xml/XMLHttpRequest.cpp:

LayoutTests:

Unskip responsexml-document-properties.htm since the dynamic message is gone.

* TestExpectations:
* platform/wpe/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238628 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/xhr/responsexml-document-properties-expected.txt
LayoutTests/platform/wpe/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/xml/XMLHttpRequest.cpp

index c660f1e..7768961 100644 (file)
@@ -1,3 +1,15 @@
+2018-11-28  Rob Buis  <rbuis@igalia.com>
+
+        [XHR] Document.lastModified doesn't work for non-rendered documents
+        https://bugs.webkit.org/show_bug.cgi?id=179375
+
+        Reviewed by Alexey Proskuryakov.
+
+        Unskip responsexml-document-properties.htm since the dynamic message is gone.
+
+        * TestExpectations:
+        * platform/wpe/TestExpectations:
+
 2018-11-28  Frederic Wang  <fwang@igalia.com>
 
         [iOS Simulator Release WK2] media/no-fullscreen-when-hidden.html is flaky
index 3b8ba3f..ad6a5c8 100644 (file)
@@ -748,8 +748,6 @@ webkit.org/b/187034 imported/w3c/web-platform-tests/webmessaging/without-ports/0
 imported/w3c/web-platform-tests/xhr/send-redirect-bogus.htm [ Skip ]
 imported/w3c/web-platform-tests/xhr/send-redirect-to-cors.htm [ Skip ]
 imported/w3c/web-platform-tests/xhr/send-redirect-to-non-cors.htm [ Skip ]
-# Failing assertion with dynamic message
-imported/w3c/web-platform-tests/xhr/responsexml-document-properties.htm [ Failure ]
 
 imported/w3c/web-platform-tests/fetch/api/basic/block-mime-as-script.html [ DumpJSConsoleLogInStdErr ]
 imported/w3c/web-platform-tests/fetch/api/cors/cors-origin.any.html [ DumpJSConsoleLogInStdErr ]
index 9af875c..e8e2b73 100644 (file)
@@ -1,3 +1,12 @@
+2018-11-28  Rob Buis  <rbuis@igalia.com>
+
+        [XHR] Document.lastModified doesn't work for non-rendered documents
+        https://bugs.webkit.org/show_bug.cgi?id=179375
+
+        Reviewed by Alexey Proskuryakov.
+
+        * web-platform-tests/xhr/responsexml-document-properties-expected.txt:
+
 2018-11-28  Ali Juma  <ajuma@chromium.org>
 
         Intersection Observer: rootMargin: '' gives weird results
index fec030d..6ce2cb0 100644 (file)
@@ -9,18 +9,18 @@ PASS contentType
 FAIL readyState assert_equals: expected "complete" but got "interactive"
 PASS location 
 PASS defaultView 
-FAIL body assert_equals: expected (undefined) undefined but got (object) null
-FAIL images assert_equals: expected (undefined) undefined but got (object) object "[object HTMLCollection]"
+PASS body 
 PASS doctype 
-FAIL forms assert_equals: expected (undefined) undefined but got (object) object "[object HTMLCollection]"
 FAIL all assert_equals: expected undefined but got [object HTMLAllCollection]
-FAIL links assert_equals: expected (undefined) undefined but got (object) object "[object HTMLCollection]"
 PASS cookie 
-FAIL Test document URL properties after redirect assert_equals: expected "http://localhost:8800/XMLHttpRequest/resources/well-formed.xml" but got "http://localhost:8800/XMLHttpRequest/resources/redirect.py?location=well-formed.xml"
-FAIL Test document URL properties of document with <base> after redirect assert_equals: expected "http://localhost:8800/XMLHttpRequest/resources/base.xml" but got "http://localhost:8800/XMLHttpRequest/resources/redirect.py?location=base.xml"
+FAIL Test document URL properties after redirect assert_equals: expected "http://localhost:8800/xhr/resources/well-formed.xml" but got "http://localhost:8800/xhr/resources/redirect.py?location=well-formed.xml"
+FAIL Test document URL properties of document with <base> after redirect assert_equals: expected "http://localhost:8800/xhr/resources/base.xml" but got "http://localhost:8800/xhr/resources/redirect.py?location=base.xml"
 PASS lastModified set to time of response if no HTTP header provided 
-FAIL lastModified set to related HTTP header if provided assert_equals: expected 1505770096000 but got 1505744052000
+PASS lastModified set to related HTTP header if provided 
 PASS cookie (after setting it) 
-PASS styleSheets 
-PASS implementation 
+PASS styleSheets should be an object 
+PASS implementation should be an object 
+PASS images should be an object 
+PASS forms should be an object 
+PASS links should be an object 
 
index c4fa0ed..32c0705 100644 (file)
@@ -1005,7 +1005,6 @@ webkit.org/b/179608 imported/w3c/web-platform-tests/xhr/access-control-preflight
 webkit.org/b/179608 imported/w3c/web-platform-tests/xhr/access-control-preflight-sync-method-denied.htm [ Failure ]
 webkit.org/b/179608 imported/w3c/web-platform-tests/xhr/access-control-preflight-sync-not-supported.htm [ Failure ]
 webkit.org/b/179608 imported/w3c/web-platform-tests/xhr/send-conditional-cors.htm [ Failure ]
-webkit.org/b/179375 imported/w3c/web-platform-tests/xhr/responsexml-document-properties.htm [ Failure ]
 webkit.org/b/171031 imported/w3c/web-platform-tests/xhr/getallresponseheaders-cl.htm [ Failure ]
 
 webkit.org/b/179663 imported/w3c/web-platform-tests/xhr/headers-normalize-response.htm [ Failure ]
index 58c9a47..3e93157 100644 (file)
@@ -1,3 +1,24 @@
+2018-11-28  Rob Buis  <rbuis@igalia.com>
+
+        [XHR] Document.lastModified doesn't work for non-rendered documents
+        https://bugs.webkit.org/show_bug.cgi?id=179375
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add setOverrideLastModified to override last modified date for
+        standalone Documents.
+
+        Behavior matches Firefox and Chrome.
+
+        Test: web-platform-tests/xhr/responsexml-document-properties.htm
+
+        * dom/Document.cpp:
+        (WebCore::Document::overrideLastModified):
+        (WebCore::Document::lastModified const): no need to test m_frame since that's already done in loader().
+        (WebCore::Document::lastModified): Deleted.
+        * dom/Document.h:
+        * xml/XMLHttpRequest.cpp:
+
 2018-11-28  Yongjun Zhang  <yongjun_zhang@apple.com>
 
         Allow WebKit clients to specify a minimum effective width for layout.
index 5c2ff13..2ac5bbe 100644 (file)
@@ -4836,11 +4836,18 @@ ExceptionOr<void> Document::setDomain(const String& newDomain)
     return { };
 }
 
+void Document::overrideLastModified(const std::optional<WallTime>& lastModified)
+{
+    m_overrideLastModified = lastModified;
+}
+
 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
-String Document::lastModified()
+String Document::lastModified() const
 {
     std::optional<WallTime> dateTime;
-    if (m_frame && loader())
+    if (m_overrideLastModified)
+        dateTime = m_overrideLastModified;
+    else if (loader())
         dateTime = loader()->response().lastModified();
 
     // FIXME: If this document came from the file system, the HTML5
index 559a5be..298ba9e 100644 (file)
@@ -929,7 +929,8 @@ public:
     WEBCORE_EXPORT String domain() const;
     ExceptionOr<void> setDomain(const String& newDomain);
 
-    WEBCORE_EXPORT String lastModified();
+    void overrideLastModified(const std::optional<WallTime>&);
+    WEBCORE_EXPORT String lastModified() const;
 
     // The cookieURL is used to query the cookie database for this document's
     // cookies. For example, if the cookie URL is http://example.com, we'll
@@ -1930,6 +1931,8 @@ private:
 
     String m_cachedDOMCookies;
 
+    std::optional<WallTime> m_overrideLastModified;
+
     HashSet<RefPtr<Element>> m_associatedFormControls;
     unsigned m_disabledFieldsetElementsCount { 0 };
 
index 1fc878b..b9eccf3 100644 (file)
@@ -200,7 +200,7 @@ ExceptionOr<Document*> XMLHttpRequest::responseXML()
                 m_responseDocument = HTMLDocument::create(0, m_url);
             else
                 m_responseDocument = XMLDocument::create(0, m_url);
-            // FIXME: Set Last-Modified.
+            m_responseDocument->overrideLastModified(m_response.lastModified());
             m_responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity());
             m_responseDocument->setContextDocument(downcast<Document>(*scriptExecutionContext()));
             m_responseDocument->setSecurityOriginPolicy(scriptExecutionContext()->securityOriginPolicy());