Title: [275682] trunk
Revision
275682
Author
katherine_che...@apple.com
Date
2021-04-08 15:14:30 -0700 (Thu, 08 Apr 2021)

Log Message

Add test infrastructure for app bound request context string
https://bugs.webkit.org/show_bug.cgi?id=224311
<rdar://problem/76229003>

Reviewed by Brent Fulgham.

Source/WebKit:

The app-bound request context string is the eTLD+1 for a load and is
needed by CFNetwork. We should add testing infrastructure to make sure
the context string is being properly set.

Test: http/tests/in-app-browser-privacy/context-string-for-subframe.html

* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(contextString):
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
* Shared/NavigatingToAppBoundDomain.h:
(WebKit::AppBoundNavigationTestingData::clearAppBoundNavigationDataTesting):
(WebKit::AppBoundNavigationTestingData::updateAppBoundNavigationTestingData):
(WebKit::AppBoundNavigationTestingData::encode const):
(WebKit::AppBoundNavigationTestingData::decode):
Store the context string in the testing struct.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _appBoundNavigationDataForDomain:completionHandler:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
SPI to get the app-bound request test data for layout testing.

Tools:

Layout test infrastructure.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::appBoundRequestContextDataForDomain):
(WTR::TestRunner::callDidReceiveAppBoundRequestContextDataForDomainCallback):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::appBoundRequestContextDataForDomain):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveAppBoundRequestContextDataForDomain):
* WebKitTestRunner/TestInvocation.h:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::appBoundRequestContextDataForDomain):
* WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView _appBoundNavigationDataForDomain:completionHandler:]):

LayoutTests:

Test coverage.

* http/tests/in-app-browser-privacy/context-string-for-subframe-expected.txt: Added.
* http/tests/in-app-browser-privacy/context-string-for-subframe.html: Added.
* http/tests/in-app-browser-privacy/resources/basic-iframe.html: Added.
* platform/ios-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (275681 => 275682)


--- trunk/LayoutTests/ChangeLog	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/LayoutTests/ChangeLog	2021-04-08 22:14:30 UTC (rev 275682)
@@ -1,3 +1,18 @@
+2021-04-08  Kate Cheney  <katherine_che...@apple.com>
+
+        Add test infrastructure for app bound request context string
+        https://bugs.webkit.org/show_bug.cgi?id=224311
+        <rdar://problem/76229003>
+
+        Reviewed by Brent Fulgham.
+
+        Test coverage.
+
+        * http/tests/in-app-browser-privacy/context-string-for-subframe-expected.txt: Added.
+        * http/tests/in-app-browser-privacy/context-string-for-subframe.html: Added.
+        * http/tests/in-app-browser-privacy/resources/basic-iframe.html: Added.
+        * platform/ios-wk2/TestExpectations:
+
 2021-04-08  Chris Dumez  <cdu...@apple.com>
 
         Suspended OfflineAudioContext objects are leaking

Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/context-string-for-subframe-expected.txt (0 => 275682)


--- trunk/LayoutTests/http/tests/in-app-browser-privacy/context-string-for-subframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/context-string-for-subframe-expected.txt	2021-04-08 22:14:30 UTC (rev 275682)
@@ -0,0 +1,10 @@
+Tests that the app-bound-request context string gets properly set for an iframe
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Context string for sub frame correctly captured.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/context-string-for-subframe.html (0 => 275682)


--- trunk/LayoutTests/http/tests/in-app-browser-privacy/context-string-for-subframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/context-string-for-subframe.html	2021-04-08 22:14:30 UTC (rev 275682)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script>
+        description("Tests that the app-bound-request context string gets properly set for an iframe");
+        jsTestIsAsync = true;
+
+        var subFrameHost = "localhost";
+        var contextHost = "127.0.0.1";
+        function askForContextStringForSubFrame() {
+            testRunner.appBoundRequestContextDataForDomain(subFrameHost, function (contextData) {
+                if (contextData == null) {
+                    askForContextStringForSubFrame();
+                    return;
+                }
+
+                if (contextData == contextHost)
+                    testPassed("Context string for sub frame correctly captured.");
+                else
+                    testFailed("Context string for sub frame NOT correctly captured.");
+
+                finishJSTest();
+            });
+        }
+    </script>
+</head>
+<body>
+<iframe _onload_="setTimeout('askForContextStringForSubFrame()', 0)" src=""
+</iframe>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/in-app-browser-privacy/resources/basic-iframe.html (0 => 275682)


--- trunk/LayoutTests/http/tests/in-app-browser-privacy/resources/basic-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/in-app-browser-privacy/resources/basic-iframe.html	2021-04-08 22:14:30 UTC (rev 275682)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (275681 => 275682)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2021-04-08 22:14:30 UTC (rev 275682)
@@ -1785,6 +1785,9 @@
 
 http/tests/in-app-browser-privacy/ [ Pass ]
 
+# Some In-App Browser Privacy tests rely on functions in WebKitAdditions.
+http/tests/in-app-browser-privacy/context-string-for-subframe.html [ Skip ]
+
 webkit.org/b/175193 fast/images/async-image-body-background-image.html [ Pass Timeout ]
 
 webkit.org/b/215110 [ Release ] imported/w3c/web-platform-tests/css/css-animations/webkit-writing-mode-crash.html [ Pass Failure ]

Modified: trunk/Source/WebKit/ChangeLog (275681 => 275682)


--- trunk/Source/WebKit/ChangeLog	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Source/WebKit/ChangeLog	2021-04-08 22:14:30 UTC (rev 275682)
@@ -1,3 +1,31 @@
+2021-04-08  Kate Cheney  <katherine_che...@apple.com>
+
+        Add test infrastructure for app bound request context string
+        https://bugs.webkit.org/show_bug.cgi?id=224311
+        <rdar://problem/76229003>
+
+        Reviewed by Brent Fulgham.
+
+        The app-bound request context string is the eTLD+1 for a load and is
+        needed by CFNetwork. We should add testing infrastructure to make sure
+        the context string is being properly set.
+
+        Test: http/tests/in-app-browser-privacy/context-string-for-subframe.html
+
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (contextString):
+        (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
+        * Shared/NavigatingToAppBoundDomain.h:
+        (WebKit::AppBoundNavigationTestingData::clearAppBoundNavigationDataTesting):
+        (WebKit::AppBoundNavigationTestingData::updateAppBoundNavigationTestingData):
+        (WebKit::AppBoundNavigationTestingData::encode const):
+        (WebKit::AppBoundNavigationTestingData::decode):
+        Store the context string in the testing struct.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _appBoundNavigationDataForDomain:completionHandler:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        SPI to get the app-bound request test data for layout testing.
+
 2021-04-08  Chris Dumez  <cdu...@apple.com>
 
         Cache NSInvocation objects on _WKRemoteObjectInterface

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (275681 => 275682)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2021-04-08 22:14:30 UTC (rev 275682)
@@ -57,6 +57,7 @@
 #import <WebKitAdditions/NetworkDataTaskCocoaAdditions.h>
 #else
 #define NETWORK_DATA_TASK_COCOA_ADDITIONS
+static WebCore::RegistrableDomain contextString(NSURLRequest *) { return { }; }
 #endif
 
 namespace WebKit {
@@ -340,7 +341,7 @@
 
     NETWORK_DATA_TASK_COCOA_ADDITIONS
 
-    m_session->appBoundNavigationTestingData().updateAppBoundNavigationTestingData(request.isAppBound());
+    m_session->appBoundNavigationTestingData().updateAppBoundNavigationTestingData(request, contextString(nsRequest));
 
     applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(nsRequest, shouldContentSniff == WebCore::ContentSniffingPolicy::SniffContent && !url.isLocalFile(), shouldContentEncodingSniff == WebCore::ContentEncodingSniffingPolicy::Sniff);
 

Modified: trunk/Source/WebKit/Shared/NavigatingToAppBoundDomain.h (275681 => 275682)


--- trunk/Source/WebKit/Shared/NavigatingToAppBoundDomain.h	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Source/WebKit/Shared/NavigatingToAppBoundDomain.h	2021-04-08 22:14:30 UTC (rev 275682)
@@ -26,8 +26,11 @@
 #pragma once
 
 #include "ArgumentCoder.h"
+#include "ArgumentCoders.h"
 #include "Decoder.h"
 #include "Encoder.h"
+#include <WebCore/RegistrableDomain.h>
+#include <WebCore/ResourceRequest.h>
 
 namespace WebKit {
 
@@ -34,6 +37,9 @@
 enum class NavigatingToAppBoundDomain : bool { No, Yes };
 enum class LastNavigationWasAppBound : bool { No, Yes };
 
+using ContextDomain = WebCore::RegistrableDomain;
+using RequestDomain = WebCore::RegistrableDomain;
+
 #if PLATFORM(COCOA)
 struct AppBoundNavigationTestingData {
 
@@ -41,11 +47,13 @@
     {
         hasLoadedAppBoundRequestTesting = false;
         hasLoadedNonAppBoundRequestTesting = false;
+        contextData.clear();
     }
-    
-    void updateAppBoundNavigationTestingData(bool requestIsAppBound)
+
+    void updateAppBoundNavigationTestingData(const WebCore::ResourceRequest& request, WebCore::RegistrableDomain&& contextDomain)
     {
-        requestIsAppBound ? hasLoadedAppBoundRequestTesting = true : hasLoadedNonAppBoundRequestTesting = true;
+        request.isAppBound() ? hasLoadedAppBoundRequestTesting = true : hasLoadedNonAppBoundRequestTesting = true;
+        contextData.add(WebCore::RegistrableDomain(request.url()), contextDomain);
     }
 
     void encode(IPC::Encoder& encoder) const
@@ -52,6 +60,7 @@
     {
         encoder << hasLoadedAppBoundRequestTesting;
         encoder << hasLoadedNonAppBoundRequestTesting;
+        encoder << contextData;
     }
 
     static Optional<AppBoundNavigationTestingData> decode(IPC::Decoder& decoder)
@@ -66,11 +75,17 @@
         if (!hasLoadedNonAppBoundRequestTesting)
             return WTF::nullopt;
 
-        return {{ *hasLoadedAppBoundRequestTesting, *hasLoadedNonAppBoundRequestTesting }};
+        Optional<HashMap<RequestDomain, ContextDomain>> contextData;
+        decoder >> contextData;
+        if (!contextData)
+            return WTF::nullopt;
+
+        return {{ *hasLoadedAppBoundRequestTesting, *hasLoadedNonAppBoundRequestTesting, WTFMove(*contextData) }};
     }
 
     bool hasLoadedAppBoundRequestTesting { false };
     bool hasLoadedNonAppBoundRequestTesting { false };
+    HashMap<RequestDomain, ContextDomain> contextData;
 };
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (275681 => 275682)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-04-08 22:14:30 UTC (rev 275682)
@@ -2234,6 +2234,18 @@
         _page->switchFromStaticFontRegistryToUserFontRegistry();
 }
 
+- (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler
+{
+    _page->appBoundNavigationData([registrableDomain = WebCore::RegistrableDomain::uncheckedCreateFromHost(domain), completionHandler = makeBlockPtr(completionHandler)] (auto&& appBoundData) mutable {
+        if (!appBoundData.contextData.contains(registrableDomain)) {
+            completionHandler(nil);
+            return;
+        }
+
+        completionHandler(appBoundData.contextData.get(registrableDomain).string());
+    });
+}
+
 - (NSArray *)_certificateChain
 {
     if (WebKit::WebFrameProxy* mainFrame = _page->mainFrame())

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (275681 => 275682)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-04-08 22:14:30 UTC (rev 275682)
@@ -404,6 +404,8 @@
 */
 - (void)_switchFromStaticFontRegistryToUserFontRegistry WK_API_AVAILABLE(macos(WK_MAC_TBA));
 
+- (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @end
 
 #if TARGET_OS_IPHONE

Modified: trunk/Tools/ChangeLog (275681 => 275682)


--- trunk/Tools/ChangeLog	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/ChangeLog	2021-04-08 22:14:30 UTC (rev 275682)
@@ -1,3 +1,33 @@
+2021-04-08  Kate Cheney  <katherine_che...@apple.com>
+
+        Add test infrastructure for app bound request context string
+        https://bugs.webkit.org/show_bug.cgi?id=224311
+        <rdar://problem/76229003>
+
+        Reviewed by Brent Fulgham.
+
+        Layout test infrastructure.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::appBoundRequestContextDataForDomain):
+        (WTR::TestRunner::callDidReceiveAppBoundRequestContextDataForDomainCallback):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::appBoundRequestContextDataForDomain):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+        (WTR::TestInvocation::didReceiveAppBoundRequestContextDataForDomain):
+        * WebKitTestRunner/TestInvocation.h:
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::appBoundRequestContextDataForDomain):
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView _appBoundNavigationDataForDomain:completionHandler:]):
+
 2021-04-08  Aakash Jain  <aakash_j...@apple.com>
 
         Add webkit-patch support for fast-cq mode

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2021-04-08 22:14:30 UTC (rev 275682)
@@ -384,6 +384,7 @@
     boolean hasAppBoundSession();
     undefined clearAppBoundSession();
     undefined setAppBoundDomains(object originsArray, object callback);
+    undefined appBoundRequestContextDataForDomain(DOMString domain, object callback);
 
     undefined injectUserScript(DOMString string);
     readonly attribute unsigned long userScriptInjectedCount;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2021-04-08 22:14:30 UTC (rev 275682)
@@ -420,7 +420,15 @@
         m_testRunner->callDidReceiveLoadedSubresourceDomainsCallback(WTFMove(domains));
         return;
     }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "CallDidReceiveAppBoundRequestContextDataForDomain")) {
+        ASSERT(messageBody);
+        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
 
+        auto resultString = toWTFString(static_cast<WKStringRef>(messageBody));
+        m_testRunner->callDidReceiveAppBoundRequestContextDataForDomainCallback(WTFMove(resultString));
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "CallDidRemoveAllSessionCredentialsCallback")) {
         m_testRunner->callDidRemoveAllSessionCredentialsCallback();
         return;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2021-04-08 22:14:30 UTC (rev 275682)
@@ -646,6 +646,7 @@
     DidSetAppBoundDomainsCallbackID,
     EnterFullscreenForElementCallbackID,
     ExitFullscreenForElementCallbackID,
+    AppBoundRequestContextDataForDomainCallbackID,
     FirstUIScriptCallbackID = 100
 };
 
@@ -2104,6 +2105,18 @@
     callTestRunnerCallback(DidSetAppBoundDomainsCallbackID);
 }
 
+void TestRunner::appBoundRequestContextDataForDomain(JSStringRef domain, JSValueRef callback)
+{
+    cacheTestRunnerCallback(AppBoundRequestContextDataForDomainCallbackID, callback);
+    postMessage("AppBoundRequestContextDataForDomain", domain);
+}
+
+void TestRunner::callDidReceiveAppBoundRequestContextDataForDomainCallback(String&& contextDomain)
+{
+    JSValueRef resultValue = JSValueMakeString(mainFrameJSContext(), createJSString(contextDomain.utf8().data()).get());
+    callTestRunnerCallback(AppBoundRequestContextDataForDomainCallbackID, 1, &resultValue);
+}
+
 void TestRunner::setIsSpeechRecognitionPermissionGranted(bool granted)
 {
     postSynchronousPageMessage("SetIsSpeechRecognitionPermissionGranted", granted);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2021-04-08 22:14:30 UTC (rev 275682)
@@ -492,6 +492,8 @@
     void clearAppBoundSession();
     void setAppBoundDomains(JSValueRef originArray, JSValueRef callback);
     void didSetAppBoundDomainsCallback();
+    void appBoundRequestContextDataForDomain(JSStringRef, JSValueRef);
+    void callDidReceiveAppBoundRequestContextDataForDomainCallback(String&&);
 
     size_t userScriptInjectedCount() const;
     void injectUserScript(JSStringRef);

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2021-04-08 22:14:30 UTC (rev 275682)
@@ -2723,6 +2723,10 @@
 {
 }
 
+void TestController::appBoundRequestContextDataForDomain(WKStringRef)
+{
+}
+
 struct GetAllStorageAccessEntriesCallbackContext {
     GetAllStorageAccessEntriesCallbackContext(TestController& controller, CompletionHandler<void(Vector<String>&&)>&& handler)
         : testController(controller)

Modified: trunk/Tools/WebKitTestRunner/TestController.h (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/TestController.h	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2021-04-08 22:14:30 UTC (rev 275682)
@@ -266,6 +266,8 @@
     void clearLoadedSubresourceDomains();
     void clearAppBoundSession();
     void reinitializeAppBoundDomains();
+    void appBoundRequestContextDataForDomain(WKStringRef);
+
     void updateBundleIdentifierInNetworkProcess(const std::string& bundleIdentifier);
     void clearBundleIdentifierInNetworkProcess();
 

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2021-04-08 22:14:30 UTC (rev 275682)
@@ -792,6 +792,12 @@
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "AppBoundRequestContextDataForDomain")) {
+        WKStringRef domain = stringValue(messageBody);
+        TestController::singleton().appBoundRequestContextDataForDomain(domain);
+        return;
+    }
+
     ASSERT_NOT_REACHED();
 }
 
@@ -1564,6 +1570,12 @@
     postPageMessage("CallDidReceiveLoadedSubresourceDomains", messageBody);
 }
 
+void TestInvocation::didReceiveAppBoundRequestContextDataForDomain(String&& domain)
+{
+    auto messageBody = WKStringCreateWithUTF8CString(domain.utf8().data());
+    postPageMessage("CallDidReceiveAppBoundRequestContextDataForDomain", messageBody);
+}
+
 void TestInvocation::didRemoveAllSessionCredentials()
 {
     postPageMessage("CallDidRemoveAllSessionCredentialsCallback");

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2021-04-08 22:14:30 UTC (rev 275682)
@@ -95,6 +95,7 @@
     void didRemoveAllSessionCredentials();
 
     void didSetAppBoundDomains();
+    void didReceiveAppBoundRequestContextDataForDomain(String&&);
 
     void dumpResourceLoadStatistics();
 

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2021-04-08 22:14:30 UTC (rev 275682)
@@ -383,6 +383,22 @@
     [[globalWebViewConfiguration() websiteDataStore] _clearLoadedSubresourceDomainsFor:parentView->platformView()];
 }
 
+void TestController::appBoundRequestContextDataForDomain(WKStringRef domain)
+{
+    auto* parentView = mainWebView();
+    if (!parentView)
+        return;
+
+    [m_mainWebView->platformView() _appBoundNavigationDataForDomain:toWTFString(domain) completionHandler:^(NSString *context) {
+        if (!context) {
+            m_currentInvocation->didReceiveAppBoundRequestContextDataForDomain({ });
+            return;
+        }
+
+        m_currentInvocation->didReceiveAppBoundRequestContextDataForDomain(String(context));
+    }];
+}
+
 void TestController::injectUserScript(WKStringRef script)
 {
     auto userScript = adoptNS([[WKUserScript alloc] initWithSource: toWTFString(script) injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO]);

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h	2021-04-08 22:14:30 UTC (rev 275682)
@@ -82,5 +82,6 @@
 
 - (void)dismissActiveMenu;
 - (void)resetInteractionCallbacks;
+- (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler;
 
 @end

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (275681 => 275682)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2021-04-08 21:52:38 UTC (rev 275681)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2021-04-08 22:14:30 UTC (rev 275682)
@@ -591,4 +591,9 @@
         self.didHideContactPickerCallback();
 }
 
+- (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler
+{
+    [super _appBoundNavigationDataForDomain:domain completionHandler:completionHandler];
+}
+
 @end
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to