Unreviewed, rolling out r247821.
authortsavell@apple.com <tsavell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 17:55:30 +0000 (17:55 +0000)
committertsavell@apple.com <tsavell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 17:55:30 +0000 (17:55 +0000)
Caused two crashing Layout Tests

Reverted changeset:

"Make storing cross-origin top-level prefetches in HTTP cache
optional"
https://bugs.webkit.org/show_bug.cgi?id=199499
https://trac.webkit.org/changeset/247821

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php
LayoutTests/http/tests/cache/resources/prefetched-main-resource.php
LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt [deleted file]
LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html [deleted file]
LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py [deleted file]
LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html [deleted file]
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSEventListener.h
Source/WebCore/dom/EventTarget.h
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLLinkElement.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoader.h

index eb61fba..973cd8d 100644 (file)
@@ -1,3 +1,16 @@
+2019-07-25  Truitt Savell  <tsavell@apple.com>
+
+        Unreviewed, rolling out r247821.
+
+        Caused two crashing Layout Tests
+
+        Reverted changeset:
+
+        "Make storing cross-origin top-level prefetches in HTTP cache
+        optional"
+        https://bugs.webkit.org/show_bug.cgi?id=199499
+        https://trac.webkit.org/changeset/247821
+
 2019-07-25  Russell Epstein  <repstein@apple.com>
 
         Adding iOS-specific expectations for fast/text-indicator/text-indicator-with-low-contrast-text.html.
index 65da64c..a7ad2e9 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 if ($_SERVER["HTTP_PURPOSE"] == "prefetch") {
+    header('Cache-Control: max-age=3600');
+    header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
+
     echo "<script>";
     echo "parent.window.postMessage('FAIL', '*');";
     echo "</script>";
@@ -7,6 +10,8 @@ if ($_SERVER["HTTP_PURPOSE"] == "prefetch") {
     exit();
 }
 
+header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
+
 echo "<script>";
 echo "parent.window.postMessage('PASS', '*');";
 echo "</script>";
index f6aac10..7a3ceb4 100644 (file)
@@ -6,16 +6,16 @@ header('Cache-Control: max-age=3600');
 <body>
 <script>
 
-if (window.testRunner) {
-  fetch('http://localhost:8000/cache/resources/prefetched-main-resource.php').then(function(response) {
-    if (internals.fetchResponseSource(response) != "Disk cache") {
-      document.getElementById('log').innerText = 'FAIL: resource is not in the disk cache.';
-    }
-    testRunner.notifyDone();
-  });
-}
+if (window.testRunner)
+   testRunner.notifyDone();
 
 </script>
-<div id="log"><?php if ($_SERVER["HTTP_PURPOSE"] == "prefetch") echo 'PASS'; else echo 'FAIL'; ?></div>
+<?php
+if ($_SERVER["HTTP_PURPOSE"] == "prefetch") {
+    print('PASS');
+} else {
+    print('FAIL');
+}
+?>
 </body>
 </html>
diff --git a/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt b/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt
deleted file mode 100644 (file)
index 9b6c11a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-PASS Verify that navigating to a main resource can skip disk cache. 
-
diff --git a/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html b/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html
deleted file mode 100644 (file)
index 8509b92..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE html>
-<meta charset="utf-8">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-
-const wait_for_message = () => {
-  return new Promise((resolve, reject) => {
-    window.addEventListener('message', e => {
-      resolve(e);
-    }, { once: true });
-  });
-};
-
-promise_test(async function(t) {
-  let url_from = "resources/navigate-skip-disk-cache.html";
-  var w = window.open(url_from);
-  let message = await wait_for_message();
-  assert_equals(message.data, 'prefetch');
-  w.close();
-}, 'Verify that navigating to a main resource can skip disk cache.');
-</script>
diff --git a/LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py b/LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py
deleted file mode 100644 (file)
index a037fef..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-def main(request, response):
-    headers = [("Content-Type", "text/html")]
-
-    document = """
-<!DOCTYPE html>
-<script>
-  async function test() {
-  var result = '%(prefetch)s';
-  if (window.testRunner) {
-    var response = await fetch('%(url)s');
-    if (internals.fetchResponseSource(response) == "Disk cache") {
-      result = 'FAIL.';
-    }
-  }
-  window.opener.postMessage(result, '*');
-  }
-</script>
-<body onload="test()">
-"""
-
-    return headers, document % {'prefetch': request.headers.get("Purpose", ""), 'url': request.url }
diff --git a/LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html b/LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html
deleted file mode 100644 (file)
index e607630..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE html>
-<meta charset="utf-8">
-<script src="/common/get-host-info.sub.js"></script>
-<body>
-<script>
-  var link = document.createElement("link");
-  link.rel = "prefetch";
-  link.href = get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/prefetch/resources/main-resource-skip-disk-cache.py";
-  document.body.appendChild(link);
-  internals.addPrefetchLoadEventListener(link, () => { window.location = get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/prefetch/resources/main-resource-skip-disk-cache.py" });
-</script>
-</body>
index 5940c9c..eafb29b 100644 (file)
@@ -736,7 +736,6 @@ webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ]
 webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ]
 
 webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ]
-webkit.org/b/199499 http/wpt/prefetch/link-prefetch-skip-disk-cache.html [ Skip ]
 
 webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ]
 webkit.org/b/199632 http/wpt/prefetch/beforeload-dynamic.html [ Skip ]
index c6543cf..d50ab73 100644 (file)
@@ -4424,7 +4424,6 @@ webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ]
 webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ]
 
 webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ]
-webkit.org/b/199499 http/wpt/prefetch/link-prefetch-skip-disk-cache.html [ Skip ]
 
 webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ]
 webkit.org/b/199632 http/wpt/prefetch/beforeload-dynamic.html [ Skip ]
index 631cf6c..c554a11 100644 (file)
@@ -1,3 +1,16 @@
+2019-07-25  Truitt Savell  <tsavell@apple.com>
+
+        Unreviewed, rolling out r247821.
+
+        Caused two crashing Layout Tests
+
+        Reverted changeset:
+
+        "Make storing cross-origin top-level prefetches in HTTP cache
+        optional"
+        https://bugs.webkit.org/show_bug.cgi?id=199499
+        https://trac.webkit.org/changeset/247821
+
 2019-07-25  Chris Dumez  <cdumez@apple.com>
 
         Avoid UI Process hangs when the WebContent process is showing JS prompts / alerts
index 8263b8d..c4668bf 100644 (file)
@@ -38,8 +38,8 @@ class HTMLElement;
 
 class JSEventListener : public EventListener {
 public:
-    WEBCORE_EXPORT static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
-    WEBCORE_EXPORT static RefPtr<JSEventListener> create(JSC::JSValue listener, JSC::JSObject& wrapper, bool isAttribute, DOMWrapperWorld&);
+    static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
+    static RefPtr<JSEventListener> create(JSC::JSValue listener, JSC::JSObject& wrapper, bool isAttribute, DOMWrapperWorld&);
 
     virtual ~JSEventListener();
 
index 720a33b..f82ae52 100644 (file)
@@ -88,7 +88,7 @@ public:
     WEBCORE_EXPORT void removeEventListenerForBindings(const AtomString& eventType, RefPtr<EventListener>&&, ListenerOptionsOrBoolean&&);
     WEBCORE_EXPORT ExceptionOr<bool> dispatchEventForBindings(Event&);
 
-    WEBCORE_EXPORT virtual bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { });
+    virtual bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { });
     virtual bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&);
 
     virtual void removeAllEventListeners();
index 63e3c42..5f85223 100644 (file)
@@ -472,7 +472,7 @@ public:
     EventTargetInterface eventTargetInterface() const override;
     ScriptExecutionContext* scriptExecutionContext() const final; // Implemented in Document.h
 
-    WEBCORE_EXPORT bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
+    bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
     bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&) override;
 
     using EventTarget::dispatchEvent;
index f4bc72b..c83ea39 100644 (file)
@@ -48,7 +48,7 @@ public:
     virtual ~HTMLLinkElement();
 
     URL href() const;
-    WEBCORE_EXPORT const AtomString& rel() const;
+    const AtomString& rel() const;
 
     String target() const final;
 
index d23a92d..715c6f9 100644 (file)
@@ -68,8 +68,6 @@
 #include "Editor.h"
 #include "Element.h"
 #include "EventHandler.h"
-#include "EventListener.h"
-#include "EventNames.h"
 #include "ExtendableEvent.h"
 #include "ExtensionStyleSheets.h"
 #include "FetchResponse.h"
@@ -5146,10 +5144,4 @@ Internals::TextIndicatorInfo Internals::textIndicatorForRange(const Range& range
     return indicator->data();
 }
 
-void Internals::addPrefetchLoadEventListener(HTMLLinkElement& link, RefPtr<EventListener>&& listener)
-{
-    if (RuntimeEnabledFeatures::sharedFeatures().linkPrefetchEnabled() && equalLettersIgnoringASCIICase(link.rel(), "prefetch"))
-        link.addEventListener(eventNames().loadEvent, listener.releaseNonNull(), false);
-}
-
 } // namespace WebCore
index 468fb83..e7d34f6 100644 (file)
@@ -59,7 +59,6 @@ class DOMURL;
 class DOMWindow;
 class Document;
 class Element;
-class EventListener;
 class ExtendableEvent;
 class FetchResponse;
 class File;
@@ -867,8 +866,6 @@ public:
 
     TextIndicatorInfo textIndicatorForRange(const Range&, TextIndicatorOptions);
 
-    void addPrefetchLoadEventListener(HTMLLinkElement&, RefPtr<EventListener>&&);
-
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;
index aa50bcc..99787e3 100644 (file)
@@ -781,6 +781,4 @@ enum CompositingPolicy {
     void setIsPlayingToAutomotiveHeadUnit(boolean value);
 
     TextIndicatorInfo textIndicatorForRange(Range range, TextIndicatorOptions options);
-
-    void addPrefetchLoadEventListener(HTMLLinkElement link, EventListener? callback);
 };
index 965e27e..753ad9c 100644 (file)
@@ -1,3 +1,16 @@
+2019-07-25  Truitt Savell  <tsavell@apple.com>
+
+        Unreviewed, rolling out r247821.
+
+        Caused two crashing Layout Tests
+
+        Reverted changeset:
+
+        "Make storing cross-origin top-level prefetches in HTTP cache
+        optional"
+        https://bugs.webkit.org/show_bug.cgi?id=199499
+        https://trac.webkit.org/changeset/247821
+
 2019-07-25  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, fix -Wredundant-move warning spam after r247672
index 3231d80..5ca46df 100644 (file)
@@ -218,18 +218,11 @@ void NetworkResourceLoader::retrieveCacheEntry(const ResourceRequest& request)
         ASSERT(m_parameters.options.mode == FetchOptions::Mode::Navigate);
         if (auto* session = m_connection->networkProcess().networkSession(sessionID())) {
             if (auto entry = session->prefetchCache().take(request.url())) {
-                // FIXME: Deal with credentials (https://bugs.webkit.org/show_bug.cgi?id=200000)
                 if (!entry->redirectRequest.isNull()) {
-                    auto cacheEntry = m_cache->makeRedirectEntry(request, entry->response, entry->redirectRequest);
-                    loader->retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request });
                     auto maxAgeCap = validateCacheEntryForMaxAgeCapValidation(request, entry->redirectRequest, entry->response);
                     m_cache->storeRedirect(request, entry->response, entry->redirectRequest, maxAgeCap);
-                    return;
-                }
-                auto cacheEntry = m_cache->makeEntry(request, entry->response, entry->releaseBuffer());
-                loader->retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request });
-                m_cache->store(request, entry->response, entry->releaseBuffer(), nullptr);
-                return;
+                } else
+                    m_cache->store(request, entry->response, entry->releaseBuffer(), nullptr);
             }
         }
     }
@@ -246,38 +239,33 @@ void NetworkResourceLoader::retrieveCacheEntry(const ResourceRequest& request)
             loader->startNetworkLoad(WTFMove(request), FirstLoad::Yes);
             return;
         }
-        loader->retrieveCacheEntryInternal(WTFMove(entry), WTFMove(request));
-    });
-}
-
-void NetworkResourceLoader::retrieveCacheEntryInternal(std::unique_ptr<NetworkCache::Entry>&& entry, WebCore::ResourceRequest&& request)
-{
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    if (entry->hasReachedPrevalentResourceAgeCap()) {
-        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource has reached prevalent resource age cap (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-        m_cacheEntryForMaxAgeCapValidation = WTFMove(entry);
-        ResourceRequest revalidationRequest = originalRequest();
-        startNetworkLoad(WTFMove(revalidationRequest), FirstLoad::Yes);
-        return;
-    }
+        if (entry->hasReachedPrevalentResourceAgeCap()) {
+            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource has reached prevalent resource age cap (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+            m_cacheEntryForMaxAgeCapValidation = WTFMove(entry);
+            ResourceRequest revalidationRequest = originalRequest();
+            loader->startNetworkLoad(WTFMove(revalidationRequest), FirstLoad::Yes);
+            return;
+        }
 #endif
-    if (entry->redirectRequest()) {
-        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Handling redirect (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-        dispatchWillSendRequestForCacheEntry(WTFMove(request), WTFMove(entry));
-        return;
-    }
-    if (m_parameters.needsCertificateInfo && !entry->response().certificateInfo()) {
-        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource does not have required certificate (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-        startNetworkLoad(WTFMove(request), FirstLoad::Yes);
-        return;
-    }
-    if (entry->needsValidation() || request.cachePolicy() == WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData) {
-        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Validating cache entry (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-        validateCacheEntry(WTFMove(entry));
-        return;
-    }
-    RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Retrieved resource from cache (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-    didRetrieveCacheEntry(WTFMove(entry));
+        if (entry->redirectRequest()) {
+            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Handling redirect (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+            loader->dispatchWillSendRequestForCacheEntry(WTFMove(request), WTFMove(entry));
+            return;
+        }
+        if (loader->m_parameters.needsCertificateInfo && !entry->response().certificateInfo()) {
+            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource does not have required certificate (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+            loader->startNetworkLoad(WTFMove(request), FirstLoad::Yes);
+            return;
+        }
+        if (entry->needsValidation() || request.cachePolicy() == WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData) {
+            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Validating cache entry (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+            loader->validateCacheEntry(WTFMove(entry));
+            return;
+        }
+        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Retrieved resource from cache (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+        loader->didRetrieveCacheEntry(WTFMove(entry));
+    });
 }
 
 void NetworkResourceLoader::startNetworkLoad(ResourceRequest&& request, FirstLoad load)
index 1514e39..4b4ce4f 100644 (file)
@@ -129,7 +129,6 @@ private:
 
     void tryStoreAsCacheEntry();
     void retrieveCacheEntry(const WebCore::ResourceRequest&);
-    void retrieveCacheEntryInternal(std::unique_ptr<NetworkCache::Entry>&&, WebCore::ResourceRequest&&);
     void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>);
     void sendResultForCacheEntry(std::unique_ptr<NetworkCache::Entry>);
     void validateCacheEntry(std::unique_ptr<NetworkCache::Entry>);