[Beacon] Content extensions should be able to intercept Beacon / Ping redirects
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 01:32:24 +0000 (01:32 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 01:32:24 +0000 (01:32 +0000)
commit4920b152e23639c13d55d6d5f5003d23c27177f3
tree219895f67f62046068d3c84694539ee135be94cb
parentb520f8139a112873125f3386b6470d5733f765bf
[Beacon] Content extensions should be able to intercept Beacon / Ping redirects
https://bugs.webkit.org/show_bug.cgi?id=175746
<rdar://problem/33946050>

Reviewed by Alex Christensen.

Source/WebCore:

Update PingLoad to process content extension rules upon redirect. This allows content
extensions to block and upgrade to HTTPS beacon / ping loads.

Because ping loads can outlive the WebProcess, the content extensions rules are passed
to the NetworkProcess when starting the Ping load. The PingLoad can then consult those
rules upon redirect, on the NetworkProcess side.

Tests: http/wpt/beacon/contentextensions/beacon-blocked.html
       http/wpt/beacon/contentextensions/beacon-redirect-blocked.html

* contentextensions/ContentExtensionActions.h:
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::forEach):
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentExtensionRulesForPingLoad):
* contentextensions/ContentExtensionsBackend.h:
* page/Page.h:
* page/UserContentProvider.cpp:
(WebCore::UserContentProvider::forEachContentExtension):
* page/UserContentProvider.h:

Source/WebKit:

Update PingLoad to process content extension rules upon redirect. This allows content
extensions to block and upgrade to HTTPS beacon / ping loads.

Because ping loads can outlive the WebProcess, the content extensions rules are passed
to the NetworkProcess when starting the Ping load. The PingLoad can then consult those
rules upon redirect, on the NetworkProcess side.

* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):
* NetworkProcess/NetworkResourceLoadParameters.h:
* NetworkProcess/PingLoad.cpp:
(WebKit::PingLoad::willPerformHTTPRedirection):
(WebKit::PingLoad::contentExtensionsBackend):
(WebKit::PingLoad::processContentExtensionRulesForLoad):
* NetworkProcess/PingLoad.h:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::startPingLoad):

LayoutTests:

Add layout test coverage for blocking beacon loads via content extensions.

* http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt:
* http/wpt/beacon/connect-src-beacon-redirect-blocked.sub.html:
* http/wpt/beacon/contentextensions/beacon-blocked-expected.txt: Added.
* http/wpt/beacon/contentextensions/beacon-blocked.html: Added.
* http/wpt/beacon/contentextensions/beacon-blocked.html.json: Added.
* http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt: Added.
* http/wpt/beacon/contentextensions/beacon-redirect-blocked.html: Added.
* http/wpt/beacon/contentextensions/beacon-redirect-blocked.html.json: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/beacon/connect-src-beacon-redirect-blocked.sub-expected.txt
LayoutTests/http/wpt/beacon/connect-src-beacon-redirect-blocked.sub.html
LayoutTests/http/wpt/beacon/contentextensions/beacon-blocked-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/beacon/contentextensions/beacon-blocked.html [new file with mode: 0644]
LayoutTests/http/wpt/beacon/contentextensions/beacon-blocked.html.json [new file with mode: 0644]
LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked.html [new file with mode: 0644]
LayoutTests/http/wpt/beacon/contentextensions/beacon-redirect-blocked.html.json [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/contentextensions/ContentExtensionActions.h
Source/WebCore/contentextensions/ContentExtensionsBackend.cpp
Source/WebCore/contentextensions/ContentExtensionsBackend.h
Source/WebCore/page/Page.h
Source/WebCore/page/UserContentProvider.cpp
Source/WebCore/page/UserContentProvider.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h
Source/WebKit/NetworkProcess/PingLoad.cpp
Source/WebKit/NetworkProcess/PingLoad.h
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp