Title: [254409] trunk
Revision
254409
Author
[email protected]
Date
2020-01-11 17:46:52 -0800 (Sat, 11 Jan 2020)

Log Message

Expose frame information on _WKResourceLoadInfo
https://bugs.webkit.org/show_bug.cgi?id=206104
<rdar://problem/57132290>

Reviewed by Dean Jackson.

Source/WebCore:

Covered by API tests.

* page/FrameIdentifier.h:
(WebCore::frameIdentifierFromID): Deleted.

Source/WebKit:

* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):
* NetworkProcess/NetworkResourceLoadParameters.h:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::resourceLoadInfo):
* Shared/API/Cocoa/_WKFrameHandle.h:
* Shared/API/Cocoa/_WKFrameHandle.mm:
(-[_WKFrameHandle frameID]):
(-[_WKFrameHandle initWithCoder:]):
(-[_WKFrameHandle encodeWithCoder:]):
(-[_WKFrameHandle _frameID]): Deleted.
* Shared/API/Cocoa/_WKFrameHandleInternal.h:
* Shared/ResourceLoadInfo.h:
(WebKit::ResourceLoadInfo::encode const):
(WebKit::ResourceLoadInfo::decode):
* UIProcess/API/APIResourceLoadInfo.h:
* UIProcess/API/Cocoa/_WKInspector.mm:
(-[_WKInspector showMainResourceForFrame:]):
* UIProcess/API/Cocoa/_WKResourceLoadInfo.h:
* UIProcess/API/Cocoa/_WKResourceLoadInfo.mm:
(-[_WKResourceLoadInfo frame]):
(-[_WKResourceLoadInfo parentFrame]):
* UIProcess/API/mac/WKWebViewMac.mm:
(-[WKWebView _canChangeFrameLayout:]):
(-[WKWebView _printOperationWithPrintInfo:forFrame:]):
* UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
(-[WKReloadFrameErrorRecoveryAttempter attemptRecovery]):
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _wk_pageCountForPrintFormatter:]):
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::evaluateJavaScriptCallback):
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
(+[WKWebProcessPlugInFrame lookUpFrameFromHandle:]):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::addParametersFromFrame):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
(WebKit::WebLoaderStrategy::startPingLoad):
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254408 => 254409)


--- trunk/Source/WebCore/ChangeLog	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebCore/ChangeLog	2020-01-12 01:46:52 UTC (rev 254409)
@@ -1,3 +1,16 @@
+2020-01-11  Alex Christensen  <[email protected]>
+
+        Expose frame information on _WKResourceLoadInfo
+        https://bugs.webkit.org/show_bug.cgi?id=206104
+        <rdar://problem/57132290>
+
+        Reviewed by Dean Jackson.
+
+        Covered by API tests.
+
+        * page/FrameIdentifier.h:
+        (WebCore::frameIdentifierFromID): Deleted.
+
 2020-01-10  Yusuke Suzuki  <[email protected]>
 
         [WebCore] Fix crash in module loader due to change in fragment reservation

Modified: trunk/Source/WebCore/page/FrameIdentifier.h (254408 => 254409)


--- trunk/Source/WebCore/page/FrameIdentifier.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebCore/page/FrameIdentifier.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -32,9 +32,4 @@
 enum FrameIdentifierType { };
 using FrameIdentifier = ObjectIdentifier<FrameIdentifierType>;
 
-inline FrameIdentifier frameIdentifierFromID(uint64_t frameID)
-{
-    return makeObjectIdentifier<FrameIdentifierType>(frameID);
 }
-
-}

Modified: trunk/Source/WebKit/ChangeLog (254408 => 254409)


--- trunk/Source/WebKit/ChangeLog	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/ChangeLog	2020-01-12 01:46:52 UTC (rev 254409)
@@ -1,3 +1,53 @@
+2020-01-11  Alex Christensen  <[email protected]>
+
+        Expose frame information on _WKResourceLoadInfo
+        https://bugs.webkit.org/show_bug.cgi?id=206104
+        <rdar://problem/57132290>
+
+        Reviewed by Dean Jackson.
+
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode const):
+        (WebKit::NetworkResourceLoadParameters::decode):
+        * NetworkProcess/NetworkResourceLoadParameters.h:
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::resourceLoadInfo):
+        * Shared/API/Cocoa/_WKFrameHandle.h:
+        * Shared/API/Cocoa/_WKFrameHandle.mm:
+        (-[_WKFrameHandle frameID]):
+        (-[_WKFrameHandle initWithCoder:]):
+        (-[_WKFrameHandle encodeWithCoder:]):
+        (-[_WKFrameHandle _frameID]): Deleted.
+        * Shared/API/Cocoa/_WKFrameHandleInternal.h:
+        * Shared/ResourceLoadInfo.h:
+        (WebKit::ResourceLoadInfo::encode const):
+        (WebKit::ResourceLoadInfo::decode):
+        * UIProcess/API/APIResourceLoadInfo.h:
+        * UIProcess/API/Cocoa/_WKInspector.mm:
+        (-[_WKInspector showMainResourceForFrame:]):
+        * UIProcess/API/Cocoa/_WKResourceLoadInfo.h:
+        * UIProcess/API/Cocoa/_WKResourceLoadInfo.mm:
+        (-[_WKResourceLoadInfo frame]):
+        (-[_WKResourceLoadInfo parentFrame]):
+        * UIProcess/API/mac/WKWebViewMac.mm:
+        (-[WKWebView _canChangeFrameLayout:]):
+        (-[WKWebView _printOperationWithPrintInfo:forFrame:]):
+        * UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm:
+        (-[WKReloadFrameErrorRecoveryAttempter attemptRecovery]):
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _wk_pageCountForPrintFormatter:]):
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::evaluateJavaScriptCallback):
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm:
+        (+[WKWebProcessPlugInFrame lookUpFrameFromHandle:]):
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::addParametersFromFrame):
+        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+        (WebKit::WebLoaderStrategy::startPingLoad):
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::installServiceWorker):
+
 2020-01-11  Kate Cheney  <[email protected]>
 
         Add correct grandfathering functionality to the ITP database backend

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp (254408 => 254409)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2020-01-12 01:46:52 UTC (rev 254409)
@@ -107,6 +107,7 @@
     encoder << frameAncestorOrigins;
     encoder << isHTTPSUpgradeEnabled;
     encoder << pageHasResourceLoadClient;
+    encoder << parentFrameID;
 
 #if ENABLE(SERVICE_WORKER)
     encoder << serviceWorkersMode;
@@ -255,6 +256,12 @@
     if (!pageHasResourceLoadClient)
         return WTF::nullopt;
     result.pageHasResourceLoadClient = *pageHasResourceLoadClient;
+    
+    Optional<Optional<FrameIdentifier>> parentFrameID;
+    decoder >> parentFrameID;
+    if (!parentFrameID)
+        return WTF::nullopt;
+    result.parentFrameID = WTFMove(*parentFrameID);
 
 #if ENABLE(SERVICE_WORKER)
     Optional<ServiceWorkersMode> serviceWorkersMode;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h (254408 => 254409)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -61,6 +61,7 @@
     Vector<RefPtr<WebCore::SecurityOrigin>> frameAncestorOrigins;
     bool isHTTPSUpgradeEnabled { false };
     bool pageHasResourceLoadClient { false };
+    Optional<WebCore::FrameIdentifier> parentFrameID;
 
 #if ENABLE(SERVICE_WORKER)
     WebCore::ServiceWorkersMode serviceWorkersMode { WebCore::ServiceWorkersMode::None };

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (254408 => 254409)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2020-01-12 01:46:52 UTC (rev 254409)
@@ -336,7 +336,9 @@
 ResourceLoadInfo NetworkResourceLoader::resourceLoadInfo()
 {
     return {
-        m_resourceLoadID
+        m_resourceLoadID,
+        m_parameters.webFrameID,
+        m_parameters.parentFrameID,
     };
 }
 

Modified: trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandle.h (254408 => 254409)


--- trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandle.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandle.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -30,4 +30,6 @@
 WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
 @interface _WKFrameHandle : NSObject <NSCopying, NSSecureCoding>
 
+@property (nonatomic, readonly) uint64_t frameID WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @end

Modified: trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandle.mm (254408 => 254409)


--- trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandle.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandle.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -28,9 +28,7 @@
 
 #import <WebCore/FrameIdentifier.h>
 
-@implementation _WKFrameHandle {
-    API::ObjectStorage<API::FrameHandle> _frameHandle;
-}
+@implementation _WKFrameHandle
 
 - (void)dealloc
 {
@@ -55,7 +53,7 @@
     return _frameHandle->frameID().toUInt64();
 }
 
-- (uint64_t)_frameID
+- (uint64_t)frameID
 {
     return _frameHandle->frameID().toUInt64();
 }
@@ -85,7 +83,7 @@
         return nil;
     }
 
-    API::Object::constructInWrapper<API::FrameHandle>(self, WebCore::frameIdentifierFromID(frameID.unsignedLongLongValue), false);
+    API::Object::constructInWrapper<API::FrameHandle>(self, makeObjectIdentifier<WebCore::FrameIdentifierType>(frameID.unsignedLongLongValue), false);
 
     return self;
 }
@@ -92,7 +90,7 @@
 
 - (void)encodeWithCoder:(NSCoder *)coder
 {
-    [coder encodeObject:@([self _frameID]) forKey:@"frameID"];
+    [coder encodeObject:@(self.frameID) forKey:@"frameID"];
 }
 
 #pragma mark WKObject protocol implementation

Modified: trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandleInternal.h (254408 => 254409)


--- trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandleInternal.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/Shared/API/Cocoa/_WKFrameHandleInternal.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -36,8 +36,8 @@
 
 }
 
-@interface _WKFrameHandle () <WKObject>
-
-@property (nonatomic, readonly) uint64_t _frameID;
-
+@interface _WKFrameHandle () <WKObject> {
+@package
+    API::ObjectStorage<API::FrameHandle> _frameHandle;
+}
 @end

Modified: trunk/Source/WebKit/Shared/ResourceLoadInfo.h (254408 => 254409)


--- trunk/Source/WebKit/Shared/ResourceLoadInfo.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/Shared/ResourceLoadInfo.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -27,6 +27,7 @@
 
 #include "ArgumentCoders.h"
 #include "NetworkResourceLoadIdentifier.h"
+#include <WebCore/FrameIdentifier.h>
 
 namespace WebKit {
 
@@ -33,10 +34,14 @@
 struct ResourceLoadInfo {
 
     NetworkResourceLoadIdentifier resourceLoadID;
+    Optional<WebCore::FrameIdentifier> frameID;
+    Optional<WebCore::FrameIdentifier> parentFrameID;
     
     void encode(IPC::Encoder& encoder) const
     {
         encoder << resourceLoadID;
+        encoder << frameID;
+        encoder << parentFrameID;
     }
 
     static Optional<ResourceLoadInfo> decode(IPC::Decoder& decoder)
@@ -46,8 +51,20 @@
         if (!resourceLoadID)
             return WTF::nullopt;
 
+        Optional<Optional<WebCore::FrameIdentifier>> frameID;
+        decoder >> frameID;
+        if (!frameID)
+            return WTF::nullopt;
+
+        Optional<Optional<WebCore::FrameIdentifier>> parentFrameID;
+        decoder >> parentFrameID;
+        if (!parentFrameID)
+            return WTF::nullopt;
+
         return {{
             WTFMove(*resourceLoadID),
+            WTFMove(*frameID),
+            WTFMove(*parentFrameID),
         }};
     }
 };

Modified: trunk/Source/WebKit/UIProcess/API/APIResourceLoadInfo.h (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/API/APIResourceLoadInfo.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/API/APIResourceLoadInfo.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -38,6 +38,8 @@
     }
 
     WebKit::NetworkResourceLoadIdentifier resourceLoadID() const { return m_info.resourceLoadID; }
+    Optional<WebCore::FrameIdentifier> frameID() const { return m_info.frameID; }
+    Optional<WebCore::FrameIdentifier> parentFrameID() const { return m_info.parentFrameID; }
 
 private:
     explicit ResourceLoadInfo(WebKit::ResourceLoadInfo&& info)

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -109,7 +109,7 @@
 - (void)showMainResourceForFrame:(_WKFrameHandle *)frame
 {
     if (auto* page = _inspector->inspectedPage())
-        _inspector->showMainResourceForFrame(page->process().webFrame(WebCore::frameIdentifierFromID(frame._frameID)));
+        _inspector->showMainResourceForFrame(page->process().webFrame(frame->_frameHandle->frameID()));
 }
 
 - (void)attach

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadInfo.h (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadInfo.h	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadInfo.h	2020-01-12 01:46:52 UTC (rev 254409)
@@ -23,6 +23,10 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#import <WebKit/WKFoundation.h>
+
+@class _WKFrameHandle;
+
 NS_ASSUME_NONNULL_BEGIN
 
 WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
@@ -32,6 +36,8 @@
 - (instancetype)init NS_UNAVAILABLE;
 
 @property (nonatomic, readonly) uint64_t resourceLoadID;
+@property (nonatomic, readonly) _WKFrameHandle* frame;
+@property (nonatomic, readonly, nullable) _WKFrameHandle* parentFrame;
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadInfo.mm (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadInfo.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKResourceLoadInfo.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -26,7 +26,9 @@
 #import "config.h"
 #import "_WKResourceLoadInfo.h"
 
+#import "APIFrameHandle.h"
 #import "APIResourceLoadInfo.h"
+#import "_WKFrameHandleInternal.h"
 #import "_WKResourceLoadInfoInternal.h"
 
 @implementation _WKResourceLoadInfo
@@ -42,6 +44,20 @@
     return _info->resourceLoadID().toUInt64();
 }
 
+- (_WKFrameHandle *)frame
+{
+    if (auto frameID = _info->frameID())
+        return wrapper(API::FrameHandle::create(*frameID));
+    return nil;
+}
+
+- (_WKFrameHandle *)parentFrame
+{
+    if (auto parentFrameID = _info->parentFrameID())
+        return wrapper(API::FrameHandle::create(*parentFrameID));
+    return nil;
+}
+
 - (API::Object&)_apiObject
 {
     return *_info;

Modified: trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -1491,7 +1491,7 @@
 
 - (BOOL)_canChangeFrameLayout:(_WKFrameHandle *)frameHandle
 {
-    if (auto* webFrameProxy = _page->process().webFrame(WebCore::frameIdentifierFromID(frameHandle._frameID)))
+    if (auto* webFrameProxy = _page->process().webFrame(frameHandle->_frameHandle->frameID()))
         return _impl->canChangeFrameLayout(*webFrameProxy);
     return false;
 }
@@ -1578,7 +1578,7 @@
 
 - (NSPrintOperation *)_printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(_WKFrameHandle *)frameHandle
 {
-    if (auto* webFrameProxy = _page->process().webFrame(WebCore::frameIdentifierFromID(frameHandle._frameID)))
+    if (auto* webFrameProxy = _page->process().webFrame(frameHandle->_frameHandle->frameID()))
         return _impl->printOperationWithPrintInfo(printInfo, *webFrameProxy);
     return nil;
 }

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -63,7 +63,7 @@
     if (!webView)
         return NO;
 
-    WebKit::WebFrameProxy* webFrameProxy = webView->_page->process().webFrame(WebCore::frameIdentifierFromID([_frameHandle _frameID]));
+    WebKit::WebFrameProxy* webFrameProxy = webView->_page->process().webFrame(_frameHandle->_frameHandle->frameID());
     if (!webFrameProxy)
         return NO;
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (254408 => 254409)


--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -748,7 +748,7 @@
 
     WebCore::FrameIdentifier frameID;
     if (_WKFrameHandle *handle = printFormatter.frameToPrint)
-        frameID = WebCore::frameIdentifierFromID(handle._frameID);
+        frameID = handle->_frameHandle->frameID();
     else if (auto mainFrame = _page->mainFrame())
         frameID = mainFrame->frameID();
     else

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (254408 => 254409)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2020-01-12 01:46:52 UTC (rev 254409)
@@ -190,7 +190,7 @@
     if (!automationSessionProxy)
         return JSValueMakeUndefined(context);
 
-    WebCore::FrameIdentifier frameID = WebCore::frameIdentifierFromID(JSValueToNumber(context, arguments[0], exception));
+    WebCore::FrameIdentifier frameID = makeObjectIdentifier<WebCore::FrameIdentifierType>(JSValueToNumber(context, arguments[0], exception));
     uint64_t callbackID = JSValueToNumber(context, arguments[1], exception);
     if (JSValueIsString(context, arguments[2])) {
         auto result = adoptRef(JSValueToStringCopy(context, arguments[2], exception));

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm (254408 => 254409)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -48,7 +48,7 @@
 
 + (instancetype)lookUpFrameFromHandle:(_WKFrameHandle *)handle
 {
-    return wrapper(WebKit::WebProcess::singleton().webFrame(WebCore::frameIdentifierFromID(handle._frameID)));
+    return wrapper(WebKit::WebProcess::singleton().webFrame(handle->_frameHandle->frameID()));
 }
 
 - (void)dealloc

Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (254408 => 254409)


--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2020-01-12 01:46:52 UTC (rev 254409)
@@ -57,6 +57,7 @@
 #include <WebCore/FetchOptions.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
+#include <WebCore/HTMLFrameOwnerElement.h>
 #include <WebCore/NetscapePlugInStreamLoader.h>
 #include <WebCore/NetworkLoadInformation.h>
 #include <WebCore/PlatformStrategies.h>
@@ -253,6 +254,22 @@
     return false;
 }
 
+static void addParametersFromFrame(const Frame* frame, NetworkResourceLoadParameters& parameters)
+{
+    if (!frame)
+        return;
+
+    parameters.isHTTPSUpgradeEnabled = frame->settings().HTTPSUpgradeEnabled();
+
+    if (auto* page = frame->page())
+        parameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
+
+    if (auto* ownerElement = frame->ownerElement()) {
+        if (auto* parentFrame = ownerElement->document().frame())
+            parameters.parentFrameID = parentFrame->loader().client().frameID();
+    }
+}
+
 void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceLoader, const ResourceRequest& request, const WebResourceLoader::TrackingParameters& trackingParameters, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime)
 {
     ResourceLoadIdentifier identifier = resourceLoader.identifier();
@@ -286,11 +303,7 @@
     loadParameters.maximumBufferingTime = maximumBufferingTime;
     loadParameters.options = resourceLoader.options();
     loadParameters.preflightPolicy = resourceLoader.options().preflightPolicy;
-    if (frame) {
-        loadParameters.isHTTPSUpgradeEnabled = frame->settings().HTTPSUpgradeEnabled();
-        if (auto* page = frame->page())
-            loadParameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
-    }
+    addParametersFromFrame(frame, loadParameters);
 
 #if ENABLE(SERVICE_WORKER)
     loadParameters.serviceWorkersMode = resourceLoader.options().serviceWorkersMode;
@@ -580,8 +593,7 @@
             loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders();
     }
     loadParameters.originalRequestHeaders = originalRequestHeaders;
-    if (page)
-        loadParameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
+    addParametersFromFrame(webFrame->coreFrame(), loadParameters);
 
     data.shrink(0);
 
@@ -647,8 +659,7 @@
         if (auto* contentSecurityPolicy = document->contentSecurityPolicy())
             loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders();
     }
-    if (auto* page = document->page())
-        loadParameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
+    addParametersFromFrame(&frame, loadParameters);
 
 #if ENABLE(CONTENT_EXTENSIONS)
     loadParameters.mainDocumentURL = document->topDocument().url();

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (254408 => 254409)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2020-01-12 01:46:52 UTC (rev 254409)
@@ -148,7 +148,7 @@
     // FIXME: This method should be moved directly to WebCore::SWContextManager::Connection
     // If it weren't for ServiceWorkerFrameLoaderClient's dependence on WebDocumentLoader, this could already happen.
     // FIXME: Weird to pass m_previousServiceWorkerID as a FrameIdentifier.
-    auto frameLoaderClient = makeUnique<ServiceWorkerFrameLoaderClient>(*this, m_webPageProxyID, m_pageID, frameIdentifierFromID(++m_previousServiceWorkerID), effectiveUserAgent);
+    auto frameLoaderClient = makeUnique<ServiceWorkerFrameLoaderClient>(*this, m_webPageProxyID, m_pageID, makeObjectIdentifier<WebCore::FrameIdentifierType>(++m_previousServiceWorkerID), effectiveUserAgent);
     pageConfiguration.loaderClientForMainFrame = frameLoaderClient.get();
     m_loaders.add(WTFMove(frameLoaderClient));
 

Modified: trunk/Tools/ChangeLog (254408 => 254409)


--- trunk/Tools/ChangeLog	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Tools/ChangeLog	2020-01-12 01:46:52 UTC (rev 254409)
@@ -1,3 +1,14 @@
+2020-01-11  Alex Christensen  <[email protected]>
+
+        Expose frame information on _WKResourceLoadInfo
+        https://bugs.webkit.org/show_bug.cgi?id=206104
+        <rdar://problem/57132290>
+
+        Reviewed by Dean Jackson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
+        (TEST):
+
 2020-01-11  Kate Cheney  <[email protected]>
 
         Add correct grandfathering functionality to the ITP database backend

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm (254408 => 254409)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm	2020-01-12 01:25:25 UTC (rev 254408)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm	2020-01-12 01:46:52 UTC (rev 254409)
@@ -32,6 +32,7 @@
 #import "TestWKWebView.h"
 #import <WebKit/WKWebViewPrivate.h>
 #import <WebKit/WebKit.h>
+#import <WebKit/_WKFrameHandle.h>
 #import <WebKit/_WKResourceLoadDelegate.h>
 #import <WebKit/_WKResourceLoadInfo.h>
 #import <wtf/RetainPtr.h>
@@ -129,7 +130,7 @@
 {
     TestWebKitAPI::HTTPServer server({
         { "/", { "hello" } },
-        { "/xhrTarget", { "hi" } },
+        { "/xhrTarget", { {{ "Content-Type", "text/html" }},  "hi" } },
         { "/beaconTarget", { "hi" } },
     });
 
@@ -140,9 +141,11 @@
     __block bool receivedCallback = false;
     auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
     [webView _setResourceLoadDelegate:resourceLoadDelegate.get()];
-    [resourceLoadDelegate setDidSendRequest:^(WKWebView *, _WKResourceLoadInfo *, NSURLRequest *request) {
+    [resourceLoadDelegate setDidSendRequest:^(WKWebView *, _WKResourceLoadInfo *info, NSURLRequest *request) {
         requestFromDelegate = request;
         receivedCallback = true;
+        EXPECT_TRUE(!!info.frame);
+        EXPECT_FALSE(!!info.parentFrame);
     }];
     
     __block bool receivedAlert = false;
@@ -264,6 +267,27 @@
     EXPECT_EQ(loadInfos[6].get().resourceLoadID, loadInfos[7].get().resourceLoadID);
     EXPECT_EQ(loadInfos[6].get().resourceLoadID, loadInfos[8].get().resourceLoadID);
     EXPECT_NE(loadInfos[6].get().resourceLoadID, loadInfos[0].get().resourceLoadID);
+    auto checkFrames = ^(size_t index, _WKFrameHandle *expectedFrame, _WKFrameHandle *expectedParent) {
+        _WKResourceLoadInfo *info = loadInfos[index].get();
+        EXPECT_EQ(!!info.frame, !!expectedFrame);
+        EXPECT_EQ(!!info.parentFrame, !!expectedParent);
+        EXPECT_EQ(info.frame.frameID, expectedFrame.frameID);
+        EXPECT_EQ(info.parentFrame.frameID, expectedParent.frameID);
+    };
+    _WKFrameHandle *main = loadInfos[0].get().frame;
+    _WKFrameHandle *sub = loadInfos[8].get().frame;
+    EXPECT_TRUE(!!main);
+    EXPECT_TRUE(!!sub);
+    EXPECT_TRUE(main.frameID != sub.frameID);
+    checkFrames(0, main, nil);
+    checkFrames(1, main, nil);
+    checkFrames(2, main, nil);
+    checkFrames(3, sub, main);
+    checkFrames(4, sub, main);
+    checkFrames(5, sub, main);
+    checkFrames(6, sub, main);
+    checkFrames(7, sub, main);
+    checkFrames(8, sub, main);
 
     EXPECT_EQ(otherParameters.size(), 9ull);
     EXPECT_WK_STREQ(NSStringFromClass([otherParameters[0] class]), "NSMutableURLRequest");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to