Title: [233269] trunk
Revision
233269
Author
[email protected]
Date
2018-06-27 11:23:06 -0700 (Wed, 27 Jun 2018)

Log Message

Disable content blockers in NetworkLoadChecker except for ping loads
https://bugs.webkit.org/show_bug.cgi?id=187083
<rdar://problem/41440083>

Reviewed by Chris Dumez.

Source/WebCore:

Add internals API to reload a frame without content extensions.

Test: http/tests/contentextensions/reload-without-contentextensions.html

* testing/Internals.cpp:
(WebCore::Internals::reloadWithoutContentExtensions):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

* NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::processContentExtensionRulesForLoad):
* NetworkProcess/NetworkLoadChecker.h:
(WebKit::NetworkLoadChecker::enableContentExtensionsCheck):
* NetworkProcess/PingLoad.cpp:

LayoutTests:

* http/tests/contentextensions/reload-without-contentextensions-expected.txt: Added.
* http/tests/contentextensions/reload-without-contentextensions.html: Added.
* http/tests/contentextensions/reload-without-contentextensions.html.json: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233268 => 233269)


--- trunk/LayoutTests/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/LayoutTests/ChangeLog	2018-06-27 18:23:06 UTC (rev 233269)
@@ -1,3 +1,15 @@
+2018-06-27  Youenn Fablet  <[email protected]>
+
+        Disable content blockers in NetworkLoadChecker except for ping loads
+        https://bugs.webkit.org/show_bug.cgi?id=187083
+        <rdar://problem/41440083>
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/contentextensions/reload-without-contentextensions-expected.txt: Added.
+        * http/tests/contentextensions/reload-without-contentextensions.html: Added.
+        * http/tests/contentextensions/reload-without-contentextensions.html.json: Added.
+
 2018-06-27  Simon Fraser  <[email protected]>
 
         https://hackernoon.com/ uses lots of layer backing store

Added: trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions-expected.txt (0 => 233269)


--- trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions-expected.txt	2018-06-27 18:23:06 UTC (rev 233269)
@@ -0,0 +1,2 @@
+CONSOLE MESSAGE: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/reload-without-contentextensions.html from loading a resource from http://localhost:8000/resources/square128.png
+PASS

Added: trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions.html (0 => 233269)


--- trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions.html	2018-06-27 18:23:06 UTC (rev 233269)
@@ -0,0 +1,39 @@
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function done(message)
+{
+    document.body.innerHTML = message;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+if (!window.internals)
+    done("FAIL: need internals API");
+
+async function doTest(shouldFail)
+{
+    const result = await fetch("resources/subresource-redirect.php", { mode : "no-cors" }).then(() => {
+        return !shouldFail;
+    }, () => {
+        return shouldFail;
+    });
+    if (!result) {
+        done("FAIL: reloaded = " + localStorage.reloaded);
+        return;
+    }
+    if (!!localStorage.reloaded) {
+        done("PASS");
+        return;
+    }
+    localStorage.reloaded = true;
+    internals.reloadWithoutContentExtensions();
+}
+
+doTest(!localStorage.reloaded);
+</script>
+</body>

Added: trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions.html.json (0 => 233269)


--- trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions.html.json	                        (rev 0)
+++ trunk/LayoutTests/http/tests/contentextensions/reload-without-contentextensions.html.json	2018-06-27 18:23:06 UTC (rev 233269)
@@ -0,0 +1,10 @@
+[
+    {
+        "action": {
+            "type": "block"
+        },
+        "trigger": {
+            "url-filter": ".*square"
+        }
+    }
+]

Modified: trunk/Source/WebCore/ChangeLog (233268 => 233269)


--- trunk/Source/WebCore/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebCore/ChangeLog	2018-06-27 18:23:06 UTC (rev 233269)
@@ -1,3 +1,20 @@
+2018-06-27  Youenn Fablet  <[email protected]>
+
+        Disable content blockers in NetworkLoadChecker except for ping loads
+        https://bugs.webkit.org/show_bug.cgi?id=187083
+        <rdar://problem/41440083>
+
+        Reviewed by Chris Dumez.
+
+        Add internals API to reload a frame without content extensions.
+
+        Test: http/tests/contentextensions/reload-without-contentextensions.html
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::reloadWithoutContentExtensions):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-06-27  Simon Fraser  <[email protected]>
 
         https://hackernoon.com/ uses lots of layer backing store

Modified: trunk/Source/WebCore/testing/Internals.cpp (233268 => 233269)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-06-27 18:23:06 UTC (rev 233269)
@@ -4608,5 +4608,11 @@
     builder.append(']');
     return builder.toString();
 }
+
+void Internals::reloadWithoutContentExtensions()
+{
+    if (auto* frame = this->frame())
+        frame->loader().reload(ReloadOption::DisableContentBlockers);
+}
     
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.h (233268 => 233269)


--- trunk/Source/WebCore/testing/Internals.h	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebCore/testing/Internals.h	2018-06-27 18:23:06 UTC (rev 233269)
@@ -705,6 +705,8 @@
     void setCaptureExtraNetworkLoadMetricsEnabled(bool);
     String ongoingLoadsDescriptions() const;
 
+    void reloadWithoutContentExtensions();
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (233268 => 233269)


--- trunk/Source/WebCore/testing/Internals.idl	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebCore/testing/Internals.idl	2018-06-27 18:23:06 UTC (rev 233269)
@@ -638,4 +638,6 @@
 
     DOMString ongoingLoadsDescriptions();
     void setCaptureExtraNetworkLoadMetricsEnabled(boolean value);
+
+    void reloadWithoutContentExtensions();
 };

Modified: trunk/Source/WebKit/ChangeLog (233268 => 233269)


--- trunk/Source/WebKit/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebKit/ChangeLog	2018-06-27 18:23:06 UTC (rev 233269)
@@ -1,3 +1,17 @@
+2018-06-27  Youenn Fablet  <[email protected]>
+
+        Disable content blockers in NetworkLoadChecker except for ping loads
+        https://bugs.webkit.org/show_bug.cgi?id=187083
+        <rdar://problem/41440083>
+
+        Reviewed by Chris Dumez.
+
+        * NetworkProcess/NetworkLoadChecker.cpp:
+        (WebKit::NetworkLoadChecker::processContentExtensionRulesForLoad):
+        * NetworkProcess/NetworkLoadChecker.h:
+        (WebKit::NetworkLoadChecker::enableContentExtensionsCheck):
+        * NetworkProcess/PingLoad.cpp:
+
 2018-06-27  Simon Fraser  <[email protected]>
 
         https://hackernoon.com/ uses lots of layer backing store

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp (233268 => 233269)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp	2018-06-27 18:23:06 UTC (rev 233269)
@@ -384,7 +384,7 @@
 void NetworkLoadChecker::processContentExtensionRulesForLoad(ResourceRequest&& request, ContentExtensionCallback&& callback)
 {
     // FIXME: Enable content blockers for navigation loads.
-    if (!m_userContentControllerIdentifier || m_options.mode == FetchOptions::Mode::Navigate) {
+    if (!m_checkContentExtensions || !m_userContentControllerIdentifier || m_options.mode == FetchOptions::Mode::Navigate) {
         ContentExtensions::BlockedStatus status;
         callback(ContentExtensionResult { WTFMove(request), status });
         return;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h (233268 => 233269)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h	2018-06-27 18:23:06 UTC (rev 233269)
@@ -72,6 +72,8 @@
     WebCore::NetworkLoadInformation takeNetworkLoadInformation() { return WTFMove(m_loadInformation); }
     void storeRedirectionIfNeeded(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
 
+    void enableContentExtensionsCheck() { m_checkContentExtensions = true; }
+
 private:
     WebCore::ContentSecurityPolicy* contentSecurityPolicy();
     bool isChecking() const { return !!m_corsPreflightChecker; }
@@ -133,6 +135,7 @@
     WebCore::PreflightPolicy m_preflightPolicy;
     String m_dntHeaderValue;
     String m_referrer;
+    bool m_checkContentExtensions { false };
     bool m_shouldCaptureExtraNetworkLoadMetrics { false };
     WebCore::NetworkLoadInformation m_loadInformation;
 };

Modified: trunk/Source/WebKit/NetworkProcess/PingLoad.cpp (233268 => 233269)


--- trunk/Source/WebKit/NetworkProcess/PingLoad.cpp	2018-06-27 18:22:06 UTC (rev 233268)
+++ trunk/Source/WebKit/NetworkProcess/PingLoad.cpp	2018-06-27 18:23:06 UTC (rev 233269)
@@ -44,7 +44,7 @@
     , m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)
     , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(connection, m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier, FetchOptions { m_parameters.options}, m_parameters.sessionID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
 {
-
+    m_networkLoadChecker->enableContentExtensionsCheck();
     if (m_parameters.cspResponseHeaders)
         m_networkLoadChecker->setCSPResponseHeaders(WTFMove(m_parameters.cspResponseHeaders.value()));
 #if ENABLE(CONTENT_EXTENSIONS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to