Changeset 273133 in webkit


Ignore:
Timestamp:
Feb 19, 2021 1:10:16 AM (3 years ago)
Author:
jiewen_tan@apple.com
Message:

PCM: Request server public key to generate secret token
https://bugs.webkit.org/show_bug.cgi?id=222141
<rdar://problem/74462955>

Reviewed by John Wilander.

Source/WebCore:

This patch adds a way for PCM fraud prevention to request the server public key
which will be then used to generate the unlinkable token.

Covered by existing tests.

  • loader/PrivateClickMeasurement.cpp:

(WebCore::PrivateClickMeasurement::tokenPublicKeyURL const):

  • loader/PrivateClickMeasurement.h:

Adds new well-known ULR for this purpose.

Source/WebKit:

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::setPrivateClickMeasurementTokenPublicKeyURLForTesting):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::setPrivateClickMeasurementTokenPublicKeyURLForTesting):

  • NetworkProcess/NetworkSession.h:

Paperwork to add a way to set test URL.

  • NetworkProcess/PrivateClickMeasurementManager.cpp:

(WebKit::PrivateClickMeasurementManager::storeUnattributed):
(WebKit::generateNetworkResourceLoadParameters):
(WebKit::generateNetworkResourceLoadParametersForPost):
(WebKit::generateNetworkResourceLoadParametersForGet):
(WebKit::PrivateClickMeasurementManager::getTokenPublicKey):
(WebKit::PrivateClickMeasurementManager::getSignedUnlinkableToken):
(WebKit::PrivateClickMeasurementManager::fireConversionRequest):
(WebKit::PrivateClickMeasurementManager::setTokenPublicKeyURLForTesting):

  • NetworkProcess/PrivateClickMeasurementManager.h:

Teaches the PCMM to send the token public key request.

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting):

  • UIProcess/API/C/WKPagePrivate.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::simulateResourceLoadStatisticsSessionRestart):
(WebKit::WebPageProxy::setPrivateClickMeasurementTokenPublicKeyURLForTesting):

  • UIProcess/WebPageProxy.h:

Paperwork to add a way to set test URL.

Tools:

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setPrivateClickMeasurementTokenPublicKeyURLForTesting):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::setPrivateClickMeasurementTokenPublicKeyURLForTesting):

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
Paperwork to add a way to set test URL.

LayoutTests:

  • http/tests/privateClickMeasurement/resources/getTokenSigningData.php:
  • http/tests/privateClickMeasurement/resources/signToken.php:
  • http/tests/privateClickMeasurement/resources/util.js:

(tearDownAndFinish):

  • http/tests/privateClickMeasurement/store-private-click-measurement-with-source-nonce-expected.txt:
  • http/tests/privateClickMeasurement/store-private-click-measurement-with-source-nonce.html:

This patch modifies the above tests to be able to record two consecutive server requests.

Location:
trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273132 r273133  
     12021-02-19  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        PCM: Request server public key to generate secret token
     4        https://bugs.webkit.org/show_bug.cgi?id=222141
     5        <rdar://problem/74462955>
     6
     7        Reviewed by John Wilander.
     8
     9        * http/tests/privateClickMeasurement/resources/getTokenSigningData.php:
     10        * http/tests/privateClickMeasurement/resources/signToken.php:
     11        * http/tests/privateClickMeasurement/resources/util.js:
     12        (tearDownAndFinish):
     13        * http/tests/privateClickMeasurement/store-private-click-measurement-with-source-nonce-expected.txt:
     14        * http/tests/privateClickMeasurement/store-private-click-measurement-with-source-nonce.html:
     15        This patch modifies the above tests to be able to record two consecutive server requests.
     16
    1172021-02-19  Imanol Fernandez  <ifernandez@igalia.com> and Sergio Villar Senin  <svillar@igalia.com>
    218
  • trunk/LayoutTests/http/tests/privateClickMeasurement/resources/getTokenSigningData.php

    r273088 r273133  
    4545    echo "if (window.testRunner) {";
    4646    echo "    testRunner.setPrivateClickMeasurementOverrideTimerForTesting(false);";
     47    echo "    testRunner.setPrivateClickMeasurementTokenPublicKeyURLForTesting('');";
    4748    echo "    testRunner.setPrivateClickMeasurementTokenSignatureURLForTesting('');";
    4849    echo "    testRunner.notifyDone();";
  • trunk/LayoutTests/http/tests/privateClickMeasurement/resources/signToken.php

    r273088 r273133  
    22require_once "tokenSigningFilePath.php";
    33
    4 $tokenSigningFile = fopen($tokenSigningFilePath . ".tmp", 'w');
     4$tokenSigningFile = fopen($tokenSigningFilePath . ".tmp", 'a');
    55$httpHeaders = $_SERVER;
    66$cookiesFound = false;
     7// This php will respond to two consecutive server requests.
     8// It will only complete the transaction when the second request finishes.
     9$isSecondRequest = false;
     10
     11if ($value = $httpHeaders["REQUEST_METHOD"]) {
     12    fwrite($tokenSigningFile, "REQUEST_METHOD: $value\n");
     13}
    714
    815if ($value = $httpHeaders["HTTP_HOST"]) {
     
    2734        $outputURL = substr($value, 0, $positionOfDummy);
    2835    fwrite($tokenSigningFile, "REQUEST_URI: $outputURL\n");
     36
     37    $positionOfDummy = strpos($value, "&second=");
     38    if ($positionOfDummy != false)
     39        $isSecondRequest = true;
    2940}
    3041
     
    3748
    3849fclose($tokenSigningFile);
    39 rename($tokenSigningFilePath . ".tmp", $tokenSigningFilePath);
     50// Complete the transaction.
     51if ($isSecondRequest)
     52    rename($tokenSigningFilePath . ".tmp", $tokenSigningFilePath);
    4053
    4154header("HTTP/1.1 201 Created");
  • trunk/LayoutTests/http/tests/privateClickMeasurement/resources/util.js

    r273088 r273133  
    1414        testRunner.setPrivateClickMeasurementAttributionReportURLForTesting("");
    1515        testRunner.setPrivateClickMeasurementTokenSignatureURLForTesting("");
     16        testRunner.setPrivateClickMeasurementTokenPublicKeyURLForTesting("");
    1617        testRunner.notifyDone();
    1718    }
  • trunk/LayoutTests/http/tests/privateClickMeasurement/store-private-click-measurement-with-source-nonce-expected.txt

    r273088 r273133  
    77--------
    88Token signing request received.
     9REQUEST_METHOD: GET
     10HTTP_HOST: 127.0.0.1:8000
     11REQUEST_URI: /privateClickMeasurement/resources/signToken.php
     12No cookies in token signing request.
     13Request body:
     14
     15REQUEST_METHOD: POST
    916HTTP_HOST: 127.0.0.1:8000
    1017Content type: application/json
  • trunk/LayoutTests/http/tests/privateClickMeasurement/store-private-click-measurement-with-source-nonce.html

    r273088 r273133  
    5151                const highEntropyBits = currentTimeMillis - (Math.floor(currentTimeMillis / 1000000) * 1000000);
    5252                const dummy = highEntropyBits + "" + Math.floor(Math.random() * 100);
    53                 testRunner.setPrivateClickMeasurementTokenSignatureURLForTesting("http://127.0.0.1:8000/privateClickMeasurement/resources/signToken.php?dummy=" + dummy);
     53                testRunner.setPrivateClickMeasurementTokenPublicKeyURLForTesting("http://127.0.0.1:8000/privateClickMeasurement/resources/signToken.php?dummy=" + dummy);
     54                testRunner.setPrivateClickMeasurementTokenSignatureURLForTesting("http://127.0.0.1:8000/privateClickMeasurement/resources/signToken.php?dummy=" + dummy + "&second=true");
    5455                targetLink.href = "http://localhost:8000/privateClickMeasurement/store-private-click-measurement-with-source-nonce.html?dummy=" + dummy;
    5556                activateElement("targetLink");
  • trunk/Source/WebCore/ChangeLog

    r273132 r273133  
     12021-02-19  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        PCM: Request server public key to generate secret token
     4        https://bugs.webkit.org/show_bug.cgi?id=222141
     5        <rdar://problem/74462955>
     6
     7        Reviewed by John Wilander.
     8
     9        This patch adds a way for PCM fraud prevention to request the server public key
     10        which will be then used to generate the unlinkable token.
     11
     12        Covered by existing tests.
     13
     14        * loader/PrivateClickMeasurement.cpp:
     15        (WebCore::PrivateClickMeasurement::tokenPublicKeyURL const):
     16        * loader/PrivateClickMeasurement.h:
     17        Adds new well-known ULR for this purpose.
     18
    1192021-02-19  Imanol Fernandez  <ifernandez@igalia.com> and Sergio Villar Senin  <svillar@igalia.com>
    220
  • trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp

    r273088 r273133  
    3939static const char privateClickMeasurementTriggerAttributionPath[] = "/.well-known/private-click-measurement/trigger-attribution/";
    4040static const char privateClickMeasurementTokenSignaturePath[] = "/.well-known/private-click-measurement/sign-unlinkable-token/";
     41static const char privateClickMeasurementTokenPublicKeyPath[] = "/.well-known/private-click-measurement/get-unlinkable-token-public-key/";
    4142static const char privateClickMeasurementReportAttributionPath[] = "/.well-known/private-click-measurement/report-attribution/";
    4243const size_t privateClickMeasurementAttributionTriggerDataPathSegmentSize = 2;
     
    133134}
    134135
     136URL PrivateClickMeasurement::tokenPublicKeyURL() const
     137{
     138    StringBuilder builder;
     139    builder.appendLiteral("https://");
     140    builder.append(m_sourceSite.registrableDomain.string());
     141    builder.appendLiteral(privateClickMeasurementTokenPublicKeyPath);
     142
     143    URL url { URL(), builder.toString() };
     144    if (url.isValid())
     145        return url;
     146
     147    return URL();
     148}
     149
    135150Ref<JSON::Object> PrivateClickMeasurement::tokenSignatureJSON() const
    136151{
  • trunk/Source/WebCore/loader/PrivateClickMeasurement.h

    r273088 r273133  
    278278    WEBCORE_EXPORT Optional<Seconds> attributeAndGetEarliestTimeToSend(AttributionTriggerData&&);
    279279    WEBCORE_EXPORT bool hasHigherPriorityThan(const PrivateClickMeasurement&) const;
     280    WEBCORE_EXPORT URL tokenPublicKeyURL() const;
    280281    WEBCORE_EXPORT URL tokenSignatureURL() const;
    281282    WEBCORE_EXPORT Ref<JSON::Object> tokenSignatureJSON() const;
  • trunk/Source/WebKit/ChangeLog

    r273131 r273133  
     12021-02-19  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        PCM: Request server public key to generate secret token
     4        https://bugs.webkit.org/show_bug.cgi?id=222141
     5        <rdar://problem/74462955>
     6
     7        Reviewed by John Wilander.
     8
     9        * NetworkProcess/NetworkProcess.cpp:
     10        (WebKit::NetworkProcess::setPrivateClickMeasurementTokenPublicKeyURLForTesting):
     11        * NetworkProcess/NetworkProcess.h:
     12        * NetworkProcess/NetworkProcess.messages.in:
     13        * NetworkProcess/NetworkSession.cpp:
     14        (WebKit::NetworkSession::setPrivateClickMeasurementTokenPublicKeyURLForTesting):
     15        * NetworkProcess/NetworkSession.h:
     16        Paperwork to add a way to set test URL.
     17
     18        * NetworkProcess/PrivateClickMeasurementManager.cpp:
     19        (WebKit::PrivateClickMeasurementManager::storeUnattributed):
     20        (WebKit::generateNetworkResourceLoadParameters):
     21        (WebKit::generateNetworkResourceLoadParametersForPost):
     22        (WebKit::generateNetworkResourceLoadParametersForGet):
     23        (WebKit::PrivateClickMeasurementManager::getTokenPublicKey):
     24        (WebKit::PrivateClickMeasurementManager::getSignedUnlinkableToken):
     25        (WebKit::PrivateClickMeasurementManager::fireConversionRequest):
     26        (WebKit::PrivateClickMeasurementManager::setTokenPublicKeyURLForTesting):
     27        * NetworkProcess/PrivateClickMeasurementManager.h:
     28        Teaches the PCMM to send the token public key request.
     29
     30        * UIProcess/API/C/WKPage.cpp:
     31        (WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting):
     32        * UIProcess/API/C/WKPagePrivate.h:
     33        * UIProcess/WebPageProxy.cpp:
     34        (WebKit::WebPageProxy::simulateResourceLoadStatisticsSessionRestart):
     35        (WebKit::WebPageProxy::setPrivateClickMeasurementTokenPublicKeyURLForTesting):
     36        * UIProcess/WebPageProxy.h:
     37        Paperwork to add a way to set test URL.
     38
    1392021-02-19  Michael Catanzaro  <mcatanzaro@gnome.org>
    240
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r273102 r273133  
    26092609}
    26102610
     2611void NetworkProcess::setPrivateClickMeasurementTokenPublicKeyURLForTesting(PAL::SessionID sessionID, URL&& url, CompletionHandler<void()>&& completionHandler)
     2612{
     2613    if (auto* session = networkSession(sessionID))
     2614        session->setPrivateClickMeasurementTokenPublicKeyURLForTesting(WTFMove(url));
     2615
     2616    completionHandler();
     2617}
     2618
    26112619void NetworkProcess::setPrivateClickMeasurementTokenSignatureURLForTesting(PAL::SessionID sessionID, URL&& url, CompletionHandler<void()>&& completionHandler)
    26122620{
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r273102 r273133  
    343343    void markAttributedPrivateClickMeasurementsAsExpiredForTesting(PAL::SessionID, CompletionHandler<void()>&&);
    344344    void simulateResourceLoadStatisticsSessionRestart(PAL::SessionID, CompletionHandler<void()>&&);
     345    void setPrivateClickMeasurementTokenPublicKeyURLForTesting(PAL::SessionID, URL&&, CompletionHandler<void()>&&);
    345346    void setPrivateClickMeasurementTokenSignatureURLForTesting(PAL::SessionID, URL&&, CompletionHandler<void()>&&);
    346347    void setPrivateClickMeasurementAttributionReportURLForTesting(PAL::SessionID, URL&&, CompletionHandler<void()>&&);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r273102 r273133  
    168168    MarkAttributedPrivateClickMeasurementsAsExpiredForTesting(PAL::SessionID sessionID) -> () Async
    169169    SimulateResourceLoadStatisticsSessionRestart(PAL::SessionID sessionID) -> () Async
     170    SetPrivateClickMeasurementTokenPublicKeyURLForTesting(PAL::SessionID sessionID, URL url) -> () Async
    170171    SetPrivateClickMeasurementTokenSignatureURLForTesting(PAL::SessionID sessionID, URL url) -> () Async
    171172    SetPrivateClickMeasurementAttributionReportURLForTesting(PAL::SessionID sessionID, URL url) -> () Async
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r273088 r273133  
    339339}
    340340
     341void NetworkSession::setPrivateClickMeasurementTokenPublicKeyURLForTesting(URL&& url)
     342{
     343    privateClickMeasurement().setTokenPublicKeyURLForTesting(WTFMove(url));
     344}
     345
    341346void NetworkSession::setPrivateClickMeasurementTokenSignatureURLForTesting(URL&& url)
    342347{
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r273088 r273133  
    124124    void setPrivateClickMeasurementOverrideTimerForTesting(bool value);
    125125    void markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&&);
     126    void setPrivateClickMeasurementTokenPublicKeyURLForTesting(URL&&);
    126127    void setPrivateClickMeasurementTokenSignatureURLForTesting(URL&&);
    127128    void setPrivateClickMeasurementAttributionReportURLForTesting(URL&&);
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp

    r273088 r273133  
    7575    clearExpired();
    7676
    77     if (attribution.ephemeralSourceNonce())
    78         getSignedUnlinkableToken(attribution);
     77    if (attribution.ephemeralSourceNonce()) {
     78        auto attributionCopy = attribution;
     79        getTokenPublicKey(WTFMove(attributionCopy));
     80    }
    7981
    8082    m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] Storing an ad click."_s);
     
    8688}
    8789
    88 static NetworkResourceLoadParameters generateNetworkResourceLoadParameters(URL&& url, Ref<JSON::Object> jsonPayload, PrivateClickMeasurement::PcmDataCarried dataTypeCarried)
     90static NetworkResourceLoadParameters generateNetworkResourceLoadParameters(URL&& url, const String& httpMethod, RefPtr<JSON::Object>&& jsonPayload, PrivateClickMeasurement::PcmDataCarried dataTypeCarried)
    8991{
    9092    static uint64_t identifier = 0;
    9193   
    9294    ResourceRequest request { WTFMove(url) };
    93     request.setHTTPMethod("POST"_s);
     95    request.setHTTPMethod(httpMethod);
    9496    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, WebCore::HTTPHeaderValues::maxAge0());
    95     request.setHTTPContentType(WebCore::HTTPHeaderValues::applicationJSONContentType());
    96     request.setHTTPBody(WebCore::FormData::create(jsonPayload->toJSONString().utf8().data()));
     97    if (jsonPayload) {
     98        request.setHTTPContentType(WebCore::HTTPHeaderValues::applicationJSONContentType());
     99        request.setHTTPBody(WebCore::FormData::create(jsonPayload->toJSONString().utf8().data()));
     100    }
    97101
    98102    FetchOptions options;
     
    113117}
    114118
    115 void PrivateClickMeasurementManager::getSignedUnlinkableToken(const PrivateClickMeasurement& attribution)
    116 {
    117     if (!featureEnabled())
    118         return;
    119 
     119static NetworkResourceLoadParameters generateNetworkResourceLoadParametersForHttpPost(URL&& url, Ref<JSON::Object>&& jsonPayload, PrivateClickMeasurement::PcmDataCarried dataTypeCarried)
     120{
     121    return generateNetworkResourceLoadParameters(WTFMove(url), "POST"_s, WTFMove(jsonPayload), dataTypeCarried);
     122}
     123
     124static NetworkResourceLoadParameters generateNetworkResourceLoadParametersForHttpGet(URL&& url, PrivateClickMeasurement::PcmDataCarried dataTypeCarried)
     125{
     126    return generateNetworkResourceLoadParameters(WTFMove(url), "GET"_s, nullptr, dataTypeCarried);
     127}
     128
     129void PrivateClickMeasurementManager::getTokenPublicKey(PrivateClickMeasurement&& attribution)
     130{
     131    if (!featureEnabled())
     132        return;
     133
     134    // This is guaranteed to be close in time to the navigational click which makes it likely to be personally identifiable.
     135    auto tokenPublicKeyURL = attribution.tokenPublicKeyURL();
     136    auto pcmDataCarried = PrivateClickMeasurement::PcmDataCarried::PersonallyIdentifiable;
     137    if (m_tokenPublicKeyURLForTesting) {
     138        tokenPublicKeyURL = *m_tokenPublicKeyURLForTesting;
     139        pcmDataCarried = PrivateClickMeasurement::PcmDataCarried::NonPersonallyIdentifiable;
     140    }
     141
     142    if (tokenPublicKeyURL.isEmpty() || !tokenPublicKeyURL.isValid())
     143        return;
     144
     145    auto loadParameters = generateNetworkResourceLoadParametersForHttpGet(WTFMove(tokenPublicKeyURL), pcmDataCarried);
     146
     147    RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire a unlinkable token public key request.");
     148    m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] About to fire a unlinkable token public key request."_s);
     149
     150    m_pingLoadFunction(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), attribution = WTFMove(attribution), this] (const WebCore::ResourceError& error, const WebCore::ResourceResponse& response) mutable {
     151        if (!weakThis)
     152            return;
     153
     154        if (!error.isNull()) {
     155            m_networkProcess->broadcastConsoleMessage(weakThis->m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for unlinkable token public key request."_s));
     156            return;
     157        }
     158
     159        // FIXME: Receive and extra the server public key, rdar://73582032.
     160        getSignedUnlinkableToken(WTFMove(attribution));
     161    });
     162
     163}
     164
     165void PrivateClickMeasurementManager::getSignedUnlinkableToken(PrivateClickMeasurement&& attribution)
     166{
     167    if (!featureEnabled())
     168        return;
     169
     170    // This is guaranteed to be close in time to the navigational click which makes it likely to be personally identifiable.
    120171    auto tokenSignatureURL = attribution.tokenSignatureURL();
    121172    auto pcmDataCarried = PrivateClickMeasurement::PcmDataCarried::PersonallyIdentifiable;
     
    128179        return;
    129180
    130     auto loadParameters = generateNetworkResourceLoadParameters(WTFMove(tokenSignatureURL), attribution.tokenSignatureJSON(), pcmDataCarried);
     181    auto loadParameters = generateNetworkResourceLoadParametersForHttpPost(WTFMove(tokenSignatureURL), attribution.tokenSignatureJSON(), pcmDataCarried);
    131182
    132183    RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire a unlinkable token signing request.");
     
    208259        return;
    209260
    210     auto loadParameters = generateNetworkResourceLoadParameters(WTFMove(attributionURL), attribution.attributionReportJSON(), PrivateClickMeasurement::PcmDataCarried::NonPersonallyIdentifiable);
     261    auto loadParameters = generateNetworkResourceLoadParametersForHttpPost(WTFMove(attributionURL), attribution.attributionReportJSON(), PrivateClickMeasurement::PcmDataCarried::NonPersonallyIdentifiable);
    211262
    212263    RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire an attribution request.");
     
    337388}
    338389
     390void PrivateClickMeasurementManager::setTokenPublicKeyURLForTesting(URL&& testURL)
     391{
     392    if (testURL.isEmpty())
     393        return;
     394    m_tokenPublicKeyURLForTesting = WTFMove(testURL);
     395}
     396
    339397void PrivateClickMeasurementManager::setTokenSignatureURLForTesting(URL&& testURL)
    340398{
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h

    r273088 r273133  
    6262    void setPingLoadFunction(Function<void(NetworkResourceLoadParameters&&, CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&)>&&)>&& pingLoadFunction) { m_pingLoadFunction = WTFMove(pingLoadFunction); }
    6363    void setOverrideTimerForTesting(bool value) { m_isRunningTest = value; }
     64    void setTokenPublicKeyURLForTesting(URL&&);
    6465    void setTokenSignatureURLForTesting(URL&&);
    6566    void setAttributionReportURLForTesting(URL&&);
     
    6970
    7071private:
    71     void getSignedUnlinkableToken(const PrivateClickMeasurement&);
     72    void getTokenPublicKey(PrivateClickMeasurement&&);
     73    void getSignedUnlinkableToken(PrivateClickMeasurement&&);
    7274    void clearSentAttribution(PrivateClickMeasurement&&);
    7375    void attribute(const SourceSite&, const AttributeOnSite&, AttributionTriggerData&&);
     
    8082    WebCore::Timer m_firePendingAttributionRequestsTimer;
    8183    bool m_isRunningTest { false };
     84    Optional<URL> m_tokenPublicKeyURLForTesting;
    8285    Optional<URL> m_tokenSignatureURLForTesting;
    8386    Optional<URL> m_attributionReportBaseURLForTesting;
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r273088 r273133  
    29462946}
    29472947
     2948void WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting(WKPageRef page, WKURLRef URLRef, WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTestingFunction callback, void* callbackContext)
     2949{
     2950    toImpl(page)->setPrivateClickMeasurementTokenPublicKeyURLForTesting(URL(URL(), toWTFString(URLRef)), [callbackContext, callback] () {
     2951        callback(callbackContext);
     2952    });
     2953}
     2954
    29482955void WKPageSetPrivateClickMeasurementTokenSignatureURLForTesting(WKPageRef page, WKURLRef URLRef, WKPageSetPrivateClickMeasurementTokenSignatureURLForTestingFunction callback, void* callbackContext)
    29492956{
  • trunk/Source/WebKit/UIProcess/API/C/WKPagePrivate.h

    r273088 r273133  
    180180typedef void (*WKPageSimulateResourceLoadStatisticsSessionRestartFunction)(void* functionContext);
    181181WK_EXPORT void WKPageSimulateResourceLoadStatisticsSessionRestart(WKPageRef page, WKPageSimulateResourceLoadStatisticsSessionRestartFunction callback, void* callbackContext);
     182typedef void (*WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTestingFunction)(void* functionContext);
     183WK_EXPORT void WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting(WKPageRef page, WKURLRef urlString, WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTestingFunction callback, void* callbackContext);
    182184typedef void (*WKPageSetPrivateClickMeasurementTokenSignatureURLForTestingFunction)(void* functionContext);
    183185WK_EXPORT void WKPageSetPrivateClickMeasurementTokenSignatureURLForTesting(WKPageRef page, WKURLRef urlString, WKPageSetPrivateClickMeasurementTokenSignatureURLForTestingFunction callback, void* callbackContext);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r273120 r273133  
    1002410024}
    1002510025
     10026void WebPageProxy::setPrivateClickMeasurementTokenPublicKeyURLForTesting(const URL& url, CompletionHandler<void()>&& completionHandler)
     10027{
     10028    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::SetPrivateClickMeasurementTokenPublicKeyURLForTesting(m_websiteDataStore->sessionID(), url), WTFMove(completionHandler));
     10029}
     10030
    1002610031void WebPageProxy::setPrivateClickMeasurementTokenSignatureURLForTesting(const URL& url, CompletionHandler<void()>&& completionHandler)
    1002710032{
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r273102 r273133  
    16921692    void markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&&);
    16931693    void simulateResourceLoadStatisticsSessionRestart(CompletionHandler<void()>&&);
     1694    void setPrivateClickMeasurementTokenPublicKeyURLForTesting(const URL&, CompletionHandler<void()>&&);
    16941695    void setPrivateClickMeasurementTokenSignatureURLForTesting(const URL&, CompletionHandler<void()>&&);
    16951696    void setPrivateClickMeasurementAttributionReportURLForTesting(const URL&, CompletionHandler<void()>&&);
  • trunk/Tools/ChangeLog

    r273130 r273133  
     12021-02-19  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        PCM: Request server public key to generate secret token
     4        https://bugs.webkit.org/show_bug.cgi?id=222141
     5        <rdar://problem/74462955>
     6
     7        Reviewed by John Wilander.
     8
     9        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     10        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     11        (WTR::TestRunner::setPrivateClickMeasurementTokenPublicKeyURLForTesting):
     12        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     13        * WebKitTestRunner/TestController.cpp:
     14        (WTR::TestController::setPrivateClickMeasurementTokenPublicKeyURLForTesting):
     15        * WebKitTestRunner/TestController.h:
     16        * WebKitTestRunner/TestInvocation.cpp:
     17        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     18        Paperwork to add a way to set test URL.
     19
    1202021-02-19  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r273088 r273133  
    404404    undefined markAttributedPrivateClickMeasurementsAsExpiredForTesting();
    405405    undefined simulateResourceLoadStatisticsSessionRestart();
     406    undefined setPrivateClickMeasurementTokenPublicKeyURLForTesting(DOMString url);
    406407    undefined setPrivateClickMeasurementTokenSignatureURLForTesting(DOMString url);
    407408    undefined setPrivateClickMeasurementAttributionReportURLForTesting(DOMString url);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r273088 r273133  
    20262026}
    20272027
     2028void TestRunner::setPrivateClickMeasurementTokenPublicKeyURLForTesting(JSStringRef urlString)
     2029{
     2030    postSynchronousPageMessage("SetPrivateClickMeasurementTokenPublicKeyURLForTesting",
     2031        adoptWK(WKURLCreateWithUTF8CString(toWTFString(urlString).utf8().data())));
     2032}
     2033
    20282034void TestRunner::setPrivateClickMeasurementTokenSignatureURLForTesting(JSStringRef urlString)
    20292035{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r273088 r273133  
    513513    void clearPrivateClickMeasurementsThroughWebsiteDataRemoval();
    514514    void setPrivateClickMeasurementOverrideTimerForTesting(bool value);
     515    void setPrivateClickMeasurementTokenPublicKeyURLForTesting(JSStringRef);
    515516    void setPrivateClickMeasurementTokenSignatureURLForTesting(JSStringRef);
    516517    void setPrivateClickMeasurementAttributionReportURLForTesting(JSStringRef);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r273088 r273133  
    36313631}
    36323632
     3633void TestController::setPrivateClickMeasurementTokenPublicKeyURLForTesting(WKURLRef url)
     3634{
     3635    PrivateClickMeasurementVoidCallbackContext callbackContext(*this);
     3636    WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting(m_mainWebView->page(), url, privateClickMeasurementVoidCallback, &callbackContext);
     3637    runUntil(callbackContext.done, noTimeout);
     3638}
     3639
    36333640void TestController::setPrivateClickMeasurementTokenSignatureURLForTesting(WKURLRef url)
    36343641{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r273088 r273133  
    347347    void markAttributedPrivateClickMeasurementsAsExpiredForTesting();
    348348    void simulateResourceLoadStatisticsSessionRestart();
     349    void setPrivateClickMeasurementTokenPublicKeyURLForTesting(WKURLRef);
    349350    void setPrivateClickMeasurementTokenSignatureURLForTesting(WKURLRef);
    350351    void setPrivateClickMeasurementAttributionReportURLForTesting(WKURLRef);
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r273088 r273133  
    13401340    }
    13411341
     1342    if (WKStringIsEqualToUTF8CString(messageName, "SetPrivateClickMeasurementTokenPublicKeyURLForTesting")) {
     1343        ASSERT(WKGetTypeID(messageBody) == WKURLGetTypeID());
     1344        TestController::singleton().setPrivateClickMeasurementTokenPublicKeyURLForTesting(static_cast<WKURLRef>(messageBody));
     1345        return nullptr;
     1346    }
     1347
    13421348    if (WKStringIsEqualToUTF8CString(messageName, "SetPrivateClickMeasurementTokenSignatureURLForTesting")) {
    13431349        ASSERT(WKGetTypeID(messageBody) == WKURLGetTypeID());
Note: See TracChangeset for help on using the changeset viewer.