⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245470 in webkit


Ignore:
Timestamp:
May 17, 2019, 10:30:22 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r245401.
https://bugs.webkit.org/show_bug.cgi?id=197990

Causing internal build failures (Requested by ShawnRoberts on
#webkit).

Reverted changeset:

"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
https://trac.webkit.org/changeset/245401

Location:
trunk
Files:
6 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245469 r245470  
     12019-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
    1162019-05-16  Said Abou-Hallawa  <sabouhallawa@apple.com>
    217
  • trunk/Source/WebCore/Headers.cmake

    r245401 r245470  
    655655    loader/CrossOriginAccessControl.h
    656656    loader/CrossOriginPreflightResultCache.h
    657     loader/CustomHeaderFields.h
    658657    loader/DocumentLoader.h
    659658    loader/DocumentWriter.h
  • trunk/Source/WebCore/Sources.txt

    r245401 r245470  
    13651365loader/CrossOriginPreflightChecker.cpp
    13661366loader/CrossOriginPreflightResultCache.cpp
    1367 loader/CustomHeaderFields.cpp @no-unify
    13681367loader/DocumentLoader.cpp
    13691368loader/DocumentThreadableLoader.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r245401 r245470  
    18731873                5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
    18741874                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, ); }; };
    18761875                5C7C88D81D0F1F4A009D2F6D /* SocketProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C88D71D0F1F2B009D2F6D /* SocketProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18771876                5C9C2DB52241A67B00996B0B /* ContentRuleListResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9C2DB32241A67300996B0B /* ContentRuleListResults.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    18801879                5CB37FFF1C62D2A100F20188 /* ScrollAnimatorMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB37FFD1C62D27800F20188 /* ScrollAnimatorMock.h */; };
    18811880                5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC8DAB1AAA302200E1C803 /* MediaAccessibilitySoftLink.h */; };
    1882                 5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */; };
    18831881                5CD9F5661AA0F73C00DA45FF /* DFABytecode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305D1AA0F6A90029C816 /* DFABytecode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18841882                5CD9F5671AA0F74200DA45FF /* DFABytecodeCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305F1AA0F6A90029C816 /* DFABytecodeCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    88358833                5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; };
    88368834                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>"; };
    88398835                5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleImpl.cpp; sourceTree = "<group>"; };
    88408836                5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; };
     
    2501625012                                E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */,
    2501725013                                E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */,
    25018                                 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */,
    25019                                 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */,
    2502025014                                93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */,
    2502125015                                656D371E0ADBA5DE00A4554D /* DocumentLoader.h */,
     
    2869228686                                9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */,
    2869328687                                62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
    28694                                 5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */,
    2869528688                                4B1E13E721790D660042CF98 /* CustomPaintCanvas.h in Headers */,
    2869628689                                4B7AE4932177B56F00C59959 /* CustomPaintImage.h in Headers */,
     
    3261732610                                46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */,
    3261832611                                1ABA76CA11D20E50004C201C /* CSSPropertyNames.cpp in Sources */,
    32619                                 5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */,
    3262032612                                BE23480C18A9870B00E4B6E8 /* DataCue.cpp in Sources */,
    3262132613                                4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */,
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r245401 r245470  
    3939#include "ContentExtensionError.h"
    4040#include "ContentSecurityPolicy.h"
    41 #include "CustomHeaderFields.h"
    4241#include "DOMWindow.h"
    4342#include "Document.h"
     
    5554#include "HTMLFormElement.h"
    5655#include "HTMLFrameOwnerElement.h"
     56#include "HTTPHeaderField.h"
    5757#include "HTTPHeaderNames.h"
    5858#include "HistoryItem.h"
     
    13231323#endif
    13241324
     1325void DocumentLoader::setCustomHeaderFields(Vector<HTTPHeaderField>&& fields)
     1326{
     1327    m_customHeaderFields = WTFMove(fields);
     1328}
     1329
    13251330bool DocumentLoader::isLoadingInAPISense() const
    13261331{
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r245401 r245470  
    7777class CachedResourceLoader;
    7878class ContentFilter;
    79 struct CustomHeaderFields;
    8079class FormState;
    8180class Frame;
    8281class FrameLoader;
     82class HTTPHeaderField;
    8383class IconLoader;
    8484class Page;
     
    372372#endif
    373373
    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; }
    376376
    377377    void setAllowsWebArchiveForMainFrame(bool allowsWebArchiveForMainFrame) { m_allowsWebArchiveForMainFrame = allowsWebArchiveForMainFrame; }
     
    565565#endif
    566566
    567     Vector<CustomHeaderFields> m_customHeaderFields;
     567    Vector<HTTPHeaderField> m_customHeaderFields;
    568568   
    569569    bool m_subresourceLoadersArePageCacheAcceptable { false };
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r245401 r245470  
    4444#include "ContentSecurityPolicy.h"
    4545#include "CrossOriginAccessControl.h"
    46 #include "CustomHeaderFields.h"
    4746#include "DOMWindow.h"
    4847#include "DiagnosticLoggingClient.h"
     
    860859                && document()->securityOrigin().isSameSchemeHostPort(requestedOrigin.get());
    861860        }
    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());
    867864        }
    868865    }
  • trunk/Source/WebKit/ChangeLog

    r245468 r245470  
     12019-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
    1162019-05-17  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Source/WebKit/Shared/API/APIObject.h

    r245401 r245470  
    112112        ContextMenuListener,
    113113        CookieManager,
    114         CustomHeaderFields,
    115114        InternalDebugFeature,
    116115        Download,
  • trunk/Source/WebKit/Shared/Cocoa/APIObject.mm

    r245401 r245470  
    7171#import "_WKAutomationSessionInternal.h"
    7272#import "_WKContentRuleListActionInternal.h"
    73 #import "_WKCustomHeaderFieldsInternal.h"
    7473#import "_WKDownloadInternal.h"
    7574#import "_WKExperimentalFeatureInternal.h"
     
    314313        break;
    315314
    316     case Type::CustomHeaderFields:
    317         wrapper = [_WKCustomHeaderFields alloc];
    318         break;
    319 
    320315    case Type::UserContentWorld:
    321316        wrapper = [_WKUserContentWorld alloc];
  • trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp

    r245401 r245470  
    2929#include "ArgumentCoders.h"
    3030#include "WebProcess.h"
    31 #include <WebCore/CustomHeaderFields.h>
    3231#include <WebCore/DocumentLoader.h>
    3332#include <WebCore/Frame.h>
     
    7978        return WTF::nullopt;
    8079   
    81     Optional<Vector<WebCore::CustomHeaderFields>> customHeaderFields;
     80    Optional<Vector<WebCore::HTTPHeaderField>> customHeaderFields;
    8281    decoder >> customHeaderFields;
    8382    if (!customHeaderFields)
  • trunk/Source/WebKit/Shared/WebsitePoliciesData.h

    r245401 r245470  
    3333#include "WebsitePopUpPolicy.h"
    3434#include "WebsiteSimulatedMouseEventsDispatchPolicy.h"
    35 #include <WebCore/CustomHeaderFields.h>
    3635#include <WebCore/DeviceOrientationOrMotionPermissionState.h>
     36#include <WebCore/HTTPHeaderField.h>
    3737#include <wtf/OptionSet.h>
    3838
     
    5757    WebCore::DeviceOrientationOrMotionPermissionState deviceOrientationAndMotionAccessState;
    5858#endif
    59     Vector<WebCore::CustomHeaderFields> customHeaderFields;
     59    Vector<WebCore::HTTPHeaderField> customHeaderFields;
    6060    WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default };
    6161    Optional<WebsiteDataStoreParameters> websiteDataStoreParameters;
  • trunk/Source/WebKit/SourcesCocoa.txt

    r245401 r245470  
    243243UIProcess/API/Cocoa/_WKContentRuleListAction.mm
    244244UIProcess/API/Cocoa/_WKContextMenuElementInfo.mm
    245 UIProcess/API/Cocoa/_WKCustomHeaderFields.mm @no-unify
    246245UIProcess/API/Cocoa/_WKDownload.mm
    247246UIProcess/API/Cocoa/_WKElementAction.mm
  • trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp

    r245401 r245470  
    3434WebsitePolicies::WebsitePolicies() = default;
    3535
    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)
     36WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebsiteDataStore>&& websiteDataStore)
    3737    : m_contentBlockersEnabled(contentBlockersEnabled)
    3838    , m_allowedAutoplayQuirks(allowedAutoplayQuirks)
    3939    , m_autoplayPolicy(autoplayPolicy)
    40     , m_legacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields))
    4140    , m_customHeaderFields(WTFMove(customHeaderFields))
    4241    , m_popUpPolicy(popUpPolicy)
     
    6261    policies->setMediaSourcePolicy(m_mediaSourcePolicy);
    6362    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;
    7264    customHeaderFields.reserveInitialCapacity(m_customHeaderFields.size());
    7365    for (auto& field : m_customHeaderFields)
    74         customHeaderFields.uncheckedAppend(field);
     66        customHeaderFields.append(WebCore::HTTPHeaderField(field));
    7567    policies->setCustomHeaderFields(WTFMove(customHeaderFields));
    7668    policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode);
     
    9082WebKit::WebsitePoliciesData WebsitePolicies::data()
    9183{
    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 
    10084    return {
    10185        contentBlockersEnabled(),
     
    10589        deviceOrientationAndMotionAccessState(),
    10690#endif
    107         WTFMove(customHeaderFields),
     91        customHeaderFields(),
    10892        popUpPolicy(),
    10993        m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->websiteDataStore().parameters() } : WTF::nullopt,
  • trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h

    r245401 r245470  
    3434#include "WebsitePopUpPolicy.h"
    3535#include "WebsiteSimulatedMouseEventsDispatchPolicy.h"
    36 #include <WebCore/CustomHeaderFields.h>
    3736#include <WebCore/DeviceOrientationOrMotionPermissionState.h>
    3837#include <WebCore/HTTPHeaderField.h>
     
    7069#endif
    7170
    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); }
    7774
    7875    WebKit::WebsitePopUpPolicy popUpPolicy() const { return m_popUpPolicy; }
     
    112109
    113110private:
    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>&&);
    115112
    116113    bool m_contentBlockersEnabled { true };
     
    120117    WebCore::DeviceOrientationOrMotionPermissionState m_deviceOrientationAndMotionAccessState { WebCore::DeviceOrientationOrMotionPermissionState::Prompt };
    121118#endif
    122     Vector<WebCore::HTTPHeaderField> m_legacyCustomHeaderFields;
    123     Vector<WebCore::CustomHeaderFields> m_customHeaderFields;
     119    Vector<WebCore::HTTPHeaderField> m_customHeaderFields;
    124120    WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default };
    125121    RefPtr<WebsiteDataStore> m_websiteDataStore;
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp

    r245401 r245470  
    6060{
    6161    HashMap<WTF::String, RefPtr<API::Object>> fields;
    62     for (const auto& field : toImpl(websitePolicies)->legacyCustomHeaderFields())
     62    for (const auto& field : toImpl(websitePolicies)->customHeaderFields())
    6363        fields.add(field.name(), API::String::create(field.value()));
    6464    return toAPI(API::Dictionary::create(WTFMove(fields)).ptr());
     
    7777            fields.uncheckedAppend(WTFMove(*field));
    7878    }
    79     toImpl(websitePolicies)->setLegacyCustomHeaderFields(WTFMove(fields));
     79    toImpl(websitePolicies)->setCustomHeaderFields(WTFMove(fields));
    8080}
    8181
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm

    r245401 r245470  
    2727#import "WKWebpagePreferences.h"
    2828
    29 #import "APICustomHeaderFields.h"
    3029#import "WKWebpagePreferencesInternal.h"
    3130#import "WKWebsiteDataStoreInternal.h"
    3231#import "WebCompatibilityMode.h"
    33 #import "_WKCustomHeaderFieldsInternal.h"
    3432#import "_WKWebsitePoliciesInternal.h"
    3533#import <wtf/RetainPtr.h>
     
    217215}
    218216
    219 - (NSArray<_WKCustomHeaderFields *> *)_customHeaderFields
     217- (NSDictionary<NSString *, NSString *> *)_customHeaderFields
    220218{
    221219    const auto& fields = _websitePolicies->customHeaderFields();
    222     NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:fields.size()] autorelease];
     220    auto dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:fields.size()]);
    223221    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));
    235237}
    236238
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h

    r245401 r245470  
    5656} WK_API_AVAILABLE(macos(10.14), ios(12.0));
    5757
    58 @class _WKCustomHeaderFields;
    59 
    6058@interface WKWebpagePreferences (WKPrivate)
    6159
     
    6361@property (nonatomic, setter=_setAllowedAutoplayQuirks:) _WKWebsiteAutoplayQuirk _allowedAutoplayQuirks;
    6462@property (nonatomic, setter=_setAutoplayPolicy:) _WKWebsiteAutoplayPolicy _autoplayPolicy;
    65 @property (nonatomic, copy, setter=_setCustomHeaderFields:) NSArray<_WKCustomHeaderFields *> *_customHeaderFields;
     63@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSDictionary<NSString *, NSString *> *_customHeaderFields;
    6664@property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy;
    6765@property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore;
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm

    r245401 r245470  
    9898- (NSDictionary<NSString *, NSString *> *)customHeaderFields
    9999{
    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];
    105101}
    106102
    107103- (void)setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields
    108104{
    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];
    118106}
    119107
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r245401 r245470  
    10791079                5C5CEC34220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; };
    10801080                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, ); }; };
    10821081                5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10831082                5C7FB47021E97DC5009E3241 /* WebCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7FB46F21E97C0C009E3241 /* WebCookieJar.h */; };
     
    10941093                5CB2378E1DF0E0D300117AA3 /* _WKWebsitePoliciesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB2378D1DF0E0C200117AA3 /* _WKWebsitePoliciesInternal.h */; };
    10951094                5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
    1096                 5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */; };
    10971095                5CD286511E7235990094FDC8 /* WKContentRuleListStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD2864D1E722F440094FDC8 /* WKContentRuleListStore.h */; settings = {ATTRIBUTES = (Public, ); }; };
    10981096                5CD286531E7235AA0094FDC8 /* _WKUserContentFilterPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD286491E722F440094FDC8 /* _WKUserContentFilterPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    35313529                5C5CEC382209583200D6BBB0 /* DaemonEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonEntryPoint.h; sourceTree = "<group>"; };
    35323530                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>"; };
    35373531                5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; };
    35383532                5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; };
     
    61486142                                1A5704F61BE01FF400874AF1 /* _WKContextMenuElementInfo.h */,
    61496143                                1A5704F51BE01FF400874AF1 /* _WKContextMenuElementInfo.mm */,
    6150                                 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */,
    6151                                 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */,
    6152                                 5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */,
    61536144                                83891B681A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h */,
    61546145                                A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */,
     
    77157706                                7C3A06A61AAB903E009D74BA /* APIContentRuleListStore.h */,
    77167707                                076E884D1A13CADF005E90FC /* APIContextMenuClient.h */,
    7717                                 5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */,
    77187708                                7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */,
    77197709                                83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */,
     
    90299019                                5C4609E8224317BB009943C2 /* _WKContentRuleListActionInternal.h in Headers */,
    90309020                                1A5704F81BE01FF400874AF1 /* _WKContextMenuElementInfo.h in Headers */,
    9031                                 5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */,
    90329021                                83891B691A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h in Headers */,
    90339022                                A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */,
     
    1096910958                        buildActionMask = 2147483647;
    1097010959                        files = (
    10971                                 5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */,
    1097210960                                99E7189A21F79D9E0055E975 /* _WKTouchEventGenerator.mm in Sources */,
    1097310961                                2D92A784212B6AB100F493FD /* ActivityAssertion.cpp in Sources */,
  • trunk/Tools/ChangeLog

    r245468 r245470  
     12019-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
    1162019-05-17  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm

    r245401 r245470  
    2929#import "TestNavigationDelegate.h"
    3030#import "TestWKWebView.h"
    31 #import <WebKit/WKMutableDictionary.h>
    3231#import <WebKit/WKNavigationDelegatePrivate.h>
    3332#import <WebKit/WKPagePrivate.h>
    3433#import <WebKit/WKPreferencesPrivate.h>
    3534#import <WebKit/WKPreferencesRefPrivate.h>
    36 #import <WebKit/WKString.h>
    3735#import <WebKit/WKUIDelegatePrivate.h>
    3836#import <WebKit/WKURLSchemeTaskPrivate.h>
     
    4139#import <WebKit/WKWebsiteDataStorePrivate.h>
    4240#import <WebKit/WKWebsitePolicies.h>
    43 #import <WebKit/_WKCustomHeaderFields.h>
    4441#import <WebKit/_WKUserContentExtensionStorePrivate.h>
    4542#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
     
    911908TEST(WebKit, InvalidCustomHeaders)
    912909{
    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];
    916913    EXPECT_EQ(canonicalized.count, 2u);
    917914    EXPECT_STREQ([canonicalized objectForKey:@"x-Custom"].UTF8String, "Needs Canonicalization");
     
    923920static bool thirdTestDone;
    924921static bool fourthTestDone;
    925 static bool fifthTestDone;
    926 
    927 static void expectLegacyHeaders(id <WKURLSchemeTask> task, bool expected)
     922
     923static void expectHeaders(id <WKURLSchemeTask> task, bool expected)
    928924{
    929925    NSURLRequest *request = task.request;
     
    937933}
    938934
    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 
    951935static void respond(id <WKURLSchemeTask>task, NSString *html = nil)
    952936{
     
    961945@implementation CustomHeaderFieldsDelegate
    962946
    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    
     947IGNORE_WARNINGS_BEGIN("deprecated-implementations")
     948- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler
     949IGNORE_WARNINGS_END
     950{
     951    _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
     952    [websitePolicies setCustomHeaderFields:@{@"X-key1": @"value1", @"X-key2": @"value2"}];
    980953    if ([navigationAction.request.URL.path isEqualToString:@"/mainresource"]) {
    981954        dispatch_async(dispatch_get_main_queue(), ^{
    982             decisionHandler(WKNavigationActionPolicyAllow, preferences);
     955            decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
    983956        });
    984957    } else
    985         decisionHandler(WKNavigationActionPolicyAllow, preferences);
     958        decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
    986959}
    987960
     
    990963    NSString *path = urlSchemeTask.request.URL.path;
    991964    if ([path isEqualToString:@"/mainresource"]) {
    992         expectLegacyHeaders(urlSchemeTask, true);
     965        expectHeaders(urlSchemeTask, true);
    993966        respond(urlSchemeTask, @"<script>fetch('subresource').then(function(response){fetch('test://differentsecurityorigin/crossoriginsubresource',{mode:'no-cors'})})</script>");
    994967    } else if ([path isEqualToString:@"/subresource"]) {
    995         expectLegacyHeaders(urlSchemeTask, true);
     968        expectHeaders(urlSchemeTask, true);
    996969        respond(urlSchemeTask);
    997970    } else if ([path isEqualToString:@"/crossoriginsubresource"]) {
    998         expectLegacyHeaders(urlSchemeTask, false);
     971        expectHeaders(urlSchemeTask, false);
    999972        respond(urlSchemeTask);
    1000973        firstTestDone = true;
    1001974    } else if ([path isEqualToString:@"/mainresourcewithiframe"]) {
    1002         expectLegacyHeaders(urlSchemeTask, true);
     975        expectHeaders(urlSchemeTask, true);
    1003976        respond(urlSchemeTask, @"<iframe src='test://iframeorigin/iframemainresource'></iframe>");
    1004977    } else if ([path isEqualToString:@"/iframemainresource"]) {
    1005         expectLegacyHeaders(urlSchemeTask, false);
     978        expectHeaders(urlSchemeTask, false);
    1006979        respond(urlSchemeTask, @"<script>fetch('iframesubresource').then(function(response){fetch('test://mainframeorigin/originaloriginsubresource',{mode:'no-cors'})})</script>");
    1007980    } else if ([path isEqualToString:@"/iframesubresource"]) {
    1008         expectLegacyHeaders(urlSchemeTask, false);
     981        expectHeaders(urlSchemeTask, false);
    1009982        respond(urlSchemeTask);
    1010983    } else if ([path isEqualToString:@"/originaloriginsubresource"]) {
    1011         expectLegacyHeaders(urlSchemeTask, false);
     984        expectHeaders(urlSchemeTask, false);
    1012985        respond(urlSchemeTask);
    1013986        secondTestDone = true;
    1014987    } else if ([path isEqualToString:@"/nestedtop"]) {
    1015         expectLegacyHeaders(urlSchemeTask, true);
     988        expectHeaders(urlSchemeTask, true);
    1016989        respond(urlSchemeTask, @"<iframe src='test://otherorigin/nestedmid'></iframe>");
    1017990    } else if ([path isEqualToString:@"/nestedmid"]) {
    1018         expectLegacyHeaders(urlSchemeTask, false);
     991        expectHeaders(urlSchemeTask, false);
    1019992        respond(urlSchemeTask, @"<iframe src='test://toporigin/nestedbottom'></iframe>");
    1020993    } else if ([path isEqualToString:@"/nestedbottom"]) {
    1021         expectLegacyHeaders(urlSchemeTask, true);
     994        expectHeaders(urlSchemeTask, true);
    1022995        respond(urlSchemeTask);
    1023996        thirdTestDone = true;
    1024997    } else if ([path isEqualToString:@"/requestfromaboutblank"]) {
    1025         expectLegacyHeaders(urlSchemeTask, true);
     998        expectHeaders(urlSchemeTask, true);
    1026999        respond(urlSchemeTask);
    10271000        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
    10491002        EXPECT_TRUE(false);
    10501003}
     
    10711024    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://toporigin/nestedtop"]]];
    10721025    TestWebKitAPI::Util::run(&thirdTestDone);
    1073 
    1074     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://host/testcustomheaderfieldhosts"]]];
    1075     TestWebKitAPI::Util::run(&fifthTestDone);
    10761026}
    10771027
Note: See TracChangeset for help on using the changeset viewer.