Title: [284917] trunk
- Revision
- 284917
- Author
- [email protected]
- Date
- 2021-10-26 20:11:35 -0700 (Tue, 26 Oct 2021)
Log Message
Remove properties set by NSURLProtocol on NSURLRequest before serializing
https://bugs.webkit.org/show_bug.cgi?id=232332
<rdar://79227845>
Patch by Alex Christensen <[email protected]> on 2021-10-26
Reviewed by Geoff Garen.
Source/WebCore/PAL:
* pal/spi/cf/CFNetworkSPI.h:
Source/WebKit:
NSURLRequest encodeWithCoder: encodes the protocol properties, which are not used by WebKit.
They exist to be used by NSURLProtocol. Serializing them can serialize a large amount of data,
so to be more efficient and hopefully run out of memory less, remove the properties before serializing.
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::ResourceRequest>::encodePlatformData):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (284916 => 284917)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-10-27 01:07:57 UTC (rev 284916)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-10-27 03:11:35 UTC (rev 284917)
@@ -1,3 +1,13 @@
+2021-10-26 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ * pal/spi/cf/CFNetworkSPI.h:
+
2021-10-26 Fujii Hironori <[email protected]>
[WebCore] Remove unneeded WTF:: namespace prefix
Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (284916 => 284917)
--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h 2021-10-27 01:07:57 UTC (rev 284916)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h 2021-10-27 03:11:35 UTC (rev 284917)
@@ -500,4 +500,12 @@
- (void)_sendCloseCode:(NSURLSessionWebSocketCloseCode)closeCode reason:(NSData *)reason;
@end
+@interface NSMutableURLRequest (Staging_83855325)
+- (void)_removeAllProtocolProperties;
+@end
+
+@interface NSURLRequest (Staging_83857142)
+@property (nonatomic, readonly, nullable, retain) NSDictionary<NSString *, id> *_allProtocolProperties;
+@end
+
#endif // defined(__OBJC__)
Modified: trunk/Source/WebKit/ChangeLog (284916 => 284917)
--- trunk/Source/WebKit/ChangeLog 2021-10-27 01:07:57 UTC (rev 284916)
+++ trunk/Source/WebKit/ChangeLog 2021-10-27 03:11:35 UTC (rev 284917)
@@ -1,3 +1,18 @@
+2021-10-26 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ NSURLRequest encodeWithCoder: encodes the protocol properties, which are not used by WebKit.
+ They exist to be used by NSURLProtocol. Serializing them can serialize a large amount of data,
+ so to be more efficient and hopefully run out of memory less, remove the properties before serializing.
+
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<WebCore::ResourceRequest>::encodePlatformData):
+
2021-10-26 Kate Cheney <[email protected]>
NetworkProcess::updateBundleIdentifier, a testing function, overrides the actual bundleID instead of the override value
Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (284916 => 284917)
--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2021-10-27 01:07:57 UTC (rev 284916)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2021-10-27 03:11:35 UTC (rev 284917)
@@ -37,6 +37,7 @@
#import <WebCore/FontCustomPlatformData.h>
#import <WebCore/ResourceRequest.h>
#import <WebCore/TextRecognitionResult.h>
+#import <pal/spi/cf/CFNetworkSPI.h>
#import <pal/spi/cf/CoreTextSPI.h>
#if PLATFORM(IOS_FAMILY)
@@ -626,10 +627,18 @@
// We don't send HTTP body over IPC for better performance.
// Also, it's not always possible to do, as streams can only be created in process that does networking.
- if ([requestToSerialize HTTPBody] || [requestToSerialize HTTPBodyStream]) {
+ bool hasHTTPBody = [requestToSerialize HTTPBody] || [requestToSerialize HTTPBodyStream];
+
+ // FIXME: Replace this respondsToSelector check with a HAS macro once rdar://83857142 has been put in a build and the bots are updated.
+ bool hasProtocolProperties = [requestToSerialize respondsToSelector:@selector(_allProtocolProperties)] && [requestToSerialize _allProtocolProperties];
+
+ if (hasHTTPBody || hasProtocolProperties) {
auto mutableRequest = adoptNS([requestToSerialize mutableCopy]);
[mutableRequest setHTTPBody:nil];
[mutableRequest setHTTPBodyStream:nil];
+ // FIXME: Replace this respondsToSelector check with a HAS macro once rdar://83855325 has been put in a build and the bots are updated.
+ if ([mutableRequest respondsToSelector:@selector(_removeAllProtocolProperties)])
+ [mutableRequest _removeAllProtocolProperties];
requestToSerialize = WTFMove(mutableRequest);
}
Modified: trunk/Tools/ChangeLog (284916 => 284917)
--- trunk/Tools/ChangeLog 2021-10-27 01:07:57 UTC (rev 284916)
+++ trunk/Tools/ChangeLog 2021-10-27 03:11:35 UTC (rev 284917)
@@ -1,3 +1,14 @@
+2021-10-26 Alex Christensen <[email protected]>
+
+ Remove properties set by NSURLProtocol on NSURLRequest before serializing
+ https://bugs.webkit.org/show_bug.cgi?id=232332
+ <rdar://79227845>
+
+ Reviewed by Geoff Garen.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm:
+ (TestWebKitAPI::TEST):
+
2021-10-26 Roy Reapor <[email protected]>
webkitpy/autoinstalled/pyobjc_frameworks.py should not autoinstall frameworks if they can be imported without exceptions
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm (284916 => 284917)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm 2021-10-27 01:07:57 UTC (rev 284916)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/LoadInvalidURLRequest.mm 2021-10-27 03:11:35 UTC (rev 284917)
@@ -137,5 +137,26 @@
[webView _test_waitForDidFinishNavigation];
}
+TEST(WebKit, LoadNSURLRequestWithProtocolProperties)
+{
+ auto request = adoptNS([[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"test:///"]]);
+
+ // FIXME: Replace this with a HAS macro once rdar://83857142 has been put in a build and the bots are updated.
+ bool hasRadar83857142 = [request respondsToSelector:@selector(_allProtocolProperties)];
+
+ [NSURLProtocol setProperty:@"world" forKey:@"hello" inRequest:request.get()];
+ auto handler = adoptNS([TestURLSchemeHandler new]);
+ __block bool done = false;
+ handler.get().startURLSchemeTaskHandler = ^(WKWebView *, id<WKURLSchemeTask> task) {
+ EXPECT_EQ(hasRadar83857142, ![NSURLProtocol propertyForKey:@"hello" inRequest:task.request]);
+ done = true;
+ };
+ auto configuration = adoptNS([WKWebViewConfiguration new]);
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"test"];
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
+ [webView loadRequest:request.get()];
+ Util::run(&done);
+}
+
} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes