Changeset 245470 in webkit
- Timestamp:
- May 17, 2019, 10:30:22 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 deleted
- 22 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Headers.cmake (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
Source/WebCore/loader/CustomHeaderFields.cpp (deleted)
-
Source/WebCore/loader/CustomHeaderFields.h (deleted)
-
Source/WebCore/loader/DocumentLoader.cpp (modified) (3 diffs)
-
Source/WebCore/loader/DocumentLoader.h (modified) (3 diffs)
-
Source/WebCore/loader/cache/CachedResourceLoader.cpp (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Shared/API/APIObject.h (modified) (1 diff)
-
Source/WebKit/Shared/Cocoa/APIObject.mm (modified) (2 diffs)
-
Source/WebKit/Shared/WebsitePoliciesData.cpp (modified) (2 diffs)
-
Source/WebKit/Shared/WebsitePoliciesData.h (modified) (2 diffs)
-
Source/WebKit/SourcesCocoa.txt (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APICustomHeaderFields.h (deleted)
-
Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (modified) (4 diffs)
-
Source/WebKit/UIProcess/API/APIWebsitePolicies.h (modified) (4 diffs)
-
Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h (deleted)
-
Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm (deleted)
-
Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h (deleted)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (modified) (1 diff)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (7 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r245469 r245470 1 2019-05-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r245401. 4 https://bugs.webkit.org/show_bug.cgi?id=197990 5 6 Causing internal build failures (Requested by ShawnRoberts on 7 #webkit). 8 9 Reverted changeset: 10 11 "Add SPI to set a list of hosts to which to send custom header 12 fields cross-origin" 13 https://bugs.webkit.org/show_bug.cgi?id=197397 14 https://trac.webkit.org/changeset/245401 15 1 16 2019-05-16 Said Abou-Hallawa <sabouhallawa@apple.com> 2 17 -
trunk/Source/WebCore/Headers.cmake
r245401 r245470 655 655 loader/CrossOriginAccessControl.h 656 656 loader/CrossOriginPreflightResultCache.h 657 loader/CustomHeaderFields.h658 657 loader/DocumentLoader.h 659 658 loader/DocumentWriter.h -
trunk/Source/WebCore/Sources.txt
r245401 r245470 1365 1365 loader/CrossOriginPreflightChecker.cpp 1366 1366 loader/CrossOriginPreflightResultCache.cpp 1367 loader/CustomHeaderFields.cpp @no-unify1368 1367 loader/DocumentLoader.cpp 1369 1368 loader/DocumentThreadableLoader.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r245401 r245470 1873 1873 5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; }; 1874 1874 5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; }; 1875 5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; };1876 1875 5C7C88D81D0F1F4A009D2F6D /* SocketProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C88D71D0F1F2B009D2F6D /* SocketProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1877 1876 5C9C2DB52241A67B00996B0B /* ContentRuleListResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9C2DB32241A67300996B0B /* ContentRuleListResults.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1880 1879 5CB37FFF1C62D2A100F20188 /* ScrollAnimatorMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB37FFD1C62D27800F20188 /* ScrollAnimatorMock.h */; }; 1881 1880 5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC8DAB1AAA302200E1C803 /* MediaAccessibilitySoftLink.h */; }; 1882 5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */; };1883 1881 5CD9F5661AA0F73C00DA45FF /* DFABytecode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305D1AA0F6A90029C816 /* DFABytecode.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1884 1882 5CD9F5671AA0F74200DA45FF /* DFABytecodeCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305F1AA0F6A90029C816 /* DFABytecodeCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8835 8833 5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; }; 8836 8834 5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSURLSearchParams.h; sourceTree = "<group>"; }; 8837 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomHeaderFields.h; sourceTree = "<group>"; };8838 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomHeaderFields.cpp; sourceTree = "<group>"; };8839 8835 5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleImpl.cpp; sourceTree = "<group>"; }; 8840 8836 5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; }; … … 25016 25012 E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */, 25017 25013 E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */, 25018 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */,25019 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */,25020 25014 93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */, 25021 25015 656D371E0ADBA5DE00A4554D /* DocumentLoader.h */, … … 28692 28686 9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */, 28693 28687 62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */, 28694 5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */,28695 28688 4B1E13E721790D660042CF98 /* CustomPaintCanvas.h in Headers */, 28696 28689 4B7AE4932177B56F00C59959 /* CustomPaintImage.h in Headers */, … … 32617 32610 46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */, 32618 32611 1ABA76CA11D20E50004C201C /* CSSPropertyNames.cpp in Sources */, 32619 5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */,32620 32612 BE23480C18A9870B00E4B6E8 /* DataCue.cpp in Sources */, 32621 32613 4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */, -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r245401 r245470 39 39 #include "ContentExtensionError.h" 40 40 #include "ContentSecurityPolicy.h" 41 #include "CustomHeaderFields.h"42 41 #include "DOMWindow.h" 43 42 #include "Document.h" … … 55 54 #include "HTMLFormElement.h" 56 55 #include "HTMLFrameOwnerElement.h" 56 #include "HTTPHeaderField.h" 57 57 #include "HTTPHeaderNames.h" 58 58 #include "HistoryItem.h" … … 1323 1323 #endif 1324 1324 1325 void DocumentLoader::setCustomHeaderFields(Vector<HTTPHeaderField>&& fields) 1326 { 1327 m_customHeaderFields = WTFMove(fields); 1328 } 1329 1325 1330 bool DocumentLoader::isLoadingInAPISense() const 1326 1331 { -
trunk/Source/WebCore/loader/DocumentLoader.h
r245401 r245470 77 77 class CachedResourceLoader; 78 78 class ContentFilter; 79 struct CustomHeaderFields;80 79 class FormState; 81 80 class Frame; 82 81 class FrameLoader; 82 class HTTPHeaderField; 83 83 class IconLoader; 84 84 class Page; … … 372 372 #endif 373 373 374 void setCustomHeaderFields(Vector<CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); }375 const Vector< CustomHeaderFields>& customHeaderFields() const{ return m_customHeaderFields; }374 WEBCORE_EXPORT void setCustomHeaderFields(Vector<HTTPHeaderField>&& fields); 375 const Vector<HTTPHeaderField>& customHeaderFields() { return m_customHeaderFields; } 376 376 377 377 void setAllowsWebArchiveForMainFrame(bool allowsWebArchiveForMainFrame) { m_allowsWebArchiveForMainFrame = allowsWebArchiveForMainFrame; } … … 565 565 #endif 566 566 567 Vector< CustomHeaderFields> m_customHeaderFields;567 Vector<HTTPHeaderField> m_customHeaderFields; 568 568 569 569 bool m_subresourceLoadersArePageCacheAcceptable { false }; -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r245401 r245470 44 44 #include "ContentSecurityPolicy.h" 45 45 #include "CrossOriginAccessControl.h" 46 #include "CustomHeaderFields.h"47 46 #include "DOMWindow.h" 48 47 #include "DiagnosticLoggingClient.h" … … 860 859 && document()->securityOrigin().isSameSchemeHostPort(requestedOrigin.get()); 861 860 } 862 for (auto& fields : m_documentLoader->customHeaderFields()) { 863 if (sameOriginRequest || fields.thirdPartyDomainsMatch(url)) { 864 for (auto& field : fields.fields) 865 request.resourceRequest().setHTTPHeaderField(field.name(), field.value()); 866 } 861 if (sameOriginRequest) { 862 for (auto& field : m_documentLoader->customHeaderFields()) 863 request.resourceRequest().setHTTPHeaderField(field.name(), field.value()); 867 864 } 868 865 } -
trunk/Source/WebKit/ChangeLog
r245468 r245470 1 2019-05-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r245401. 4 https://bugs.webkit.org/show_bug.cgi?id=197990 5 6 Causing internal build failures (Requested by ShawnRoberts on 7 #webkit). 8 9 Reverted changeset: 10 11 "Add SPI to set a list of hosts to which to send custom header 12 fields cross-origin" 13 https://bugs.webkit.org/show_bug.cgi?id=197397 14 https://trac.webkit.org/changeset/245401 15 1 16 2019-05-17 Commit Queue <commit-queue@webkit.org> 2 17 -
trunk/Source/WebKit/Shared/API/APIObject.h
r245401 r245470 112 112 ContextMenuListener, 113 113 CookieManager, 114 CustomHeaderFields,115 114 InternalDebugFeature, 116 115 Download, -
trunk/Source/WebKit/Shared/Cocoa/APIObject.mm
r245401 r245470 71 71 #import "_WKAutomationSessionInternal.h" 72 72 #import "_WKContentRuleListActionInternal.h" 73 #import "_WKCustomHeaderFieldsInternal.h"74 73 #import "_WKDownloadInternal.h" 75 74 #import "_WKExperimentalFeatureInternal.h" … … 314 313 break; 315 314 316 case Type::CustomHeaderFields:317 wrapper = [_WKCustomHeaderFields alloc];318 break;319 320 315 case Type::UserContentWorld: 321 316 wrapper = [_WKUserContentWorld alloc]; -
trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp
r245401 r245470 29 29 #include "ArgumentCoders.h" 30 30 #include "WebProcess.h" 31 #include <WebCore/CustomHeaderFields.h>32 31 #include <WebCore/DocumentLoader.h> 33 32 #include <WebCore/Frame.h> … … 79 78 return WTF::nullopt; 80 79 81 Optional<Vector<WebCore:: CustomHeaderFields>> customHeaderFields;80 Optional<Vector<WebCore::HTTPHeaderField>> customHeaderFields; 82 81 decoder >> customHeaderFields; 83 82 if (!customHeaderFields) -
trunk/Source/WebKit/Shared/WebsitePoliciesData.h
r245401 r245470 33 33 #include "WebsitePopUpPolicy.h" 34 34 #include "WebsiteSimulatedMouseEventsDispatchPolicy.h" 35 #include <WebCore/CustomHeaderFields.h>36 35 #include <WebCore/DeviceOrientationOrMotionPermissionState.h> 36 #include <WebCore/HTTPHeaderField.h> 37 37 #include <wtf/OptionSet.h> 38 38 … … 57 57 WebCore::DeviceOrientationOrMotionPermissionState deviceOrientationAndMotionAccessState; 58 58 #endif 59 Vector<WebCore:: CustomHeaderFields> customHeaderFields;59 Vector<WebCore::HTTPHeaderField> customHeaderFields; 60 60 WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default }; 61 61 Optional<WebsiteDataStoreParameters> websiteDataStoreParameters; -
trunk/Source/WebKit/SourcesCocoa.txt
r245401 r245470 243 243 UIProcess/API/Cocoa/_WKContentRuleListAction.mm 244 244 UIProcess/API/Cocoa/_WKContextMenuElementInfo.mm 245 UIProcess/API/Cocoa/_WKCustomHeaderFields.mm @no-unify246 245 UIProcess/API/Cocoa/_WKDownload.mm 247 246 UIProcess/API/Cocoa/_WKElementAction.mm -
trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp
r245401 r245470 34 34 WebsitePolicies::WebsitePolicies() = default; 35 35 36 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)36 WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebsiteDataStore>&& websiteDataStore) 37 37 : m_contentBlockersEnabled(contentBlockersEnabled) 38 38 , m_allowedAutoplayQuirks(allowedAutoplayQuirks) 39 39 , m_autoplayPolicy(autoplayPolicy) 40 , m_legacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields))41 40 , m_customHeaderFields(WTFMove(customHeaderFields)) 42 41 , m_popUpPolicy(popUpPolicy) … … 62 61 policies->setMediaSourcePolicy(m_mediaSourcePolicy); 63 62 policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy); 64 65 Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields; 66 legacyCustomHeaderFields.reserveInitialCapacity(m_legacyCustomHeaderFields.size()); 67 for (auto& field : m_legacyCustomHeaderFields) 68 legacyCustomHeaderFields.uncheckedAppend(field); 69 policies->setLegacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields)); 70 71 Vector<WebCore::CustomHeaderFields> customHeaderFields; 63 Vector<WebCore::HTTPHeaderField> customHeaderFields; 72 64 customHeaderFields.reserveInitialCapacity(m_customHeaderFields.size()); 73 65 for (auto& field : m_customHeaderFields) 74 customHeaderFields. uncheckedAppend(field);66 customHeaderFields.append(WebCore::HTTPHeaderField(field)); 75 67 policies->setCustomHeaderFields(WTFMove(customHeaderFields)); 76 68 policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode); … … 90 82 WebKit::WebsitePoliciesData WebsitePolicies::data() 91 83 { 92 bool hasLegacyCustomHeaderFields = legacyCustomHeaderFields().size();93 Vector<WebCore::CustomHeaderFields> customHeaderFields;94 customHeaderFields.reserveInitialCapacity(this->customHeaderFields().size() + hasLegacyCustomHeaderFields);95 for (auto& field : this->customHeaderFields())96 customHeaderFields.uncheckedAppend(field);97 if (hasLegacyCustomHeaderFields)98 customHeaderFields.uncheckedAppend({ legacyCustomHeaderFields(), { }});99 100 84 return { 101 85 contentBlockersEnabled(), … … 105 89 deviceOrientationAndMotionAccessState(), 106 90 #endif 107 WTFMove(customHeaderFields),91 customHeaderFields(), 108 92 popUpPolicy(), 109 93 m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->websiteDataStore().parameters() } : WTF::nullopt, -
trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h
r245401 r245470 34 34 #include "WebsitePopUpPolicy.h" 35 35 #include "WebsiteSimulatedMouseEventsDispatchPolicy.h" 36 #include <WebCore/CustomHeaderFields.h>37 36 #include <WebCore/DeviceOrientationOrMotionPermissionState.h> 38 37 #include <WebCore/HTTPHeaderField.h> … … 70 69 #endif 71 70 72 const Vector<WebCore::HTTPHeaderField>& legacyCustomHeaderFields() const { return m_legacyCustomHeaderFields; } 73 void setLegacyCustomHeaderFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_legacyCustomHeaderFields = WTFMove(fields); } 74 75 const Vector<WebCore::CustomHeaderFields>& customHeaderFields() const { return m_customHeaderFields; } 76 void setCustomHeaderFields(Vector<WebCore::CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); } 71 const Vector<WebCore::HTTPHeaderField>& customHeaderFields() const { return m_customHeaderFields; } 72 Vector<WebCore::HTTPHeaderField>&& takeCustomHeaderFields() { return WTFMove(m_customHeaderFields); } 73 void setCustomHeaderFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_customHeaderFields = WTFMove(fields); } 77 74 78 75 WebKit::WebsitePopUpPolicy popUpPolicy() const { return m_popUpPolicy; } … … 112 109 113 110 private: 114 WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&,WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&);111 WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&); 115 112 116 113 bool m_contentBlockersEnabled { true }; … … 120 117 WebCore::DeviceOrientationOrMotionPermissionState m_deviceOrientationAndMotionAccessState { WebCore::DeviceOrientationOrMotionPermissionState::Prompt }; 121 118 #endif 122 Vector<WebCore::HTTPHeaderField> m_legacyCustomHeaderFields; 123 Vector<WebCore::CustomHeaderFields> m_customHeaderFields; 119 Vector<WebCore::HTTPHeaderField> m_customHeaderFields; 124 120 WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default }; 125 121 RefPtr<WebsiteDataStore> m_websiteDataStore; -
trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp
r245401 r245470 60 60 { 61 61 HashMap<WTF::String, RefPtr<API::Object>> fields; 62 for (const auto& field : toImpl(websitePolicies)-> legacyCustomHeaderFields())62 for (const auto& field : toImpl(websitePolicies)->customHeaderFields()) 63 63 fields.add(field.name(), API::String::create(field.value())); 64 64 return toAPI(API::Dictionary::create(WTFMove(fields)).ptr()); … … 77 77 fields.uncheckedAppend(WTFMove(*field)); 78 78 } 79 toImpl(websitePolicies)->set LegacyCustomHeaderFields(WTFMove(fields));79 toImpl(websitePolicies)->setCustomHeaderFields(WTFMove(fields)); 80 80 } 81 81 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm
r245401 r245470 27 27 #import "WKWebpagePreferences.h" 28 28 29 #import "APICustomHeaderFields.h"30 29 #import "WKWebpagePreferencesInternal.h" 31 30 #import "WKWebsiteDataStoreInternal.h" 32 31 #import "WebCompatibilityMode.h" 33 #import "_WKCustomHeaderFieldsInternal.h"34 32 #import "_WKWebsitePoliciesInternal.h" 35 33 #import <wtf/RetainPtr.h> … … 217 215 } 218 216 219 - (NS Array<_WKCustomHeaderFields*> *)_customHeaderFields217 - (NSDictionary<NSString *, NSString *> *)_customHeaderFields 220 218 { 221 219 const auto& fields = _websitePolicies->customHeaderFields(); 222 NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:fields.size()] autorelease];220 auto dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:fields.size()]); 223 221 for (const auto& field : fields) 224 [array addObject:wrapper(API::CustomHeaderFields::create(field))]; 225 return array; 226 } 227 228 - (void)_setCustomHeaderFields:(NSArray<_WKCustomHeaderFields *> *)fields 229 { 230 Vector<WebCore::CustomHeaderFields> vector; 231 vector.reserveInitialCapacity(fields.count); 232 for (_WKCustomHeaderFields *element in fields) 233 vector.uncheckedAppend(static_cast<API::CustomHeaderFields&>([element _apiObject]).coreFields()); 234 _websitePolicies->setCustomHeaderFields(WTFMove(vector)); 222 [dictionary setObject:field.value() forKey:field.name()]; 223 return dictionary.autorelease(); 224 } 225 226 - (void)_setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields 227 { 228 Vector<WebCore::HTTPHeaderField> parsedFields; 229 parsedFields.reserveInitialCapacity(fields.count); 230 231 for (NSString *name in fields) { 232 auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]); 233 if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-")) 234 parsedFields.uncheckedAppend(WTFMove(*field)); 235 } 236 _websitePolicies->setCustomHeaderFields(WTFMove(parsedFields)); 235 237 } 236 238 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h
r245401 r245470 56 56 } WK_API_AVAILABLE(macos(10.14), ios(12.0)); 57 57 58 @class _WKCustomHeaderFields;59 60 58 @interface WKWebpagePreferences (WKPrivate) 61 59 … … 63 61 @property (nonatomic, setter=_setAllowedAutoplayQuirks:) _WKWebsiteAutoplayQuirk _allowedAutoplayQuirks; 64 62 @property (nonatomic, setter=_setAutoplayPolicy:) _WKWebsiteAutoplayPolicy _autoplayPolicy; 65 @property (nonatomic, copy, setter=_setCustomHeaderFields:) NS Array<_WKCustomHeaderFields*> *_customHeaderFields;63 @property (nonatomic, copy, setter=_setCustomHeaderFields:) NSDictionary<NSString *, NSString *> *_customHeaderFields; 66 64 @property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy; 67 65 @property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm
r245401 r245470 98 98 - (NSDictionary<NSString *, NSString *> *)customHeaderFields 99 99 { 100 auto& fields = static_cast<API::WebsitePolicies&>([_webpagePreferences _apiObject]).legacyCustomHeaderFields(); 101 auto dictionary = [NSMutableDictionary dictionaryWithCapacity:fields.size()]; 102 for (const auto& field : fields) 103 [dictionary setObject:field.value() forKey:field.name()]; 104 return dictionary; 100 return [_webpagePreferences _customHeaderFields]; 105 101 } 106 102 107 103 - (void)setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields 108 104 { 109 auto websitePolicies = static_cast<API::WebsitePolicies&>([_webpagePreferences _apiObject]); 110 Vector<WebCore::HTTPHeaderField> parsedFields; 111 parsedFields.reserveInitialCapacity(fields.count); 112 for (NSString *name in fields) { 113 auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]); 114 if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-")) 115 parsedFields.uncheckedAppend(WTFMove(*field)); 116 } 117 websitePolicies.setLegacyCustomHeaderFields(WTFMove(parsedFields)); 105 [_webpagePreferences _setCustomHeaderFields:fields]; 118 106 } 119 107 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r245401 r245470 1079 1079 5C5CEC34220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; }; 1080 1080 5C5CEC35220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; }; 1081 5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; };1082 1081 5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1083 1082 5C7FB47021E97DC5009E3241 /* WebCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7FB46F21E97C0C009E3241 /* WebCookieJar.h */; }; … … 1094 1093 5CB2378E1DF0E0D300117AA3 /* _WKWebsitePoliciesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB2378D1DF0E0C200117AA3 /* _WKWebsitePoliciesInternal.h */; }; 1095 1094 5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; }; 1096 5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */; };1097 1095 5CD286511E7235990094FDC8 /* WKContentRuleListStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD2864D1E722F440094FDC8 /* WKContentRuleListStore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1098 1096 5CD286531E7235AA0094FDC8 /* _WKUserContentFilterPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD286491E722F440094FDC8 /* _WKUserContentFilterPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 3531 3529 5C5CEC382209583200D6BBB0 /* DaemonEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonEntryPoint.h; sourceTree = "<group>"; }; 3532 3530 5C5CEC392209583200D6BBB0 /* DaemonEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DaemonEntryPoint.mm; sourceTree = "<group>"; }; 3533 5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFieldsInternal.h; sourceTree = "<group>"; };3534 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKCustomHeaderFields.mm; sourceTree = "<group>"; };3535 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFields.h; sourceTree = "<group>"; };3536 5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICustomHeaderFields.h; sourceTree = "<group>"; };3537 3531 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; }; 3538 3532 5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; }; … … 6148 6142 1A5704F61BE01FF400874AF1 /* _WKContextMenuElementInfo.h */, 6149 6143 1A5704F51BE01FF400874AF1 /* _WKContextMenuElementInfo.mm */, 6150 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */,6151 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */,6152 5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */,6153 6144 83891B681A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h */, 6154 6145 A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */, … … 7715 7706 7C3A06A61AAB903E009D74BA /* APIContentRuleListStore.h */, 7716 7707 076E884D1A13CADF005E90FC /* APIContextMenuClient.h */, 7717 5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */,7718 7708 7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */, 7719 7709 83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */, … … 9029 9019 5C4609E8224317BB009943C2 /* _WKContentRuleListActionInternal.h in Headers */, 9030 9020 1A5704F81BE01FF400874AF1 /* _WKContextMenuElementInfo.h in Headers */, 9031 5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */,9032 9021 83891B691A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h in Headers */, 9033 9022 A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */, … … 10969 10958 buildActionMask = 2147483647; 10970 10959 files = ( 10971 5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */,10972 10960 99E7189A21F79D9E0055E975 /* _WKTouchEventGenerator.mm in Sources */, 10973 10961 2D92A784212B6AB100F493FD /* ActivityAssertion.cpp in Sources */, -
trunk/Tools/ChangeLog
r245468 r245470 1 2019-05-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r245401. 4 https://bugs.webkit.org/show_bug.cgi?id=197990 5 6 Causing internal build failures (Requested by ShawnRoberts on 7 #webkit). 8 9 Reverted changeset: 10 11 "Add SPI to set a list of hosts to which to send custom header 12 fields cross-origin" 13 https://bugs.webkit.org/show_bug.cgi?id=197397 14 https://trac.webkit.org/changeset/245401 15 1 16 2019-05-17 Commit Queue <commit-queue@webkit.org> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm
r245401 r245470 29 29 #import "TestNavigationDelegate.h" 30 30 #import "TestWKWebView.h" 31 #import <WebKit/WKMutableDictionary.h>32 31 #import <WebKit/WKNavigationDelegatePrivate.h> 33 32 #import <WebKit/WKPagePrivate.h> 34 33 #import <WebKit/WKPreferencesPrivate.h> 35 34 #import <WebKit/WKPreferencesRefPrivate.h> 36 #import <WebKit/WKString.h>37 35 #import <WebKit/WKUIDelegatePrivate.h> 38 36 #import <WebKit/WKURLSchemeTaskPrivate.h> … … 41 39 #import <WebKit/WKWebsiteDataStorePrivate.h> 42 40 #import <WebKit/WKWebsitePolicies.h> 43 #import <WebKit/_WKCustomHeaderFields.h>44 41 #import <WebKit/_WKUserContentExtensionStorePrivate.h> 45 42 #import <WebKit/_WKWebsiteDataStoreConfiguration.h> … … 911 908 TEST(WebKit, InvalidCustomHeaders) 912 909 { 913 auto customHeaderFields = adoptNS([[_WKCustomHeaderFields alloc] init]);914 [ customHeaderFields setFields:@{@"invalidheader" : @"", @"noncustom" : @"header", @" x-Custom ":@" Needs Canonicalization\t ", @"x-other" : @"other value"}];915 NSDictionary<NSString *, NSString *> *canonicalized = [ customHeaderFields fields];910 auto websitePolicies = adoptNS([[_WKWebsitePolicies alloc] init]); 911 [websitePolicies setCustomHeaderFields:@{@"invalidheader" : @"", @"noncustom" : @"header", @" x-Custom ":@" Needs Canonicalization\t ", @"x-other" : @"other value"}]; 912 NSDictionary<NSString *, NSString *> *canonicalized = [websitePolicies customHeaderFields]; 916 913 EXPECT_EQ(canonicalized.count, 2u); 917 914 EXPECT_STREQ([canonicalized objectForKey:@"x-Custom"].UTF8String, "Needs Canonicalization"); … … 923 920 static bool thirdTestDone; 924 921 static bool fourthTestDone; 925 static bool fifthTestDone; 926 927 static void expectLegacyHeaders(id <WKURLSchemeTask> task, bool expected) 922 923 static void expectHeaders(id <WKURLSchemeTask> task, bool expected) 928 924 { 929 925 NSURLRequest *request = task.request; … … 937 933 } 938 934 939 static void expectHeaders(id <WKURLSchemeTask> task, bool expected)940 {941 NSURLRequest *request = task.request;942 if (expected) {943 EXPECT_STREQ([[request valueForHTTPHeaderField:@"X-key3"] UTF8String], "value3");944 EXPECT_STREQ([[request valueForHTTPHeaderField:@"X-key4"] UTF8String], "value4");945 } else {946 EXPECT_TRUE([request valueForHTTPHeaderField:@"X-key3"] == nil);947 EXPECT_TRUE([request valueForHTTPHeaderField:@"X-key4"] == nil);948 }949 }950 951 935 static void respond(id <WKURLSchemeTask>task, NSString *html = nil) 952 936 { … … 961 945 @implementation CustomHeaderFieldsDelegate 962 946 963 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler 964 { 965 auto legacyHeaderFieldDictionary = adoptWK(WKMutableDictionaryCreate()); 966 WKDictionarySetItem(legacyHeaderFieldDictionary.get(), adoptWK(WKStringCreateWithUTF8CString("X-key1")).get(), adoptWK(WKStringCreateWithUTF8CString("value1")).get()); 967 WKDictionarySetItem(legacyHeaderFieldDictionary.get(), adoptWK(WKStringCreateWithUTF8CString("X-key2")).get(), adoptWK(WKStringCreateWithUTF8CString("value2")).get()); 968 WKWebsitePoliciesSetCustomHeaderFields((WKWebsitePoliciesRef)preferences, legacyHeaderFieldDictionary.get()); 969 970 _WKCustomHeaderFields *headerFields = [[[_WKCustomHeaderFields alloc] init] autorelease]; 971 [headerFields setFields:@{@"X-key3": @"value3", @"X-key4": @"value4"}]; 972 [headerFields setThirdPartyDomains:@[ 973 @"*.hostwithasterisk.com", 974 @"hostwithoutasterisk.com", 975 @"*.com" // should be ignored. 976 ]]; 977 978 [preferences _setCustomHeaderFields:@[headerFields]]; 979 947 IGNORE_WARNINGS_BEGIN("deprecated-implementations") 948 - (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler 949 IGNORE_WARNINGS_END 950 { 951 _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; 952 [websitePolicies setCustomHeaderFields:@{@"X-key1": @"value1", @"X-key2": @"value2"}]; 980 953 if ([navigationAction.request.URL.path isEqualToString:@"/mainresource"]) { 981 954 dispatch_async(dispatch_get_main_queue(), ^{ 982 decisionHandler(WKNavigationActionPolicyAllow, preferences);955 decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); 983 956 }); 984 957 } else 985 decisionHandler(WKNavigationActionPolicyAllow, preferences);958 decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); 986 959 } 987 960 … … 990 963 NSString *path = urlSchemeTask.request.URL.path; 991 964 if ([path isEqualToString:@"/mainresource"]) { 992 expect LegacyHeaders(urlSchemeTask, true);965 expectHeaders(urlSchemeTask, true); 993 966 respond(urlSchemeTask, @"<script>fetch('subresource').then(function(response){fetch('test://differentsecurityorigin/crossoriginsubresource',{mode:'no-cors'})})</script>"); 994 967 } else if ([path isEqualToString:@"/subresource"]) { 995 expect LegacyHeaders(urlSchemeTask, true);968 expectHeaders(urlSchemeTask, true); 996 969 respond(urlSchemeTask); 997 970 } else if ([path isEqualToString:@"/crossoriginsubresource"]) { 998 expect LegacyHeaders(urlSchemeTask, false);971 expectHeaders(urlSchemeTask, false); 999 972 respond(urlSchemeTask); 1000 973 firstTestDone = true; 1001 974 } else if ([path isEqualToString:@"/mainresourcewithiframe"]) { 1002 expect LegacyHeaders(urlSchemeTask, true);975 expectHeaders(urlSchemeTask, true); 1003 976 respond(urlSchemeTask, @"<iframe src='test://iframeorigin/iframemainresource'></iframe>"); 1004 977 } else if ([path isEqualToString:@"/iframemainresource"]) { 1005 expect LegacyHeaders(urlSchemeTask, false);978 expectHeaders(urlSchemeTask, false); 1006 979 respond(urlSchemeTask, @"<script>fetch('iframesubresource').then(function(response){fetch('test://mainframeorigin/originaloriginsubresource',{mode:'no-cors'})})</script>"); 1007 980 } else if ([path isEqualToString:@"/iframesubresource"]) { 1008 expect LegacyHeaders(urlSchemeTask, false);981 expectHeaders(urlSchemeTask, false); 1009 982 respond(urlSchemeTask); 1010 983 } else if ([path isEqualToString:@"/originaloriginsubresource"]) { 1011 expect LegacyHeaders(urlSchemeTask, false);984 expectHeaders(urlSchemeTask, false); 1012 985 respond(urlSchemeTask); 1013 986 secondTestDone = true; 1014 987 } else if ([path isEqualToString:@"/nestedtop"]) { 1015 expect LegacyHeaders(urlSchemeTask, true);988 expectHeaders(urlSchemeTask, true); 1016 989 respond(urlSchemeTask, @"<iframe src='test://otherorigin/nestedmid'></iframe>"); 1017 990 } else if ([path isEqualToString:@"/nestedmid"]) { 1018 expect LegacyHeaders(urlSchemeTask, false);991 expectHeaders(urlSchemeTask, false); 1019 992 respond(urlSchemeTask, @"<iframe src='test://toporigin/nestedbottom'></iframe>"); 1020 993 } else if ([path isEqualToString:@"/nestedbottom"]) { 1021 expect LegacyHeaders(urlSchemeTask, true);994 expectHeaders(urlSchemeTask, true); 1022 995 respond(urlSchemeTask); 1023 996 thirdTestDone = true; 1024 997 } else if ([path isEqualToString:@"/requestfromaboutblank"]) { 1025 expect LegacyHeaders(urlSchemeTask, true);998 expectHeaders(urlSchemeTask, true); 1026 999 respond(urlSchemeTask); 1027 1000 fourthTestDone = true; 1028 } else if ([path isEqualToString:@"/testcustomheaderfieldhosts"]) { 1029 expectHeaders(urlSchemeTask, true); 1030 NSString *html = @"<script>fetch('test://a.b.c.sub.hostwithasterisk.com/hosttest1',{mode:'no-cors'})" 1031 ".then(function(response){fetch('test://subhostwithasterisk.com/hosttest2',{mode:'no-cors'})})" 1032 ".then(function(response){fetch('test://hostwithoutasterisk.com/hosttest3',{mode:'no-cors'})})" 1033 ".then(function(response){fetch('test://a.b.c.sub.hostwithoutasterisk.com/hosttest4',{mode:'no-cors'})})</script>"; 1034 respond(urlSchemeTask, html); 1035 } else if ([path isEqualToString:@"/hosttest1"]) { 1036 expectHeaders(urlSchemeTask, true); 1037 respond(urlSchemeTask); 1038 } else if ([path isEqualToString:@"/hosttest2"]) { 1039 expectHeaders(urlSchemeTask, false); 1040 respond(urlSchemeTask); 1041 } else if ([path isEqualToString:@"/hosttest3"]) { 1042 expectHeaders(urlSchemeTask, true); 1043 respond(urlSchemeTask); 1044 } else if ([path isEqualToString:@"/hosttest4"]) { 1045 expectHeaders(urlSchemeTask, false); 1046 respond(urlSchemeTask); 1047 fifthTestDone = true; 1048 } else if ([path isEqualToString:@"/testcustomheaderfieldhosts"]) 1001 } else 1049 1002 EXPECT_TRUE(false); 1050 1003 } … … 1071 1024 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://toporigin/nestedtop"]]]; 1072 1025 TestWebKitAPI::Util::run(&thirdTestDone); 1073 1074 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://host/testcustomheaderfieldhosts"]]];1075 TestWebKitAPI::Util::run(&fifthTestDone);1076 1026 } 1077 1027
Note:
See TracChangeset
for help on using the changeset viewer.