Skip to content

Commit

Permalink
[WebKit] Add an option key to prevent network loads when serializing …
Browse files Browse the repository at this point in the history
…attributed strings

https://bugs.webkit.org/show_bug.cgi?id=264745
rdar://118309399

Reviewed by Tim Horton.

Add support for a `NSAttributedStringDocumentReadingOptionKey` which allows clients to serialize
attributed strings from web content, without loading any requests over the network. This is
particularly ideal for clients such as UIFoundation, when serializing HTML markup and/or web archive
data, which otherwise has the potential to trigger arbitrary resource loads upon conversion.

Note that we add an opt-in flag for network loads, because we want to eventually default to *not*
loading content from over the network when serializing attributed strings. Given this eventual plan,
it makes more sense for an app to need to explicitly opt _in_ to network loads, rather than opt out.

Test: WKWebView.DoNotAllowNetworkLoads

* Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm:
(+[_WKAttributedStringWebViewCache configuration]):

Respect the new `_WKAllowNetworkLoadsOption` option by setting `_allowedNetworkHosts` to an empty
set on the configuration, if the value is false-y.

(+[_WKAttributedStringWebViewCache maybeUpdateShouldAllowNetworkLoads:]):
(+[_WKAttributedStringWebViewCache maybeConsumeBundlePaths:]):
(+[_WKAttributedStringWebViewCache invalidateGlobalConfigurationIfNeeded:]):

Refactor this logic to update the global configuration (and clear any cached web views if needed),
if either network load disablement or the allowed file URL list changes.

(+[NSAttributedString _loadFromHTMLWithOptions:contentLoader:completionHandler:]):
* Source/WebKit/UIProcess/API/Cocoa/NSAttributedStringPrivate.h:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:

Lift the `TestResourceLoadDelegate` class out of this API test and into a separate helper file, so
that we can use it in a different API test suite (see below).

(-[TestResourceLoadDelegate webView:resourceLoad:didSendRequest:]): Deleted.
(-[TestResourceLoadDelegate webView:resourceLoad:didPerformHTTPRedirection:newRequest:]): Deleted.
(-[TestResourceLoadDelegate webView:resourceLoad:didReceiveChallenge:]): Deleted.
(-[TestResourceLoadDelegate webView:resourceLoad:didReceiveResponse:]): Deleted.
(-[TestResourceLoadDelegate webView:resourceLoad:didCompleteWithError:response:]): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm:

Add a new API test to exercise the case where `_WKAllowNetworkLoadsOption` is set to `@NO`, by
adding a resource load delegate to the web view to listen for any attempted network access. When
this new option is set, we should never get a call to the `didSendRequest:` delegate method.

* Tools/TestWebKitAPI/cocoa/TestResourceLoadDelegate.h: Added.
* Tools/TestWebKitAPI/cocoa/TestResourceLoadDelegate.mm: Added.
(-[TestResourceLoadDelegate webView:resourceLoad:didSendRequest:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didPerformHTTPRedirection:newRequest:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didReceiveChallenge:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didReceiveResponse:]):
(-[TestResourceLoadDelegate webView:resourceLoad:didCompleteWithError:response:]):

Canonical link: https://commits.webkit.org/270753@main
  • Loading branch information
whsieh committed Nov 15, 2023
1 parent 8d05646 commit 39925c5
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 49 deletions.
36 changes: 31 additions & 5 deletions Source/WebKit/UIProcess/API/Cocoa/NSAttributedString.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

NSString * const NSReadAccessURLDocumentOption = @"ReadAccessURL";
NSString * const _WKReadAccessFileURLsOption = @"_WKReadAccessFileURLsOption";
NSString * const _WKAllowNetworkLoadsOption = @"_WKAllowNetworkLoadsOption";

constexpr CGRect webViewRect = { { 0, 0 }, { 800, 600 } };
constexpr NSTimeInterval defaultTimeoutInterval = 60;
Expand Down Expand Up @@ -118,7 +119,7 @@ @interface _WKAttributedStringWebViewCache : NSObject

+ (RetainPtr<WKWebView>)retrieveOrCreateWebView;
+ (void)cacheWebView:(WKWebView *)webView;
+ (void)maybeConsumeBundlePaths:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)options;
+ (void)invalidateGlobalConfigurationIfNeeded:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)options;
+ (void)validateEntry:(id)maybeFileURL;

@end
Expand All @@ -137,6 +138,10 @@ @implementation _WKAttributedStringWebViewCache
return configuration;
}

// FIXME (264780): This should ideally default to `NO`, but making this change would break
// copy/paste from Chrome or Firefox on macOS into TextEdit and other native apps.
static BOOL shouldAllowNetworkLoads = YES;

static NSMutableArray<NSURL *> *readOnlyAccessPaths()
{
static NeverDestroyed<RetainPtr<NSMutableArray>> readOnlyAccessPaths = adoptNS([[NSMutableArray alloc] initWithCapacity:maximumReadOnlyAccessPaths]);
Expand Down Expand Up @@ -174,6 +179,9 @@ + (WKWebViewConfiguration *)configuration
#endif

[configuration preferences]._defaultFontSize = 12;

if (!shouldAllowNetworkLoads)
[configuration _setAllowedNetworkHosts:NSSet.set];
}

return configuration.get();
Expand Down Expand Up @@ -208,12 +216,21 @@ + (void)validateEntry:(id)maybeFileURL
[self clearConfigurationAndRaiseExceptionIfNecessary:errorMessage];
}

+ (void)maybeConsumeBundlePaths:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)options
+ (void)maybeUpdateShouldAllowNetworkLoads:(id)allowNetworkLoadsValue
{
id maybeReadAccessFileURLs = options[_WKReadAccessFileURLsOption];
if (!maybeReadAccessFileURLs)
auto *allowNetworkLoadsAsNumber = dynamic_objc_cast<NSNumber>(allowNetworkLoadsValue);
if (!allowNetworkLoadsAsNumber)
[self clearConfigurationAndRaiseExceptionIfNecessary:@"The value associated with _WKAllowNetworkLoadsOption must be an NSNumber."];

if (allowNetworkLoadsAsNumber.boolValue == shouldAllowNetworkLoads)
return;

shouldAllowNetworkLoads = allowNetworkLoadsAsNumber.boolValue;
[self clearConfiguration];
}

+ (void)maybeConsumeBundlePaths:(id)maybeReadAccessFileURLs
{
NSString *errorMessage = nil;
auto* readAccessFileURLs = dynamic_objc_cast<NSArray<NSURL *>>(maybeReadAccessFileURLs);
if (!readAccessFileURLs)
Expand All @@ -236,6 +253,15 @@ + (void)maybeConsumeBundlePaths:(NSDictionary<NSAttributedStringDocumentReadingO
[self clearConfiguration];
}

+ (void)invalidateGlobalConfigurationIfNeeded:(NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *)options
{
if (id maybeReadAccessFileURLs = options[_WKReadAccessFileURLsOption])
[self maybeConsumeBundlePaths:maybeReadAccessFileURLs];

if (id allowNetworkLoads = options[_WKAllowNetworkLoadsOption])
[self maybeUpdateShouldAllowNetworkLoads:allowNetworkLoads];
}

+ (RetainPtr<WKWebView>)retrieveOrCreateWebView
{
[self resetPurgeDelay];
Expand Down Expand Up @@ -322,7 +348,7 @@ + (void)_loadFromHTMLWithOptions:(NSDictionary<NSAttributedStringDocumentReading
auto runConversion = ^{
__block auto finished = NO;

[_WKAttributedStringWebViewCache maybeConsumeBundlePaths:options];
[_WKAttributedStringWebViewCache invalidateGlobalConfigurationIfNeeded:options];
__block auto webView = [_WKAttributedStringWebViewCache retrieveOrCreateWebView];
__block auto navigationDelegate = adoptNS([[_WKAttributedStringNavigationDelegate alloc] init]);

Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit/UIProcess/API/Cocoa/NSAttributedStringPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ NS_ASSUME_NONNULL_BEGIN

/*!
@abstract Indicates additional local paths WebKit can read from when loading content.
The value is an NSArray containing one or more NSURLs.
*/
WK_EXTERN NSAttributedStringDocumentReadingOptionKey const _WKReadAccessFileURLsOption
NS_SWIFT_NAME(readAccessPaths) WK_API_AVAILABLE(macos(13.1), ios(16.2));

/*!
@abstract Whether to allow loads over the network (including subresources).
The value is an NSNumber, which is interpreted as a BOOL.
*/
WK_EXTERN NSAttributedStringDocumentReadingOptionKey const _WKAllowNetworkLoadsOption
NS_SWIFT_NAME(allowNetworkLoads) WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

/*!
@discussion Private extension of @link //apple_ref/occ/NSAttributedString NSAttributedString @/link to
translate HTML content into attributed strings using WebKit.
Expand Down
1 change: 1 addition & 0 deletions Tools/TestWebKitAPI/SourcesCocoa.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ cocoa/TestInspectorURLSchemeHandler.mm
cocoa/TestLegacyDownloadDelegate.mm
cocoa/TestNavigationDelegate.mm
cocoa/TestProtocol.mm
cocoa/TestResourceLoadDelegate.mm
cocoa/TestUIDelegate.mm
cocoa/TestWKWebView.mm
cocoa/TestWebExtensionsDelegate.mm
Expand Down
4 changes: 4 additions & 0 deletions Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,8 @@
F4BDA42E27F8BF2F00F9647D /* FullscreenVideoTextRecognition.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenVideoTextRecognition.mm; sourceTree = "<group>"; };
F4BDA42F27F8CF5600F9647D /* element-fullscreen.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "element-fullscreen.html"; sourceTree = "<group>"; };
F4BFA68C1E4AD08000154298 /* LegacyDragAndDropTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyDragAndDropTests.mm; sourceTree = "<group>"; };
F4C192CD2B027C93001F75CE /* TestResourceLoadDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TestResourceLoadDelegate.h; path = cocoa/TestResourceLoadDelegate.h; sourceTree = "<group>"; };
F4C192CE2B027C93001F75CE /* TestResourceLoadDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = TestResourceLoadDelegate.mm; path = cocoa/TestResourceLoadDelegate.mm; sourceTree = "<group>"; };
F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
F4C8797E2059D8D3009CD00B /* ScrollViewInsetTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollViewInsetTests.mm; sourceTree = "<group>"; };
F4CB8A7B2856447F0017ECD3 /* TestPDFHostViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestPDFHostViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3853,6 +3855,8 @@
516281242325C17B00BB7E42 /* TestPDFDocument.mm */,
A14FC58D1B8AE36500D107EB /* TestProtocol.h */,
A14FC58E1B8AE36500D107EB /* TestProtocol.mm */,
F4C192CD2B027C93001F75CE /* TestResourceLoadDelegate.h */,
F4C192CE2B027C93001F75CE /* TestResourceLoadDelegate.mm */,
5CBAA7F324327F6B00564A8B /* TestUIDelegate.h */,
5CBAA7F424327F6B00564A8B /* TestUIDelegate.mm */,
B63EF53E2995797F00A190A3 /* TestWebExtensionsDelegate.h */,
Expand Down
45 changes: 1 addition & 44 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "HTTPServer.h"
#import "PlatformUtilities.h"
#import "TestNavigationDelegate.h"
#import "TestResourceLoadDelegate.h"
#import "TestUIDelegate.h"
#import "TestWKWebView.h"
#import <WebKit/WKWebViewPrivate.h>
Expand All @@ -37,50 +38,6 @@
#import <WebKit/_WKResourceLoadInfo.h>
#import <wtf/RetainPtr.h>

@interface TestResourceLoadDelegate : NSObject <_WKResourceLoadDelegate>

@property (nonatomic, copy) void (^didSendRequest)(WKWebView *, _WKResourceLoadInfo *, NSURLRequest *);
@property (nonatomic, copy) void (^didPerformHTTPRedirection)(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *, NSURLRequest *);
@property (nonatomic, copy) void (^didReceiveChallenge)(WKWebView *, _WKResourceLoadInfo *, NSURLAuthenticationChallenge *);
@property (nonatomic, copy) void (^didReceiveResponse)(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *);
@property (nonatomic, copy) void (^didCompleteWithError)(WKWebView *, _WKResourceLoadInfo *, NSError *, NSURLResponse *);

@end

@implementation TestResourceLoadDelegate

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didSendRequest:(NSURLRequest *)request
{
if (_didSendRequest)
_didSendRequest(webView, resourceLoad, request);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didPerformHTTPRedirection:(NSURLResponse *)response newRequest:(NSURLRequest *)request
{
if (_didPerformHTTPRedirection)
_didPerformHTTPRedirection(webView, resourceLoad, response, request);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
{
if (_didReceiveChallenge)
_didReceiveChallenge(webView, resourceLoad, challenge);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveResponse:(NSURLResponse *)response
{
if (_didReceiveResponse)
_didReceiveResponse(webView, resourceLoad, response);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didCompleteWithError:(NSError *)error response:(NSURLResponse *)response
{
if (_didCompleteWithError)
_didCompleteWithError(webView, resourceLoad, error, response);
}

@end

TEST(ResourceLoadDelegate, Basic)
{
auto webView = adoptNS([WKWebView new]);
Expand Down
42 changes: 42 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
#import "PlatformUtilities.h"
#import "Test.h"
#import "TestNavigationDelegate.h"
#import "TestProtocol.h"
#import "TestResourceLoadDelegate.h"
#import "TestWKWebView.h"
#import "UIKitSPIForTesting.h"
#import <WebKit/NSAttributedStringPrivate.h>
#import <WebKit/_WKResourceLoadInfo.h>
#import <pal/spi/cocoa/NSAttributedStringSPI.h>
#import <wtf/cocoa/TypeCastsCocoa.h>

Expand Down Expand Up @@ -409,3 +413,41 @@ - (NSAttributedString *)_contentsAsAttributedString
checkListAtIndex(6, @"", secondList);
checkListAtIndex(7, @"Four", secondList);
}

TEST(WKWebView, DoNotAllowNetworkLoads)
{
[TestProtocol registerWithScheme:@"https"];

NSString *markup = @""
"<body>"
"<strong>Hello</strong>"
"<img src='https://webkit.org/nonexistent-image.png'>"
"</body>";

__block bool attemptedImageLoad = false;
auto resourceLoadDelegate = adoptNS([TestResourceLoadDelegate new]);
[resourceLoadDelegate setDidSendRequest:^(WKWebView *, _WKResourceLoadInfo *info, NSURLRequest *) {
if (info.resourceType == _WKResourceLoadInfoResourceTypeImage)
attemptedImageLoad = true;
}];

__block bool done = false;
__block RetainPtr<NSAttributedString> resultString;
__block RetainPtr<NSError> resultError;
[NSAttributedString _loadFromHTMLWithOptions:@{ _WKAllowNetworkLoadsOption : @NO } contentLoader:^(WKWebView *webView) {
webView._resourceLoadDelegate = resourceLoadDelegate.get();
return [webView loadHTMLString:markup baseURL:nil];
} completionHandler:^(NSAttributedString *string, NSDictionary *, NSError *error) {
resultString = string;
resultError = error;
done = true;
}];
TestWebKitAPI::Util::run(&done);

EXPECT_NULL(resultError);

auto helloRange = [[resultString string] rangeOfString:@"Hello"];
EXPECT_EQ(helloRange.location, 0U);
EXPECT_EQ(helloRange.length, 5U);
EXPECT_FALSE(attemptedImageLoad);
}
41 changes: 41 additions & 0 deletions Tools/TestWebKitAPI/cocoa/TestResourceLoadDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#import <WebKit/WebKit.h>
#import <WebKit/_WKResourceLoadDelegate.h>

@class _WKResourceLoadInfo;

@interface TestResourceLoadDelegate : NSObject <_WKResourceLoadDelegate>

@property (nonatomic, copy) void (^didSendRequest)(WKWebView *, _WKResourceLoadInfo *, NSURLRequest *);
@property (nonatomic, copy) void (^didPerformHTTPRedirection)(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *, NSURLRequest *);
@property (nonatomic, copy) void (^didReceiveChallenge)(WKWebView *, _WKResourceLoadInfo *, NSURLAuthenticationChallenge *);
@property (nonatomic, copy) void (^didReceiveResponse)(WKWebView *, _WKResourceLoadInfo *, NSURLResponse *);
@property (nonatomic, copy) void (^didCompleteWithError)(WKWebView *, _WKResourceLoadInfo *, NSError *, NSURLResponse *);

@end
63 changes: 63 additions & 0 deletions Tools/TestWebKitAPI/cocoa/TestResourceLoadDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "config.h"
#import "TestResourceLoadDelegate.h"

#import <WebKit/_WKResourceLoadInfo.h>

@implementation TestResourceLoadDelegate

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didSendRequest:(NSURLRequest *)request
{
if (_didSendRequest)
_didSendRequest(webView, resourceLoad, request);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didPerformHTTPRedirection:(NSURLResponse *)response newRequest:(NSURLRequest *)request
{
if (_didPerformHTTPRedirection)
_didPerformHTTPRedirection(webView, resourceLoad, response, request);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
{
if (_didReceiveChallenge)
_didReceiveChallenge(webView, resourceLoad, challenge);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didReceiveResponse:(NSURLResponse *)response
{
if (_didReceiveResponse)
_didReceiveResponse(webView, resourceLoad, response);
}

- (void)webView:(WKWebView *)webView resourceLoad:(_WKResourceLoadInfo *)resourceLoad didCompleteWithError:(NSError *)error response:(NSURLResponse *)response
{
if (_didCompleteWithError)
_didCompleteWithError(webView, resourceLoad, error, response);
}

@end

0 comments on commit 39925c5

Please sign in to comment.