WebKit Bugzilla
Attachment 368774 Details for
Bug 197397
: Add SPI to set a list of hosts to which to send custom header fields cross-origin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197397-20190502091431.patch (text/plain), 66.87 KB, created by
Alex Christensen
on 2019-05-02 09:14:32 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-05-02 09:14:32 PDT
Size:
66.87 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 244794) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,34 @@ >+2019-05-02 Alex Christensen <achristensen@webkit.org> >+ >+ Add SPI to set a list of hosts to which to send custom header fields cross-origin >+ https://bugs.webkit.org/show_bug.cgi?id=197397 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In r223001 I added the ability to send custom headers, but with a restriction that they will not be sent except to the origin of the main document. >+ We need the ability to specify what origins to send these headers to even if they are not first party requests. >+ We get this information in a list of strings which are the hosts to send the headers to. Some of the strings have an asterisk at the beginning, >+ indicating that the headers are to be sent to all subdomains. >+ >+ I repurposed some ObjC SPI that was never adopted, but I keep testing the C API that was to verify no regression. >+ I also added some new API tests for the new behavior. >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * loader/CustomHeaderFields.cpp: Added. >+ (WebCore::CustomHeaderFields::thirdPartyDomainsMatch const): >+ * loader/CustomHeaderFields.h: Added. >+ (WebCore::CustomHeaderFields::encode const): >+ (WebCore::CustomHeaderFields::decode): >+ * loader/DocumentLoader.cpp: >+ (WebCore::DocumentLoader::setCustomHeaderFields): Deleted. >+ * loader/DocumentLoader.h: >+ (WebCore::DocumentLoader::setCustomHeaderFields): >+ (WebCore::DocumentLoader::customHeaderFields const): >+ (WebCore::DocumentLoader::customHeaderFields): Deleted. >+ * loader/cache/CachedResourceLoader.cpp: >+ (WebCore::CachedResourceLoader::requestResource): >+ > 2019-04-30 Alex Christensen <achristensen@webkit.org> > > Add WKContentRuleList ping resource-type >Index: Source/WebCore/Headers.cmake >=================================================================== >--- Source/WebCore/Headers.cmake (revision 244759) >+++ Source/WebCore/Headers.cmake (working copy) >@@ -653,6 +653,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS > loader/CookieJar.h > loader/CrossOriginAccessControl.h > loader/CrossOriginPreflightResultCache.h >+ loader/CustomHeaderFields.h > loader/DocumentLoader.h > loader/DocumentWriter.h > loader/EmptyClients.h >Index: Source/WebCore/Sources.txt >=================================================================== >--- Source/WebCore/Sources.txt (revision 244759) >+++ Source/WebCore/Sources.txt (working copy) >@@ -1361,6 +1361,7 @@ loader/CookieJar.cpp > loader/CrossOriginAccessControl.cpp > loader/CrossOriginPreflightChecker.cpp > loader/CrossOriginPreflightResultCache.cpp >+loader/CustomHeaderFields.cpp > loader/DocumentLoader.cpp > loader/DocumentThreadableLoader.cpp > loader/DocumentWriter.cpp >Index: Source/WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebCore/WebCore.xcodeproj/project.pbxproj (revision 244759) >+++ Source/WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -1873,6 +1873,7 @@ > 5C4304B0191AC908000E2BC0 /* EXTShaderTextureLOD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4304AD191AC908000E2BC0 /* EXTShaderTextureLOD.cpp */; }; > 5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; }; > 5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; }; >+ 5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 5C7C88D81D0F1F4A009D2F6D /* SocketProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C88D71D0F1F2B009D2F6D /* SocketProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 5C9C2DB52241A67B00996B0B /* ContentRuleListResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9C2DB32241A67300996B0B /* ContentRuleListResults.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 5C9EF2F321F06190003BDC56 /* StorageSessionProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9EF2F221F06171003BDC56 /* StorageSessionProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -8827,6 +8828,8 @@ > 5C5381B11D87D45700E2EBE6 /* URLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSearchParams.h; sourceTree = "<group>"; }; > 5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; }; > 5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSURLSearchParams.h; sourceTree = "<group>"; }; >+ 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomHeaderFields.h; sourceTree = "<group>"; }; >+ 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomHeaderFields.cpp; sourceTree = "<group>"; }; > 5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleImpl.cpp; sourceTree = "<group>"; }; > 5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; }; > 5C688AA21D38126F000B54FA /* SocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketProvider.cpp; sourceTree = "<group>"; }; >@@ -24998,6 +25001,8 @@ > 41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */, > E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */, > E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */, >+ 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */, >+ 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */, > 93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */, > 656D371E0ADBA5DE00A4554D /* DocumentLoader.h */, > 0B9056150F2578BE0095FF6A /* DocumentThreadableLoader.cpp */, >@@ -28663,6 +28668,7 @@ > 93D437A01D57B19A00AB85EA /* CustomElementReactionQueue.h in Headers */, > 9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */, > 62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */, >+ 5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */, > 4B1E13E721790D660042CF98 /* CustomPaintCanvas.h in Headers */, > 4B7AE4932177B56F00C59959 /* CustomPaintImage.h in Headers */, > A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */, >Index: Source/WebCore/loader/CustomHeaderFields.cpp >=================================================================== >--- Source/WebCore/loader/CustomHeaderFields.cpp (nonexistent) >+++ Source/WebCore/loader/CustomHeaderFields.cpp (working copy) >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2019 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. >+ */ >+ >+#include "config.h" >+#include "CustomHeaderFields.h" >+ >+#include "HTTPHeaderField.h" >+#include "RegistrableDomain.h" >+ >+namespace WebCore { >+ >+bool CustomHeaderFields::thirdPartyDomainsMatch(const URL& url) const >+{ >+ if (thirdPartyDomains.isEmpty()) >+ return false; >+ >+ auto registrableDomainLength = RegistrableDomain(url).string().length(); >+ for (const auto& domainOrPattern : thirdPartyDomains) { >+ if (domainOrPattern == url.host()) >+ return true; >+ if (domainOrPattern.length() > 2 >+ && domainOrPattern[0] == '*' >+ && domainOrPattern[1] == '.' >+ && domainOrPattern.length() > registrableDomainLength >+ && url.host().endsWith(StringView(domainOrPattern).substring(1))) >+ return true; >+ } >+ >+ return false; >+} >+ >+} >Index: Source/WebCore/loader/CustomHeaderFields.h >=================================================================== >--- Source/WebCore/loader/CustomHeaderFields.h (nonexistent) >+++ Source/WebCore/loader/CustomHeaderFields.h (working copy) >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2019 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. ``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 >+ * 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 >+ >+#include "HTTPHeaderField.h" >+#include <wtf/Vector.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+struct WEBCORE_EXPORT CustomHeaderFields { >+ Vector<HTTPHeaderField> fields; >+ Vector<String> thirdPartyDomains; >+ >+ bool thirdPartyDomainsMatch(const URL&) const; >+ >+ template<class Encoder> void encode(Encoder&) const; >+ template<class Decoder> static Optional<CustomHeaderFields> decode(Decoder&); >+}; >+ >+template<class Encoder> >+void CustomHeaderFields::encode(Encoder& encoder) const >+{ >+ encoder << fields; >+ encoder << thirdPartyDomains; >+} >+ >+template<class Decoder> >+Optional<CustomHeaderFields> CustomHeaderFields::decode(Decoder& decoder) >+{ >+ Optional<Vector<HTTPHeaderField>> fields; >+ decoder >> fields; >+ if (!fields) >+ return WTF::nullopt; >+ >+ Optional<Vector<String>> thirdPartyDomains; >+ decoder >> thirdPartyDomains; >+ if (!thirdPartyDomains) >+ return WTF::nullopt; >+ >+ return {{ WTFMove(*fields), WTFMove(*thirdPartyDomains) }}; >+} >+ >+} // namespace WebCore >Index: Source/WebCore/loader/DocumentLoader.cpp >=================================================================== >--- Source/WebCore/loader/DocumentLoader.cpp (revision 244759) >+++ Source/WebCore/loader/DocumentLoader.cpp (working copy) >@@ -38,6 +38,7 @@ > #include "CachedResourceLoader.h" > #include "ContentExtensionError.h" > #include "ContentSecurityPolicy.h" >+#include "CustomHeaderFields.h" > #include "DOMWindow.h" > #include "Document.h" > #include "DocumentParser.h" >@@ -53,7 +54,6 @@ > #include "FrameTree.h" > #include "HTMLFormElement.h" > #include "HTMLFrameOwnerElement.h" >-#include "HTTPHeaderField.h" > #include "HTTPHeaderNames.h" > #include "HistoryItem.h" > #include "HistoryController.h" >@@ -1322,11 +1322,6 @@ void DocumentLoader::notifyFinishedLoadi > } > #endif > >-void DocumentLoader::setCustomHeaderFields(Vector<HTTPHeaderField>&& fields) >-{ >- m_customHeaderFields = WTFMove(fields); >-} >- > bool DocumentLoader::isLoadingInAPISense() const > { > // Once a frame has loaded, we no longer need to consider subresources, >Index: Source/WebCore/loader/DocumentLoader.h >=================================================================== >--- Source/WebCore/loader/DocumentLoader.h (revision 244759) >+++ Source/WebCore/loader/DocumentLoader.h (working copy) >@@ -76,10 +76,10 @@ class ArchiveResourceCollection; > class CachedRawResource; > class CachedResourceLoader; > class ContentFilter; >+struct CustomHeaderFields; > class FormState; > class Frame; > class FrameLoader; >-class HTTPHeaderField; > class IconLoader; > class Page; > class PreviewConverter; >@@ -371,8 +371,8 @@ public: > void finishedLoadingApplicationManifest(ApplicationManifestLoader&); > #endif > >- WEBCORE_EXPORT void setCustomHeaderFields(Vector<HTTPHeaderField>&& fields); >- const Vector<HTTPHeaderField>& customHeaderFields() { return m_customHeaderFields; } >+ void setCustomHeaderFields(Vector<CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); } >+ const Vector<CustomHeaderFields>& customHeaderFields() const { return m_customHeaderFields; } > > void setAllowsWebArchiveForMainFrame(bool allowsWebArchiveForMainFrame) { m_allowsWebArchiveForMainFrame = allowsWebArchiveForMainFrame; } > bool allowsWebArchiveForMainFrame() const { return m_allowsWebArchiveForMainFrame; } >@@ -564,7 +564,7 @@ private: > HashMap<std::unique_ptr<ApplicationManifestLoader>, uint64_t> m_applicationManifestLoaders; > #endif > >- Vector<HTTPHeaderField> m_customHeaderFields; >+ Vector<CustomHeaderFields> m_customHeaderFields; > > bool m_subresourceLoadersArePageCacheAcceptable { false }; > ShouldOpenExternalURLsPolicy m_shouldOpenExternalURLsPolicy { ShouldOpenExternalURLsPolicy::ShouldNotAllow }; >Index: Source/WebCore/loader/cache/CachedResourceLoader.cpp >=================================================================== >--- Source/WebCore/loader/cache/CachedResourceLoader.cpp (revision 244759) >+++ Source/WebCore/loader/cache/CachedResourceLoader.cpp (working copy) >@@ -43,6 +43,7 @@ > #include "ContentRuleListResults.h" > #include "ContentSecurityPolicy.h" > #include "CrossOriginAccessControl.h" >+#include "CustomHeaderFields.h" > #include "DOMWindow.h" > #include "DiagnosticLoggingClient.h" > #include "DiagnosticLoggingKeys.h" >@@ -858,9 +859,11 @@ ResourceErrorOr<CachedResourceHandle<Cac > sameOriginRequest = document()->topDocument().securityOrigin().isSameSchemeHostPort(requestedOrigin.get()) > && document()->securityOrigin().isSameSchemeHostPort(requestedOrigin.get()); > } >- if (sameOriginRequest) { >- for (auto& field : m_documentLoader->customHeaderFields()) >- request.resourceRequest().setHTTPHeaderField(field.name(), field.value()); >+ for (auto& fields : m_documentLoader->customHeaderFields()) { >+ if (sameOriginRequest || fields.thirdPartyDomainsMatch(url)) { >+ for (auto& field : fields.fields) >+ request.resourceRequest().setHTTPHeaderField(field.name(), field.value()); >+ } > } > } > >Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 244810) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,50 @@ >+2019-05-02 Alex Christensen <achristensen@webkit.org> >+ >+ Add SPI to set a list of hosts to which to send custom header fields cross-origin >+ https://bugs.webkit.org/show_bug.cgi?id=197397 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Shared/API/APIObject.h: >+ * Shared/Cocoa/APIObject.mm: >+ (API::Object::newObject): >+ * Shared/WebsitePoliciesData.cpp: >+ (WebKit::WebsitePoliciesData::decode): >+ * Shared/WebsitePoliciesData.h: >+ * SourcesCocoa.txt: >+ * UIProcess/API/APICustomHeaderFields.h: Added. >+ * UIProcess/API/APIWebsitePolicies.cpp: >+ (API::WebsitePolicies::WebsitePolicies): >+ (API::WebsitePolicies::copy const): >+ (API::WebsitePolicies::data): >+ * UIProcess/API/APIWebsitePolicies.h: >+ * UIProcess/API/C/WKWebsitePolicies.cpp: >+ (WKWebsitePoliciesCopyCustomHeaderFields): >+ (WKWebsitePoliciesSetCustomHeaderFields): >+ * UIProcess/API/Cocoa/WKWebpagePreferences.mm: >+ (-[WKWebpagePreferences _customHeaderFields]): >+ (-[WKWebpagePreferences _setCustomHeaderFields:]): >+ * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h: >+ * UIProcess/API/Cocoa/_WKCustomHeaderFields.h: Added. >+ * UIProcess/API/Cocoa/_WKCustomHeaderFields.mm: Added. >+ (-[_WKCustomHeaderFields init]): >+ (-[_WKCustomHeaderFields dealloc]): >+ (-[_WKCustomHeaderFields fields]): >+ (-[_WKCustomHeaderFields setFields:]): >+ (-[_WKCustomHeaderFields thirdPartyDomains]): >+ (-[_WKCustomHeaderFields setThirdPartyDomains:]): >+ (-[_WKCustomHeaderFields _apiObject]): >+ * UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h: Added. >+ * UIProcess/API/Cocoa/_WKWebsitePolicies.h: >+ * UIProcess/API/Cocoa/_WKWebsitePolicies.mm: >+ (-[_WKWebsitePolicies customHeaderFields]): Deleted. >+ (-[_WKWebsitePolicies setCustomHeaderFields:]): Deleted. >+ * UIProcess/Cocoa/WebViewImpl.h: >+ * UIProcess/Cocoa/WebViewImpl.mm: >+ (WebKit::WebViewImpl::takeFocus): >+ (WebKit::WebViewImpl::accessibilityAttributeValue): >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2019-04-30 Chris Dumez <cdumez@apple.com> > > Regression(PSON) URL scheme handlers can no longer respond asynchronously >Index: Source/WebKit/SourcesCocoa.txt >=================================================================== >--- Source/WebKit/SourcesCocoa.txt (revision 244759) >+++ Source/WebKit/SourcesCocoa.txt (working copy) >@@ -242,6 +242,7 @@ UIProcess/API/Cocoa/_WKAutomationSession > UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm > UIProcess/API/Cocoa/_WKContentRuleListAction.mm > UIProcess/API/Cocoa/_WKContextMenuElementInfo.mm >+UIProcess/API/Cocoa/_WKCustomHeaderFields.mm > UIProcess/API/Cocoa/_WKDownload.mm > UIProcess/API/Cocoa/_WKElementAction.mm > UIProcess/API/Cocoa/_WKErrorRecoveryAttempting.mm >Index: Source/WebKit/Platform/spi/ios/UIKitSPI.h >=================================================================== >--- Source/WebKit/Platform/spi/ios/UIKitSPI.h (revision 244759) >+++ Source/WebKit/Platform/spi/ios/UIKitSPI.h (working copy) >@@ -204,17 +204,6 @@ typedef enum { > @end > > typedef enum { >- UIFontTraitPlain = 0, >- UIFontTraitItalic = 1 << 0, >- UIFontTraitBold = 1 << 1, >-} UIFontTrait; >- >-@interface UIFont () >-+ (UIFont *)fontWithFamilyName:(NSString *)familyName traits:(UIFontTrait)traits size:(CGFloat)fontSize; >-- (UIFontTrait)traits; >-@end >- >-typedef enum { > UIAllCorners = 0xFF, > } UIRectCorners; > >@@ -444,12 +433,6 @@ typedef enum { > @property (readonly) NSString *_hostApplicationBundleIdentifier; > @end > >-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 >-@interface NSURL () >-@property (nonatomic, copy, setter=_setTitle:) NSString *_title; >-@end >-#endif >- > @protocol UIViewControllerContextTransitioningEx <UIViewControllerContextTransitioning> > - (void)__runAlongsideAnimations; > - (void)_interactivityDidChange:(BOOL)isInteractive; >@@ -1088,7 +1071,7 @@ typedef NS_OPTIONS(NSInteger, UIWKDocume > @property (nonatomic, readonly) NSInteger _gsModifierFlags; > @end > >-@interface UIColor (IPI) >+@interface UIColor (WebKitIPI) > + (UIColor *)insertionPointColor; > @end > >Index: Source/WebKit/Shared/WebsitePoliciesData.cpp >=================================================================== >--- Source/WebKit/Shared/WebsitePoliciesData.cpp (revision 244759) >+++ Source/WebKit/Shared/WebsitePoliciesData.cpp (working copy) >@@ -28,6 +28,7 @@ > > #include "ArgumentCoders.h" > #include "WebProcess.h" >+#include <WebCore/CustomHeaderFields.h> > #include <WebCore/DocumentLoader.h> > #include <WebCore/Frame.h> > #include <WebCore/Page.h> >@@ -77,7 +78,7 @@ Optional<WebsitePoliciesData> WebsitePol > if (!allowedAutoplayQuirks) > return WTF::nullopt; > >- Optional<Vector<WebCore::HTTPHeaderField>> customHeaderFields; >+ Optional<Vector<WebCore::CustomHeaderFields>> customHeaderFields; > decoder >> customHeaderFields; > if (!customHeaderFields) > return WTF::nullopt; >Index: Source/WebKit/Shared/WebsitePoliciesData.h >=================================================================== >--- Source/WebKit/Shared/WebsitePoliciesData.h (revision 244759) >+++ Source/WebKit/Shared/WebsitePoliciesData.h (working copy) >@@ -32,8 +32,8 @@ > #include "WebsiteMetaViewportPolicy.h" > #include "WebsitePopUpPolicy.h" > #include "WebsiteSimulatedMouseEventsDispatchPolicy.h" >+#include <WebCore/CustomHeaderFields.h> > #include <WebCore/DeviceOrientationOrMotionPermissionState.h> >-#include <WebCore/HTTPHeaderField.h> > #include <wtf/OptionSet.h> > > namespace IPC { >@@ -56,7 +56,7 @@ struct WebsitePoliciesData { > #if ENABLE(DEVICE_ORIENTATION) > WebCore::DeviceOrientationOrMotionPermissionState deviceOrientationAndMotionAccessState; > #endif >- Vector<WebCore::HTTPHeaderField> customHeaderFields; >+ Vector<WebCore::CustomHeaderFields> customHeaderFields; > WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default }; > Optional<WebsiteDataStoreParameters> websiteDataStoreParameters; > String customUserAgent; >Index: Source/WebKit/Shared/API/APIObject.h >=================================================================== >--- Source/WebKit/Shared/API/APIObject.h (revision 244759) >+++ Source/WebKit/Shared/API/APIObject.h (working copy) >@@ -111,6 +111,7 @@ public: > ContentRuleListStore, > ContextMenuListener, > CookieManager, >+ CustomHeaderFields, > InternalDebugFeature, > Download, > ExperimentalFeature, >Index: Source/WebKit/Shared/Cocoa/APIObject.mm >=================================================================== >--- Source/WebKit/Shared/Cocoa/APIObject.mm (revision 244759) >+++ Source/WebKit/Shared/Cocoa/APIObject.mm (working copy) >@@ -70,6 +70,7 @@ > #import "_WKAttachmentInternal.h" > #import "_WKAutomationSessionInternal.h" > #import "_WKContentRuleListActionInternal.h" >+#import "_WKCustomHeaderFieldsInternal.h" > #import "_WKDownloadInternal.h" > #import "_WKExperimentalFeatureInternal.h" > #import "_WKFrameHandleInternal.h" >@@ -312,6 +313,10 @@ void* Object::newObject(size_t size, Typ > wrapper = [WKContentRuleListStore alloc]; > break; > >+ case Type::CustomHeaderFields: >+ wrapper = [_WKCustomHeaderFields alloc]; >+ break; >+ > case Type::UserContentWorld: > wrapper = [_WKUserContentWorld alloc]; > break; >Index: Source/WebKit/UIProcess/API/APICustomHeaderFields.h >=================================================================== >--- Source/WebKit/UIProcess/API/APICustomHeaderFields.h (nonexistent) >+++ Source/WebKit/UIProcess/API/APICustomHeaderFields.h (working copy) >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2019 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 >+ >+#include "APIObject.h" >+#include <WebCore/CustomHeaderFields.h> >+ >+namespace API { >+ >+class CustomHeaderFields final : public ObjectImpl<Object::Type::CustomHeaderFields> { >+public: >+ template<typename... Args> static Ref<CustomHeaderFields> create(Args&&... args) >+ { >+ return adoptRef(*new CustomHeaderFields(std::forward<Args>(args)...)); >+ } >+ >+ CustomHeaderFields() = default; >+ >+ const Vector<WebCore::HTTPHeaderField>& fields() const { return m_fields.fields; } >+ void setFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_fields.fields = WTFMove(fields); } >+ >+ const Vector<WTF::String> thirdPartyDomains() const { return m_fields.thirdPartyDomains; } >+ void setThirdPartyDomains(Vector<WTF::String>&& domains) { m_fields.thirdPartyDomains = WTFMove(domains); } >+ >+ const WebCore::CustomHeaderFields& coreFields() const { return m_fields; } >+ >+private: >+ CustomHeaderFields(const WebCore::CustomHeaderFields& fields) >+ : m_fields(fields) { } >+ >+ WebCore::CustomHeaderFields m_fields; >+}; >+ >+} // namespace API >Index: Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp >=================================================================== >--- Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (revision 244759) >+++ Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (working copy) >@@ -33,10 +33,11 @@ namespace API { > > WebsitePolicies::WebsitePolicies() = default; > >-WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebsiteDataStore>&& websiteDataStore) >+WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& legacyCustomHeaderFields, Vector<WebCore::CustomHeaderFields>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebsiteDataStore>&& websiteDataStore) > : m_contentBlockersEnabled(contentBlockersEnabled) > , m_allowedAutoplayQuirks(allowedAutoplayQuirks) > , m_autoplayPolicy(autoplayPolicy) >+ , m_legacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields)) > , m_customHeaderFields(WTFMove(customHeaderFields)) > , m_popUpPolicy(popUpPolicy) > , m_websiteDataStore(WTFMove(websiteDataStore)) >@@ -60,11 +61,19 @@ Ref<WebsitePolicies> WebsitePolicies::co > policies->setMetaViewportPolicy(m_metaViewportPolicy); > policies->setMediaSourcePolicy(m_mediaSourcePolicy); > policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy); >- Vector<WebCore::HTTPHeaderField> customHeaderFields; >+ >+ Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields; >+ legacyCustomHeaderFields.reserveInitialCapacity(m_legacyCustomHeaderFields.size()); >+ for (auto& field : m_legacyCustomHeaderFields) >+ legacyCustomHeaderFields.uncheckedAppend(field); >+ policies->setLegacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields)); >+ >+ Vector<WebCore::CustomHeaderFields> customHeaderFields; > customHeaderFields.reserveInitialCapacity(m_customHeaderFields.size()); > for (auto& field : m_customHeaderFields) >- customHeaderFields.append(WebCore::HTTPHeaderField(field)); >+ customHeaderFields.uncheckedAppend(field); > policies->setCustomHeaderFields(WTFMove(customHeaderFields)); >+ > return policies; > } > >@@ -79,6 +88,13 @@ void WebsitePolicies::setWebsiteDataStor > > WebKit::WebsitePoliciesData WebsitePolicies::data() > { >+ Vector<WebCore::CustomHeaderFields> customHeaderFields; >+ customHeaderFields.reserveInitialCapacity(this->customHeaderFields().size() + 1); >+ for (auto& field : this->customHeaderFields()) >+ customHeaderFields.uncheckedAppend(field); >+ if (legacyCustomHeaderFields().size()) >+ customHeaderFields.uncheckedAppend({ legacyCustomHeaderFields(), { }}); >+ > return { > contentBlockersEnabled(), > allowedAutoplayQuirks(), >@@ -86,7 +102,7 @@ WebKit::WebsitePoliciesData WebsitePolic > #if ENABLE(DEVICE_ORIENTATION) > deviceOrientationAndMotionAccessState(), > #endif >- customHeaderFields(), >+ WTFMove(customHeaderFields), > popUpPolicy(), > m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->websiteDataStore().parameters() } : WTF::nullopt, > m_customUserAgent, >Index: Source/WebKit/UIProcess/API/APIWebsitePolicies.h >=================================================================== >--- Source/WebKit/UIProcess/API/APIWebsitePolicies.h (revision 244759) >+++ Source/WebKit/UIProcess/API/APIWebsitePolicies.h (working copy) >@@ -33,6 +33,7 @@ > #include "WebsiteMetaViewportPolicy.h" > #include "WebsitePopUpPolicy.h" > #include "WebsiteSimulatedMouseEventsDispatchPolicy.h" >+#include <WebCore/CustomHeaderFields.h> > #include <WebCore/DeviceOrientationOrMotionPermissionState.h> > #include <WebCore/HTTPHeaderField.h> > #include <wtf/OptionSet.h> >@@ -68,9 +69,11 @@ public: > void setDeviceOrientationAndMotionAccessState(WebCore::DeviceOrientationOrMotionPermissionState state) { m_deviceOrientationAndMotionAccessState = state; } > #endif > >- const Vector<WebCore::HTTPHeaderField>& customHeaderFields() const { return m_customHeaderFields; } >- Vector<WebCore::HTTPHeaderField>&& takeCustomHeaderFields() { return WTFMove(m_customHeaderFields); } >- void setCustomHeaderFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_customHeaderFields = WTFMove(fields); } >+ const Vector<WebCore::HTTPHeaderField>& legacyCustomHeaderFields() const { return m_legacyCustomHeaderFields; } >+ void setLegacyCustomHeaderFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_legacyCustomHeaderFields = WTFMove(fields); } >+ >+ const Vector<WebCore::CustomHeaderFields>& customHeaderFields() const { return m_customHeaderFields; } >+ void setCustomHeaderFields(Vector<WebCore::CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); } > > WebKit::WebsitePopUpPolicy popUpPolicy() const { return m_popUpPolicy; } > void setPopUpPolicy(WebKit::WebsitePopUpPolicy policy) { m_popUpPolicy = policy; } >@@ -102,7 +105,7 @@ public: > void setSimulatedMouseEventsDispatchPolicy(WebKit::WebsiteSimulatedMouseEventsDispatchPolicy policy) { m_simulatedMouseEventsDispatchPolicy = policy; } > > private: >- WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&); >+ WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&); > > bool m_contentBlockersEnabled { true }; > OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks; >@@ -110,7 +113,8 @@ private: > #if ENABLE(DEVICE_ORIENTATION) > WebCore::DeviceOrientationOrMotionPermissionState m_deviceOrientationAndMotionAccessState { WebCore::DeviceOrientationOrMotionPermissionState::Prompt }; > #endif >- Vector<WebCore::HTTPHeaderField> m_customHeaderFields; >+ Vector<WebCore::HTTPHeaderField> m_legacyCustomHeaderFields; >+ Vector<WebCore::CustomHeaderFields> m_customHeaderFields; > WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default }; > RefPtr<WebsiteDataStore> m_websiteDataStore; > WTF::String m_customUserAgent; >Index: Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp >=================================================================== >--- Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp (revision 244759) >+++ Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp (working copy) >@@ -59,7 +59,7 @@ bool WKWebsitePoliciesGetContentBlockers > WK_EXPORT WKDictionaryRef WKWebsitePoliciesCopyCustomHeaderFields(WKWebsitePoliciesRef websitePolicies) > { > HashMap<WTF::String, RefPtr<API::Object>> fields; >- for (const auto& field : toImpl(websitePolicies)->customHeaderFields()) >+ for (const auto& field : toImpl(websitePolicies)->legacyCustomHeaderFields()) > fields.add(field.name(), API::String::create(field.value())); > return toAPI(API::Dictionary::create(WTFMove(fields)).ptr()); > } >@@ -76,7 +76,7 @@ WK_EXPORT void WKWebsitePoliciesSetCusto > if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-")) > fields.uncheckedAppend(WTFMove(*field)); > } >- toImpl(websitePolicies)->setCustomHeaderFields(WTFMove(fields)); >+ toImpl(websitePolicies)->setLegacyCustomHeaderFields(WTFMove(fields)); > } > > void WKWebsitePoliciesSetAllowedAutoplayQuirks(WKWebsitePoliciesRef websitePolicies, WKWebsiteAutoplayQuirk allowedQuirks) >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (revision 244759) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (working copy) >@@ -26,9 +26,11 @@ > #import "config.h" > #import "WKWebpagePreferences.h" > >+#import "APICustomHeaderFields.h" > #import "WKWebpagePreferencesInternal.h" > #import "WKWebsiteDataStoreInternal.h" > #import "WebCompatibilityMode.h" >+#import "_WKCustomHeaderFieldsInternal.h" > #import "_WKWebsitePoliciesInternal.h" > #import <wtf/RetainPtr.h> > >@@ -214,26 +216,22 @@ - (_WKWebsitePopUpPolicy)_popUpPolicy > } > } > >-- (NSDictionary<NSString *, NSString *> *)_customHeaderFields >+- (NSArray<_WKCustomHeaderFields *> *)_customHeaderFields > { > const auto& fields = _websitePolicies->customHeaderFields(); >- auto dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:fields.size()]); >+ NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:fields.size()] autorelease]; > for (const auto& field : fields) >- [dictionary setObject:field.value() forKey:field.name()]; >- return dictionary.autorelease(); >+ [array addObject:wrapper(API::CustomHeaderFields::create(field))]; >+ return array; > } > >-- (void)_setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields >+- (void)_setCustomHeaderFields:(NSArray<_WKCustomHeaderFields *> *)fields > { >- Vector<WebCore::HTTPHeaderField> parsedFields; >- parsedFields.reserveInitialCapacity(fields.count); >- >- for (NSString *name in fields) { >- auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]); >- if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-")) >- parsedFields.uncheckedAppend(WTFMove(*field)); >- } >- _websitePolicies->setCustomHeaderFields(WTFMove(parsedFields)); >+ Vector<WebCore::CustomHeaderFields> vector; >+ vector.reserveInitialCapacity(fields.count); >+ for (_WKCustomHeaderFields *element in fields) >+ vector.uncheckedAppend(static_cast<API::CustomHeaderFields&>([element _apiObject]).coreFields()); >+ _websitePolicies->setCustomHeaderFields(WTFMove(vector)); > } > > - (WKWebsiteDataStore *)_websiteDataStore >Index: Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (revision 244759) >+++ Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (working copy) >@@ -55,12 +55,14 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsit > _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny, > } WK_API_AVAILABLE(macos(10.14), ios(12.0)); > >+@class _WKCustomHeaderFields; >+ > @interface WKWebpagePreferences (WKPrivate) > > @property (nonatomic, setter=_setContentBlockersEnabled:) BOOL _contentBlockersEnabled; > @property (nonatomic, setter=_setAllowedAutoplayQuirks:) _WKWebsiteAutoplayQuirk _allowedAutoplayQuirks; > @property (nonatomic, setter=_setAutoplayPolicy:) _WKWebsiteAutoplayPolicy _autoplayPolicy; >-@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSDictionary<NSString *, NSString *> *_customHeaderFields; >+@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSArray<_WKCustomHeaderFields *> *_customHeaderFields; > @property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy; > @property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore; > @property (nonatomic, copy, setter=_setCustomUserAgent:) NSString *_customUserAgent; >Index: Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h (nonexistent) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h (working copy) >@@ -0,0 +1,38 @@ >+/* >+ * Copyright (C) 2015 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 <WebKit/WKFoundation.h> >+ >+NS_ASSUME_NONNULL_BEGIN >+ >+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)) >+@interface _WKCustomHeaderFields : NSObject >+ >+@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *fields; >+@property (nonatomic, copy) NSArray<NSString *> *thirdPartyDomains; >+ >+@end >+ >+NS_ASSUME_NONNULL_END >Index: Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm (nonexistent) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm (working copy) >@@ -0,0 +1,92 @@ >+/* >+ * Copyright (C) 2015 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 "_WKCustomHeaderFields.h" >+ >+#import "_WKCustomHeaderFieldsInternal.h" >+#import <wtf/BlockPtr.h> >+ >+@implementation _WKCustomHeaderFields >+ >+- (instancetype)init >+{ >+ if (!(self = [super init])) >+ return nil; >+ >+ API::Object::constructInWrapper<API::CustomHeaderFields>(self); >+ return self; >+} >+ >+- (void)dealloc >+{ >+ _fields->API::CustomHeaderFields::~CustomHeaderFields(); >+ [super dealloc]; >+} >+ >+- (NSDictionary<NSString *, NSString *> *)fields >+{ >+ auto& vector = _fields->fields(); >+ NSMutableDictionary<NSString *, NSString *> *dictionary = [[[NSMutableDictionary alloc] initWithCapacity:vector.size()] autorelease]; >+ for (auto& field : vector) >+ [dictionary setObject:field.value() forKey:field.name()]; >+ return dictionary; >+} >+ >+- (void)setFields:(NSDictionary<NSString *, NSString *> *)fields >+{ >+ Vector<WebCore::HTTPHeaderField> vector; >+ vector.reserveInitialCapacity(fields.count); >+ [fields enumerateKeysAndObjectsUsingBlock:makeBlockPtr([&](id key, id value, BOOL* stop) { >+ if (auto field = WebCore::HTTPHeaderField::create((NSString *)key, (NSString *)value); field && startsWithLettersIgnoringASCIICase(field->name(), "x-")) >+ vector.uncheckedAppend(WTFMove(*field)); >+ }).get()]; >+ _fields->setFields(WTFMove(vector)); >+} >+ >+- (NSArray<NSString *> *)thirdPartyDomains >+{ >+ auto& domains = _fields->thirdPartyDomains(); >+ NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:domains.size()] autorelease]; >+ for (auto& domain : domains) >+ [array addObject:domain]; >+ return array; >+} >+ >+- (void)setThirdPartyDomains:(NSArray<NSString *> *)thirdPartyDomains >+{ >+ Vector<String> domains; >+ domains.reserveInitialCapacity(thirdPartyDomains.count); >+ for (NSString *domain in thirdPartyDomains) >+ domains.uncheckedAppend(domain); >+ _fields->setThirdPartyDomains(WTFMove(domains)); >+} >+ >+- (API::Object&)_apiObject >+{ >+ return *_fields; >+} >+ >+@end >Index: Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h (nonexistent) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h (working copy) >@@ -0,0 +1,42 @@ >+/* >+ * Copyright (C) 2019 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 "APICustomHeaderFields.h" >+#import "WKObject.h" >+#import "_WKCustomHeaderFields.h" >+ >+namespace WebKit { >+ >+template<> struct WrapperTraits<API::CustomHeaderFields> { >+ using WrapperClass = _WKCustomHeaderFields; >+}; >+ >+} >+ >+@interface _WKCustomHeaderFields () <WKObject> { >+@package >+ API::ObjectStorage<API::CustomHeaderFields> _fields; >+} >+@end >Index: Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (revision 244759) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (working copy) >@@ -34,7 +34,6 @@ WK_CLASS_AVAILABLE(macos(10.12.3), ios(1 > @property (nonatomic) BOOL contentBlockersEnabled; > @property (nonatomic) _WKWebsiteAutoplayQuirk allowedAutoplayQuirks WK_API_AVAILABLE(macos(10.13), ios(11.0)); > @property (nonatomic) _WKWebsiteAutoplayPolicy autoplayPolicy WK_API_AVAILABLE(macos(10.13), ios(11.0)); >-@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *customHeaderFields WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); > @property (nonatomic) _WKWebsitePopUpPolicy popUpPolicy WK_API_AVAILABLE(macos(10.14), ios(12.0)); > @property (nonatomic, strong) WKWebsiteDataStore *websiteDataStore WK_API_AVAILABLE(macos(10.13.4), ios(11.3)); > @property (nonatomic, copy) NSString *customUserAgent WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); >Index: Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm >=================================================================== >--- Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (revision 244759) >+++ Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (working copy) >@@ -95,16 +95,6 @@ - (_WKWebsitePopUpPolicy)popUpPolicy > return [_webpagePreferences _popUpPolicy]; > } > >-- (NSDictionary<NSString *, NSString *> *)customHeaderFields >-{ >- return [_webpagePreferences _customHeaderFields]; >-} >- >-- (void)setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields >-{ >- [_webpagePreferences _setCustomHeaderFields:fields]; >-} >- > - (WKWebsiteDataStore *)websiteDataStore > { > return [_webpagePreferences _websiteDataStore]; >Index: Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >=================================================================== >--- Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (revision 244759) >+++ Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (working copy) >@@ -140,6 +140,7 @@ class WebEditCommandProxy; > class WebFrameProxy; > class WebPageProxy; > class WebProcessPool; >+class WebProcessProxy; > struct ColorSpaceData; > struct WebHitTestResultData; > >Index: Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >=================================================================== >--- Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (revision 244759) >+++ Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (working copy) >@@ -84,6 +84,7 @@ > #import <WebCore/DragData.h> > #import <WebCore/DragItem.h> > #import <WebCore/Editor.h> >+#import <WebCore/FocusDirection.h> > #import <WebCore/FontAttributeChanges.h> > #import <WebCore/FontAttributes.h> > #import <WebCore/KeypressCommand.h> >@@ -1568,7 +1569,7 @@ void WebViewImpl::takeFocus(WebCore::Foc > { > NSView *webView = m_view.getAutoreleased(); > >- if (direction == FocusDirectionForward) { >+ if (direction == WebCore::FocusDirectionForward) { > // Since we're trying to move focus out of m_webView, and because > // m_webView may contain subviews within it, we ask it for the next key > // view of the last view in its key view loop. This makes m_webView >@@ -3610,7 +3611,7 @@ id WebViewImpl::accessibilityAttributeVa > if ([attribute isEqualToString:@"AXConvertRelativeFrame"]) { > if ([parameter isKindOfClass:[NSValue class]]) { > NSRect rect = [(NSValue *)parameter rectValue]; >- return [NSValue valueWithRect:m_pageClient->rootViewToScreen(IntRect(rect))]; >+ return [NSValue valueWithRect:m_pageClient->rootViewToScreen(WebCore::IntRect(rect))]; > } > } > >Index: Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >=================================================================== >--- Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (revision 244759) >+++ Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (working copy) >@@ -102,6 +102,7 @@ > #import <pal/spi/cocoa/DataDetectorsCoreSPI.h> > #import <pal/spi/ios/DataDetectorsUISPI.h> > #import <pal/spi/ios/GraphicsServicesSPI.h> >+#import <pal/spi/ios/UIKitSPI.h> > #import <wtf/Optional.h> > #import <wtf/RetainPtr.h> > #import <wtf/SetForScope.h> >Index: Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm >=================================================================== >--- Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm (revision 244759) >+++ Source/WebKit/UIProcess/ios/WebProcessProxyIOS.mm (working copy) >@@ -30,6 +30,7 @@ > > #import "AccessibilitySupportSPI.h" > #import "WKFullKeyboardAccessWatcher.h" >+#import "WebPageProxy.h" > #import "WebProcessMessages.h" > > namespace WebKit { >Index: Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.h >=================================================================== >--- Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.h (revision 244759) >+++ Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.h (working copy) >@@ -27,6 +27,7 @@ > > #import "WKFormPeripheral.h" > #import <wtf/Forward.h> >+#import <wtf/RetainPtr.h> > > @class WKContentView; > >Index: Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.mm >=================================================================== >--- Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.mm (revision 244759) >+++ Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.mm (working copy) >@@ -28,8 +28,11 @@ > > #if PLATFORM(IOS_FAMILY) > >+#import "UIKitSPI.h" > #import "WKContentView.h" >+#import "WKContentViewInteraction.h" > #import <pal/spi/cocoa/IOKitSPI.h> >+#import <pal/spi/ios/UIKitSPI.h> > #import <wtf/RetainPtr.h> > > @implementation WKFormPeripheralBase { >Index: Source/WebKit/WebKit.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebKit/WebKit.xcodeproj/project.pbxproj (revision 244759) >+++ Source/WebKit/WebKit.xcodeproj/project.pbxproj (working copy) >@@ -1077,6 +1077,7 @@ > 5C5CEC33220912B300D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; }; > 5C5CEC34220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; }; > 5C5CEC35220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; }; >+ 5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 5C7FB47021E97DC5009E3241 /* WebCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7FB46F21E97C0C009E3241 /* WebCookieJar.h */; }; > 5C8BC797218CBB4800813886 /* SafeBrowsing.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5C8BC796218CB58A00813886 /* SafeBrowsing.xcassets */; }; >@@ -3524,6 +3525,10 @@ > 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AuxiliaryProcessMain.cpp; path = Cocoa/AuxiliaryProcessMain.cpp; sourceTree = "<group>"; }; > 5C5CEC382209583200D6BBB0 /* DaemonEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonEntryPoint.h; sourceTree = "<group>"; }; > 5C5CEC392209583200D6BBB0 /* DaemonEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DaemonEntryPoint.mm; sourceTree = "<group>"; }; >+ 5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFieldsInternal.h; sourceTree = "<group>"; }; >+ 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKCustomHeaderFields.mm; sourceTree = "<group>"; }; >+ 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFields.h; sourceTree = "<group>"; }; >+ 5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICustomHeaderFields.h; sourceTree = "<group>"; }; > 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; }; > 5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; }; > 5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImplCocoa.h; sourceTree = "<group>"; }; >@@ -6132,6 +6137,9 @@ > 5C4609E422430E4D009943C2 /* _WKContentRuleListActionInternal.h */, > 1A5704F61BE01FF400874AF1 /* _WKContextMenuElementInfo.h */, > 1A5704F51BE01FF400874AF1 /* _WKContextMenuElementInfo.mm */, >+ 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */, >+ 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */, >+ 5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */, > 83891B681A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h */, > A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */, > A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */, >@@ -7694,6 +7702,7 @@ > 7C3A06A51AAB903E009D74BA /* APIContentRuleListStore.cpp */, > 7C3A06A61AAB903E009D74BA /* APIContentRuleListStore.h */, > 076E884D1A13CADF005E90FC /* APIContextMenuClient.h */, >+ 5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */, > 7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */, > 83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */, > 1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */, >@@ -9005,6 +9014,7 @@ > 5C4609E7224317B4009943C2 /* _WKContentRuleListAction.h in Headers */, > 5C4609E8224317BB009943C2 /* _WKContentRuleListActionInternal.h in Headers */, > 1A5704F81BE01FF400874AF1 /* _WKContextMenuElementInfo.h in Headers */, >+ 5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */, > 83891B691A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h in Headers */, > A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */, > A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */, >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 244762) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2019-05-02 Alex Christensen <achristensen@webkit.org> >+ >+ Add SPI to set a list of hosts to which to send custom header fields cross-origin >+ https://bugs.webkit.org/show_bug.cgi?id=197397 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: >+ (TEST): >+ (expectLegacyHeaders): >+ (expectHeaders): >+ (-[CustomHeaderFieldsDelegate webView:decidePolicyForNavigationAction:preferences:decisionHandler:]): >+ (-[CustomHeaderFieldsDelegate webView:startURLSchemeTask:]): >+ (-[CustomHeaderFieldsDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]): Deleted. >+ > 2019-04-29 Alex Christensen <achristensen@webkit.org> > > <rdar://problem/50299396> Fix internal High Sierra build >Index: Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm >=================================================================== >--- Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (revision 244759) >+++ Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (working copy) >@@ -28,16 +28,19 @@ > #import "PlatformUtilities.h" > #import "TestNavigationDelegate.h" > #import "TestWKWebView.h" >+#import <WebKit/WKMutableDictionary.h> > #import <WebKit/WKNavigationDelegatePrivate.h> > #import <WebKit/WKPagePrivate.h> > #import <WebKit/WKPreferencesPrivate.h> > #import <WebKit/WKPreferencesRefPrivate.h> >+#import <WebKit/WKString.h> > #import <WebKit/WKUIDelegatePrivate.h> > #import <WebKit/WKURLSchemeTaskPrivate.h> > #import <WebKit/WKUserContentControllerPrivate.h> > #import <WebKit/WKWebViewPrivate.h> > #import <WebKit/WKWebsiteDataStorePrivate.h> > #import <WebKit/WKWebsitePolicies.h> >+#import <WebKit/_WKCustomHeaderFields.h> > #import <WebKit/_WKUserContentExtensionStorePrivate.h> > #import <WebKit/_WKWebsiteDataStoreConfiguration.h> > #import <WebKit/_WKWebsitePolicies.h> >@@ -907,9 +910,9 @@ TEST(WebKit, WebsitePoliciesAutoplayQuir > > TEST(WebKit, InvalidCustomHeaders) > { >- auto websitePolicies = adoptNS([[_WKWebsitePolicies alloc] init]); >- [websitePolicies setCustomHeaderFields:@{@"invalidheader" : @"", @"noncustom" : @"header", @" x-Custom ":@" Needs Canonicalization\t ", @"x-other" : @"other value"}]; >- NSDictionary<NSString *, NSString *> *canonicalized = [websitePolicies customHeaderFields]; >+ auto customHeaderFields = adoptNS([[_WKCustomHeaderFields alloc] init]); >+ [customHeaderFields setFields:@{@"invalidheader" : @"", @"noncustom" : @"header", @" x-Custom ":@" Needs Canonicalization\t ", @"x-other" : @"other value"}]; >+ NSDictionary<NSString *, NSString *> *canonicalized = [customHeaderFields fields]; > EXPECT_EQ(canonicalized.count, 2u); > EXPECT_STREQ([canonicalized objectForKey:@"x-Custom"].UTF8String, "Needs Canonicalization"); > EXPECT_STREQ([canonicalized objectForKey:@"x-other"].UTF8String, "other value"); >@@ -919,8 +922,9 @@ static bool firstTestDone; > static bool secondTestDone; > static bool thirdTestDone; > static bool fourthTestDone; >+static bool fifthTestDone; > >-static void expectHeaders(id <WKURLSchemeTask> task, bool expected) >+static void expectLegacyHeaders(id <WKURLSchemeTask> task, bool expected) > { > NSURLRequest *request = task.request; > if (expected) { >@@ -932,6 +936,18 @@ static void expectHeaders(id <WKURLSchem > } > } > >+static void expectHeaders(id <WKURLSchemeTask> task, bool expected) >+{ >+ NSURLRequest *request = task.request; >+ if (expected) { >+ EXPECT_STREQ([[request valueForHTTPHeaderField:@"X-key3"] UTF8String], "value3"); >+ EXPECT_STREQ([[request valueForHTTPHeaderField:@"X-key4"] UTF8String], "value4"); >+ } else { >+ EXPECT_TRUE([request valueForHTTPHeaderField:@"X-key3"] == nil); >+ EXPECT_TRUE([request valueForHTTPHeaderField:@"X-key4"] == nil); >+ } >+} >+ > static void respond(id <WKURLSchemeTask>task, NSString *html = nil) > { > [task didReceiveResponse:[[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:html.length textEncodingName:nil] autorelease]]; >@@ -944,61 +960,88 @@ @interface CustomHeaderFieldsDelegate : > > @implementation CustomHeaderFieldsDelegate > >-IGNORE_WARNINGS_BEGIN("deprecated-implementations") >-- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler >-IGNORE_WARNINGS_END >+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler > { >- _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; >- [websitePolicies setCustomHeaderFields:@{@"X-key1": @"value1", @"X-key2": @"value2"}]; >+ auto legacyHeaderFieldDictionary = adoptWK(WKMutableDictionaryCreate()); >+ WKDictionarySetItem(legacyHeaderFieldDictionary.get(), adoptWK(WKStringCreateWithUTF8CString("X-key1")).get(), adoptWK(WKStringCreateWithUTF8CString("value1")).get()); >+ WKDictionarySetItem(legacyHeaderFieldDictionary.get(), adoptWK(WKStringCreateWithUTF8CString("X-key2")).get(), adoptWK(WKStringCreateWithUTF8CString("value2")).get()); >+ WKWebsitePoliciesSetCustomHeaderFields((WKWebsitePoliciesRef)preferences, legacyHeaderFieldDictionary.get()); >+ >+ _WKCustomHeaderFields *headerFields = [[[_WKCustomHeaderFields alloc] init] autorelease]; >+ [headerFields setFields:@{@"X-key3": @"value3", @"X-key4": @"value4"}]; >+ [headerFields setThirdPartyDomains:@[@"*.hostwithasterisk.com", @"hostwithoutasterisk.com"]]; >+ >+ [preferences _setCustomHeaderFields:@[headerFields]]; >+ > if ([navigationAction.request.URL.path isEqualToString:@"/mainresource"]) { > dispatch_async(dispatch_get_main_queue(), ^{ >- decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); >+ decisionHandler(WKNavigationActionPolicyAllow, preferences); > }); > } else >- decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); >+ decisionHandler(WKNavigationActionPolicyAllow, preferences); > } > > - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask > { > NSString *path = urlSchemeTask.request.URL.path; > if ([path isEqualToString:@"/mainresource"]) { >- expectHeaders(urlSchemeTask, true); >+ expectLegacyHeaders(urlSchemeTask, true); > respond(urlSchemeTask, @"<script>fetch('subresource').then(function(response){fetch('test://differentsecurityorigin/crossoriginsubresource',{mode:'no-cors'})})</script>"); > } else if ([path isEqualToString:@"/subresource"]) { >- expectHeaders(urlSchemeTask, true); >+ expectLegacyHeaders(urlSchemeTask, true); > respond(urlSchemeTask); > } else if ([path isEqualToString:@"/crossoriginsubresource"]) { >- expectHeaders(urlSchemeTask, false); >+ expectLegacyHeaders(urlSchemeTask, false); > respond(urlSchemeTask); > firstTestDone = true; > } else if ([path isEqualToString:@"/mainresourcewithiframe"]) { >- expectHeaders(urlSchemeTask, true); >+ expectLegacyHeaders(urlSchemeTask, true); > respond(urlSchemeTask, @"<iframe src='test://iframeorigin/iframemainresource'></iframe>"); > } else if ([path isEqualToString:@"/iframemainresource"]) { >- expectHeaders(urlSchemeTask, false); >+ expectLegacyHeaders(urlSchemeTask, false); > respond(urlSchemeTask, @"<script>fetch('iframesubresource').then(function(response){fetch('test://mainframeorigin/originaloriginsubresource',{mode:'no-cors'})})</script>"); > } else if ([path isEqualToString:@"/iframesubresource"]) { >- expectHeaders(urlSchemeTask, false); >+ expectLegacyHeaders(urlSchemeTask, false); > respond(urlSchemeTask); > } else if ([path isEqualToString:@"/originaloriginsubresource"]) { >- expectHeaders(urlSchemeTask, false); >+ expectLegacyHeaders(urlSchemeTask, false); > respond(urlSchemeTask); > secondTestDone = true; > } else if ([path isEqualToString:@"/nestedtop"]) { >- expectHeaders(urlSchemeTask, true); >+ expectLegacyHeaders(urlSchemeTask, true); > respond(urlSchemeTask, @"<iframe src='test://otherorigin/nestedmid'></iframe>"); > } else if ([path isEqualToString:@"/nestedmid"]) { >- expectHeaders(urlSchemeTask, false); >+ expectLegacyHeaders(urlSchemeTask, false); > respond(urlSchemeTask, @"<iframe src='test://toporigin/nestedbottom'></iframe>"); > } else if ([path isEqualToString:@"/nestedbottom"]) { >- expectHeaders(urlSchemeTask, true); >+ expectLegacyHeaders(urlSchemeTask, true); > respond(urlSchemeTask); > thirdTestDone = true; > } else if ([path isEqualToString:@"/requestfromaboutblank"]) { >- expectHeaders(urlSchemeTask, true); >+ expectLegacyHeaders(urlSchemeTask, true); > respond(urlSchemeTask); > fourthTestDone = true; >- } else >+ } else if ([path isEqualToString:@"/testcustomheaderfieldhosts"]) { >+ expectHeaders(urlSchemeTask, true); >+ NSString *html = @"<script>fetch('test://a.b.c.sub.hostwithasterisk.com/hosttest1',{mode:'no-cors'})" >+ ".then(function(response){fetch('test://subhostwithasterisk.com/hosttest2',{mode:'no-cors'})})" >+ ".then(function(response){fetch('test://hostwithoutasterisk.com/hosttest3',{mode:'no-cors'})})" >+ ".then(function(response){fetch('test://a.b.c.sub.hostwithoutasterisk.com/hosttest4',{mode:'no-cors'})})</script>"; >+ respond(urlSchemeTask, html); >+ } else if ([path isEqualToString:@"/hosttest1"]) { >+ expectHeaders(urlSchemeTask, true); >+ respond(urlSchemeTask); >+ } else if ([path isEqualToString:@"/hosttest2"]) { >+ expectHeaders(urlSchemeTask, false); >+ respond(urlSchemeTask); >+ } else if ([path isEqualToString:@"/hosttest3"]) { >+ expectHeaders(urlSchemeTask, true); >+ respond(urlSchemeTask); >+ } else if ([path isEqualToString:@"/hosttest4"]) { >+ expectHeaders(urlSchemeTask, false); >+ respond(urlSchemeTask); >+ fifthTestDone = true; >+ } else if ([path isEqualToString:@"/testcustomheaderfieldhosts"]) > EXPECT_TRUE(false); > } > >@@ -1023,6 +1066,9 @@ TEST(WebKit, CustomHeaderFields) > > [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://toporigin/nestedtop"]]]; > TestWebKitAPI::Util::run(&thirdTestDone); >+ >+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://host/testcustomheaderfieldhosts"]]]; >+ TestWebKitAPI::Util::run(&fifthTestDone); > } > > static unsigned loadCount; >Index: Tools/TestWebKitAPI/ios/UIKitSPI.h >=================================================================== >--- Tools/TestWebKitAPI/ios/UIKitSPI.h (revision 244759) >+++ Tools/TestWebKitAPI/ios/UIKitSPI.h (working copy) >@@ -158,10 +158,6 @@ typedef NS_OPTIONS(NSInteger, UIWKDocume > @end > #endif > >-@interface NSURL (UIKitSPI) >-@property (nonatomic, copy, setter=_setTitle:) NSString *_title; >-@end >- > @interface UIViewController (UIKitSPI) > + (UIViewController *)_viewControllerForFullScreenPresentationFromView:(UIView *)view; > @end
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197397
:
368523
|
368538
|
368698
|
368711
|
368724
|
368738
|
368774
|
368780
|
368801
|
369179
|
369182
|
369187
|
369238
|
369325
|
369328
|
370005
|
370155