Pick up Ad Click Attribution conversions in NetworkResourceLoader::willSendRedirected...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2019 18:19:59 +0000 (18:19 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Apr 2019 18:19:59 +0000 (18:19 +0000)
commit7043dfcc937b539280e3cccbc8d52459ff19324f
treef727380ce09f722a063b626e05beb731f4aeb69c
parent62402bbb546f8278c2e9b25bfcd9c12148dde5b4
Pick up Ad Click Attribution conversions in NetworkResourceLoader::willSendRedirectedRequest()
https://bugs.webkit.org/show_bug.cgi?id=196558
<rdar://problem/47650245>

Reviewed by Youenn Fablet.

Source/WebCore:

Tests: http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html
       http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html
       http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html

The existing API tests were expanded too.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAdClickAttribution const):
   Enhanced the use of AdClickAttribution::MaxEntropy.
* loader/AdClickAttribution.cpp:
(WebCore::AdClickAttribution::parseConversionRequest):
    New function to parse and validate URLs with a path starting with
    /.well-known/ad-click-attribution/.
(WebCore::AdClickAttribution::toString const):
    Added output for the conversion priority for testing purposes.
* loader/AdClickAttribution.h:
(WebCore::AdClickAttribution::Campaign::isValid const):
(WebCore::AdClickAttribution::Conversion::isValid const):
   Enhanced the use of AdClickAttribution::MaxEntropy.

Source/WebKit:

So called pixel requests have traditionally been used to send ad click
attribution data to click sources. The privacy implications of such
pixel requests are severe which is in part why browsers have started to
block cookies from being sent in such third-party requests.

To allow for a smooth transition to more privacy-friendly ad click
attribution, we should allow servers to make a redirect to
https://click-source.example/.well-known/ad-click-attribution/ to
trigger a so called conversion.

This patch checks for the well-known location in the path component of
the redirect URL. If the request indeed goes to the well-known location,
we parse the conversion data and send it to the storage in the network
session.

* NetworkProcess/NetworkAdClickAttribution.cpp:
(WebKit::NetworkAdClickAttribution::convert):
    Reporting function.
* NetworkProcess/NetworkAdClickAttribution.h:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::willSendRedirectedRequest):
    Now checks for the well-known location through a call to
    WebCore::AdClickAttribution::parseConversionRequest().
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::convertAdClickAttribution):
    Piping to WebKit::NetworkAdClickAttribution::convert().
* NetworkProcess/NetworkSession.h:

Tools:

* TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp:
(TestWebKitAPI::TEST):
    Added tests of WebCore::AdClickAttribution::parseConversionRequest().

LayoutTests:

* http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt:
   Enhanced the use of AdClickAttribution::MaxEntropy.
* http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect-expected.txt: Added.
* http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html: Added.
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority-expected.txt: Added.
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html: Added.
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority-expected.txt: Added.
* http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html: Added.
* http/tests/adClickAttribution/resources/redirectToConversion.php: Added.
* http/tests/adClickAttribution/resources/redirectToConversionOnIPAddress.php: Added.
* platform/ios-wk2/http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt:
   Enhanced the use of AdClickAttribution::MaxEntropy.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244086 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-cross-site-image-redirect.html [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-with-priority.html [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/attribution-conversion-through-image-redirect-without-priority.html [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/resources/redirectToConversion.php [new file with mode: 0644]
LayoutTests/http/tests/adClickAttribution/resources/redirectToConversionOnIPAddress.php [new file with mode: 0644]
LayoutTests/platform/ios-wk2/http/tests/adClickAttribution/anchor-tag-attributes-validation-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/loader/AdClickAttribution.cpp
Source/WebCore/loader/AdClickAttribution.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkAdClickAttribution.cpp
Source/WebKit/NetworkProcess/NetworkAdClickAttribution.h
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/NetworkProcess/NetworkSession.cpp
Source/WebKit/NetworkProcess/NetworkSession.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp