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

Changeset 231622 in webkit


Ignore:
Timestamp:
May 9, 2018, 5:33:37 PM (8 years ago)
Author:
Chris Dumez
Message:

Add initial support for 'Cross-Origin-Options' HTTP response header
​https://bugs.webkit.org/show_bug.cgi?id=184996
<rdar://problem/39664620>

Reviewed by Geoff Garen.

Source/WebCore:

Add initial support for 'Cross-Origin-Options' HTTP response header behind an experimental
feature flag, on by default. When the HTTP server services this HTTP response header for a
main resource, we'll set these options on the corresponding Document. This will impact the
behavior of the Document's associated Window API when cross-origin.

The HTTP header has 3 possible values:

  • allow: This is the default. Regular cross-origin Window API is available.
  • allow-postmessage: Only postMessage() is available on a cross-origin window, trying to access anything else will throw a SecurityError.
  • deny: Trying to do anything with a cross-origin window will throw a SecurityError.

The header has no effect when accessing same origin windows.

Note that on cross-origin access from Window A to Window B, we check the cross-origin
options for both Window A and Window B and use the lowest common denominator as effective
cross-origin options for the access. So if Window A has 'Cross-Origin-Options: deny' and
tries to call postMessage() on Window B which has 'Cross-Origin-Options: allow-postmessage',
we will throw a SecurityError. This is because Window A's more restrictive options (deny)
apply.

Tests: http/wpt/cross-origin-options/allow-postmessage-from-deny.html

http/wpt/cross-origin-options/allow-postmessage.html
http/wpt/cross-origin-options/cross-origin-options-header.html

  • bindings/js/JSDOMBindingSecurity.cpp:

(WebCore::BindingSecurity::shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions):

  • bindings/js/JSDOMBindingSecurity.h:
  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::effectiveCrossOriginOptionsForAccess):
(WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
(WebCore::addCrossOriginWindowPropertyNames):
(WebCore::addScopedChildrenIndexes):
(WebCore::addCrossOriginWindowOwnPropertyNames):
(WebCore::JSDOMWindow::getOwnPropertyNames):

  • bindings/js/JSDOMWindowCustom.h:
  • bindings/js/JSRemoteDOMWindowCustom.cpp:

(WebCore::JSRemoteDOMWindow::getOwnPropertySlot):
(WebCore::JSRemoteDOMWindow::getOwnPropertySlotByIndex):
(WebCore::JSRemoteDOMWindow::getOwnPropertyNames):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateAttributeGetterBodyDefinition):
(GetCrossOriginsOptionsFromExtendedAttributeValue):
(GenerateAttributeSetterBodyDefinition):
(GenerateOperationBodyDefinition):

  • bindings/scripts/IDLAttributes.json:
  • dom/Document.cpp:

(WebCore::Document::setCrossOriginOptions):

  • dom/Document.h:

(WebCore::Document::crossOriginOptions const):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::didBeginDocument):

  • page/AbstractDOMWindow.cpp:

(WebCore::AbstractDOMWindow::AbstractDOMWindow):

  • page/AbstractDOMWindow.h:

(WebCore::AbstractDOMWindow::crossOriginOptions):
(WebCore::AbstractDOMWindow::setCrossOriginOptions):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::DOMWindow):
(WebCore::DOMWindow::didSecureTransitionTo):

  • page/DOMWindow.idl:
  • page/Frame.h:
  • page/RemoteDOMWindow.cpp:

(WebCore::RemoteDOMWindow::RemoteDOMWindow):

  • page/RemoteDOMWindow.h:
  • page/Settings.yaml:
  • platform/network/HTTPHeaderNames.in:
  • platform/network/HTTPParsers.cpp:

(WebCore::parseCrossOriginOptionsHeader):

  • platform/network/HTTPParsers.h:

Source/WebKit:

  • Shared/WebPreferences.yaml:

Add this as an experimental feature, on by default.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::frameBecameRemote):
Make sure we pass the cross-origin options from the local Window
to the remote one when transitioning.

LayoutTests:

Add layout test coverage.

  • http/wpt/cross-origin-options/allow-postmessage-expected.txt: Added.
  • http/wpt/cross-origin-options/allow-postmessage-from-deny-expected.txt: Added.
  • http/wpt/cross-origin-options/allow-postmessage-from-deny.html: Added.
  • http/wpt/cross-origin-options/allow-postmessage-from-deny.html.headers: Added.
  • http/wpt/cross-origin-options/allow-postmessage.html: Added.
  • http/wpt/cross-origin-options/cross-origin-options-header-expected.txt: Added.
  • http/wpt/cross-origin-options/cross-origin-options-header.html: Added.
  • http/wpt/cross-origin-options/resources/cross-origin-options-allow-postmessage-pong.html: Added.
  • http/wpt/cross-origin-options/resources/cross-origin-options-allow-postmessage-pong.html.headers: Added.
  • http/wpt/cross-origin-options/resources/serve-cross-origin-options-header.py: Added.
Location:
trunk
Files:
13 added
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r231621 r231622  
     12018-05-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for 'Cross-Origin-Options' HTTP response header
     4        https://bugs.webkit.org/show_bug.cgi?id=184996
     5        <rdar://problem/39664620>
     6
     7        Reviewed by Geoff Garen.
     8
     9        Add layout test coverage.
     10
     11        * http/wpt/cross-origin-options/allow-postmessage-expected.txt: Added.
     12        * http/wpt/cross-origin-options/allow-postmessage-from-deny-expected.txt: Added.
     13        * http/wpt/cross-origin-options/allow-postmessage-from-deny.html: Added.
     14        * http/wpt/cross-origin-options/allow-postmessage-from-deny.html.headers: Added.
     15        * http/wpt/cross-origin-options/allow-postmessage.html: Added.
     16        * http/wpt/cross-origin-options/cross-origin-options-header-expected.txt: Added.
     17        * http/wpt/cross-origin-options/cross-origin-options-header.html: Added.
     18        * http/wpt/cross-origin-options/resources/cross-origin-options-allow-postmessage-pong.html: Added.
     19        * http/wpt/cross-origin-options/resources/cross-origin-options-allow-postmessage-pong.html.headers: Added.
     20        * http/wpt/cross-origin-options/resources/serve-cross-origin-options-header.py: Added.
     21
    1222018-05-09  Ryosuke Niwa  <rniwa@webkit.org>
    223
  • trunk/Source/WebCore/ChangeLog

    r231621 r231622  
     12018-05-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for 'Cross-Origin-Options' HTTP response header
     4        https://bugs.webkit.org/show_bug.cgi?id=184996
     5        <rdar://problem/39664620>
     6
     7        Reviewed by Geoff Garen.
     8
     9        Add initial support for 'Cross-Origin-Options' HTTP response header behind an experimental
     10        feature flag, on by default. When the HTTP server services this HTTP response header for a
     11        main resource, we'll set these options on the corresponding Document. This will impact the
     12        behavior of the Document's associated Window API when cross-origin.
     13
     14        The HTTP header has 3 possible values:
     15        - allow: This is the default. Regular cross-origin Window API is available.
     16        - allow-postmessage: Only postMessage() is available on a cross-origin window, trying to
     17          access anything else will throw a SecurityError.
     18        - deny: Trying to do anything with a cross-origin window will throw a SecurityError.
     19
     20        The header has no effect when accessing same origin windows.
     21
     22        Note that on cross-origin access from Window A to Window B, we check the cross-origin
     23        options for both Window A and Window B and use the lowest common denominator as effective
     24        cross-origin options for the access. So if Window A has 'Cross-Origin-Options: deny' and
     25        tries to call postMessage() on Window B which has 'Cross-Origin-Options: allow-postmessage',
     26        we will throw a SecurityError. This is because Window A's more restrictive options (deny)
     27        apply.
     28
     29        Tests: http/wpt/cross-origin-options/allow-postmessage-from-deny.html
     30               http/wpt/cross-origin-options/allow-postmessage.html
     31               http/wpt/cross-origin-options/cross-origin-options-header.html
     32
     33        * bindings/js/JSDOMBindingSecurity.cpp:
     34        (WebCore::BindingSecurity::shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions):
     35        * bindings/js/JSDOMBindingSecurity.h:
     36        * bindings/js/JSDOMWindowCustom.cpp:
     37        (WebCore::effectiveCrossOriginOptionsForAccess):
     38        (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
     39        (WebCore::JSDOMWindow::getOwnPropertySlot):
     40        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
     41        (WebCore::addCrossOriginWindowPropertyNames):
     42        (WebCore::addScopedChildrenIndexes):
     43        (WebCore::addCrossOriginWindowOwnPropertyNames):
     44        (WebCore::JSDOMWindow::getOwnPropertyNames):
     45        * bindings/js/JSDOMWindowCustom.h:
     46        * bindings/js/JSRemoteDOMWindowCustom.cpp:
     47        (WebCore::JSRemoteDOMWindow::getOwnPropertySlot):
     48        (WebCore::JSRemoteDOMWindow::getOwnPropertySlotByIndex):
     49        (WebCore::JSRemoteDOMWindow::getOwnPropertyNames):
     50        * bindings/scripts/CodeGeneratorJS.pm:
     51        (GenerateAttributeGetterBodyDefinition):
     52        (GetCrossOriginsOptionsFromExtendedAttributeValue):
     53        (GenerateAttributeSetterBodyDefinition):
     54        (GenerateOperationBodyDefinition):
     55        * bindings/scripts/IDLAttributes.json:
     56        * dom/Document.cpp:
     57        (WebCore::Document::setCrossOriginOptions):
     58        * dom/Document.h:
     59        (WebCore::Document::crossOriginOptions const):
     60        * loader/FrameLoader.cpp:
     61        (WebCore::FrameLoader::didBeginDocument):
     62        * page/AbstractDOMWindow.cpp:
     63        (WebCore::AbstractDOMWindow::AbstractDOMWindow):
     64        * page/AbstractDOMWindow.h:
     65        (WebCore::AbstractDOMWindow::crossOriginOptions):
     66        (WebCore::AbstractDOMWindow::setCrossOriginOptions):
     67        * page/DOMWindow.cpp:
     68        (WebCore::DOMWindow::DOMWindow):
     69        (WebCore::DOMWindow::didSecureTransitionTo):
     70        * page/DOMWindow.idl:
     71        * page/Frame.h:
     72        * page/RemoteDOMWindow.cpp:
     73        (WebCore::RemoteDOMWindow::RemoteDOMWindow):
     74        * page/RemoteDOMWindow.h:
     75        * page/Settings.yaml:
     76        * platform/network/HTTPHeaderNames.in:
     77        * platform/network/HTTPParsers.cpp:
     78        (WebCore::parseCrossOriginOptionsHeader):
     79        * platform/network/HTTPParsers.h:
     80
    1812018-05-09  Ryosuke Niwa  <rniwa@webkit.org>
    282
  • trunk/Source/WebCore/bindings/js/JSDOMBindingSecurity.cpp

    r230864 r231622  
    2626#include "Document.h"
    2727#include "Frame.h"
     28#include "HTTPParsers.h"
    2829#include "JSDOMExceptionHandling.h"
    2930#include "JSDOMWindowBase.h"
    … …  
    100101}
    101102
     103bool BindingSecurity::shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions(JSC::ExecState* state, DOMWindow& target, CrossOriginOptions minimumCrossOriginOptions, SecurityReportingOption reportingOption)
     104{
     105    DOMWindow& source = activeDOMWindow(*state);
     106    ASSERT(minimumCrossOriginOptions > CrossOriginOptions::Deny);
     107
     108    static_assert(CrossOriginOptions::Deny < CrossOriginOptions::AllowPostMessage && CrossOriginOptions::AllowPostMessage < CrossOriginOptions::Allow, "More restrictive cross-origin options should have lower values");
     109
     110    // Fast path.
     111    auto effectiveCrossOriginOptions = std::min(source.crossOriginOptions(), target.crossOriginOptions());
     112    if (effectiveCrossOriginOptions >= minimumCrossOriginOptions)
     113        return true;
     114
     115    return shouldAllowAccessToDOMWindow(state, target, reportingOption);
     116}
     117
    102118} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSDOMBindingSecurity.h

    r211403 r231622  
    3737class Node;
    3838
     39enum class CrossOriginOptions;
     40
    3941void printErrorMessageForFrame(Frame*, const String& message);
    4042
    … …  
    5355bool shouldAllowAccessToFrame(JSC::ExecState&, Frame&, String& message);
    5456bool shouldAllowAccessToNode(JSC::ExecState&, Node*);
     57
     58bool shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions(JSC::ExecState*, DOMWindow&, CrossOriginOptions, SecurityReportingOption = LogSecurityError);
    5559
    5660};
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r231037 r231622  
    2727#include "HTMLDocument.h"
    2828#include "HTMLFrameOwnerElement.h"
     29#include "HTTPParsers.h"
    2930#include "JSDOMBindingSecurity.h"
    3031#include "JSDOMConvertNullable.h"
    … …  
    5657using namespace JSC;
    5758
     59static CrossOriginOptions effectiveCrossOriginOptionsForAccess(ExecState& state, AbstractDOMWindow& target)
     60{
     61    static_assert(CrossOriginOptions::Deny < CrossOriginOptions::AllowPostMessage && CrossOriginOptions::AllowPostMessage < CrossOriginOptions::Allow, "More restrictive cross-origin options should have lower values");
     62    return std::min(activeDOMWindow(state).crossOriginOptions(), target.crossOriginOptions());
     63}
     64
    5865EncodedJSValue JSC_HOST_CALL jsDOMWindowInstanceFunctionShowModalDialog(ExecState*);
    5966
    … …  
    8188
    8289template <DOMWindowType windowType>
    83 bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMGlobalObject* thisObject, AbstractFrame* frame, ExecState* exec, PropertyName propertyName, PropertySlot& slot, const String& errorMessage)
    84 {
    85     VM& vm = exec->vm();
     90bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMGlobalObject* thisObject, AbstractDOMWindow& window, ExecState& state, PropertyName propertyName, PropertySlot& slot, const String& errorMessage)
     91{
     92    VM& vm = state.vm();
    8693    auto scope = DECLARE_THROW_SCOPE(vm);
    8794
    … …  
    9299        slot.setValue(thisObject, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum, jsUndefined());
    93100        return true;
     101    }
     102
     103    switch (effectiveCrossOriginOptionsForAccess(state, window)) {
     104    case CrossOriginOptions::AllowPostMessage:
     105        if (propertyName == builtinNames.postMessagePublicName()) {
     106            slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionPostMessage, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>);
     107            return true;
     108        }
     109        FALLTHROUGH;
     110    case CrossOriginOptions::Deny:
     111        throwSecurityError(state, scope, errorMessage);
     112        slot.setUndefined();
     113        return false;
     114    case CrossOriginOptions::Allow:
     115        break;
    94116    }
    95117
    … …  
    137159        // named getter from returning frames with matching names - this seems a little questionable, see
    138160        // FIXME comment on prototype search below.)
    139         throwSecurityError(*exec, scope, errorMessage);
     161        throwSecurityError(state, scope, errorMessage);
    140162        slot.setUndefined();
    141163        return false;
    … …  
    147169    // the Moz way.
    148170    // FIXME: Add support to named attributes on RemoteFrames.
     171    auto* frame = window.frame();
    149172    if (frame && is<Frame>(*frame)) {
    150173        if (auto* scopedChild = downcast<Frame>(*frame).tree().scopedChild(propertyNameToAtomicString(propertyName))) {
    151             slot.setValue(thisObject, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum, toJS(exec, scopedChild->document()->domWindow()));
     174            slot.setValue(thisObject, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum, toJS(&state, scopedChild->document()->domWindow()));
    152175            return true;
    153176        }
    154177    }
    155178
    156     throwSecurityError(*exec, scope, errorMessage);
     179    throwSecurityError(state, scope, errorMessage);
    157180    slot.setUndefined();
    158181    return false;
    159182}
    160 template bool jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Local>(JSDOMGlobalObject*, AbstractFrame*, ExecState*, PropertyName, PropertySlot&, const String&);
    161 template bool jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(JSDOMGlobalObject*, AbstractFrame*, ExecState*, PropertyName, PropertySlot&, const String&);
     183template bool jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Local>(JSDOMGlobalObject*, AbstractDOMWindow&, ExecState&, PropertyName, PropertySlot&, const String&);
     184template bool jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(JSDOMGlobalObject*, AbstractDOMWindow&, ExecState&, PropertyName, PropertySlot&, const String&);
    162185
    163186// Property access sequence is:
    … …  
    173196
    174197    auto* thisObject = jsCast<JSDOMWindow*>(object);
    175     auto* frame = thisObject->wrapped().frame();
    176198
    177199    // Hand off all cross-domain access to jsDOMWindowGetOwnPropertySlotRestrictedAccess.
    178200    String errorMessage;
    179201    if (!BindingSecurity::shouldAllowAccessToDOMWindow(*state, thisObject->wrapped(), errorMessage))
    180         return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Local>(thisObject, frame, state, propertyName, slot, errorMessage);
    181    
     202        return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Local>(thisObject, thisObject->wrapped(), *state, propertyName, slot, errorMessage);
     203
    182204    // FIXME: this need more explanation.
    183205    // (Particularly, is it correct that this exists here but not in getOwnPropertySlotByIndex?)
    … …  
    187209    PropertySlot slotCopy = slot;
    188210    if (Base::getOwnPropertySlot(thisObject, state, propertyName, slot)) {
     211        auto* frame = thisObject->wrapped().frame();
     212
    189213        // Detect when we're getting the property 'showModalDialog', this is disabled, and has its original value.
    190214        bool isShowModalDialogAndShouldHide = propertyName == static_cast<JSVMClientData*>(state->vm().clientData)->builtinNames().showModalDialogPublicName()
    … …  
    214238{
    215239    auto* thisObject = jsCast<JSDOMWindow*>(object);
    216     auto* frame = thisObject->wrapped().frame();
     240    auto& window = thisObject->wrapped();
     241    auto* frame = window.frame();
    217242
    218243    // Indexed getters take precendence over regular properties, so caching would be invalid.
    219244    slot.disableCaching();
    220245
     246    String errorMessage;
     247    std::optional<bool> cachedIsCrossOriginAccess;
     248    auto isCrossOriginAccess = [&] {
     249        if (!cachedIsCrossOriginAccess)
     250            cachedIsCrossOriginAccess = !BindingSecurity::shouldAllowAccessToDOMWindow(*state, window, errorMessage);
     251        return *cachedIsCrossOriginAccess;
     252    };
     253
    221254    // (1) First, indexed properties.
    222     // These are also allowed cross-orgin, so come before the access check.
    223     if (frame && index < frame->tree().scopedChildCount()) {
    224         slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), toJS(state, frame->tree().scopedChild(index)->document()->domWindow()));
    225         return true;
     255    // These are also allowed cross-origin, so come before the access check.
     256    switch (effectiveCrossOriginOptionsForAccess(*state, window)) {
     257    case CrossOriginOptions::Deny:
     258    case CrossOriginOptions::AllowPostMessage:
     259        if (isCrossOriginAccess())
     260            break;
     261        FALLTHROUGH;
     262    case CrossOriginOptions::Allow:
     263        if (frame && index < frame->tree().scopedChildCount()) {
     264            slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), toJS(state, frame->tree().scopedChild(index)->document()->domWindow()));
     265            return true;
     266        }
     267        break;
    226268    }
    227269
    228270    // Hand off all cross-domain/frameless access to jsDOMWindowGetOwnPropertySlotRestrictedAccess.
    229     String errorMessage;
    230     if (!BindingSecurity::shouldAllowAccessToDOMWindow(*state, thisObject->wrapped(), errorMessage))
    231         return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Local>(thisObject, frame, state, Identifier::from(state, index), slot, errorMessage);
     271    if (isCrossOriginAccess())
     272        return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Local>(thisObject, window, *state, Identifier::from(state, index), slot, errorMessage);
    232273
    233274    // (2) Regular own properties.
    … …  
    288329
    289330// https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
    290 static void addCrossOriginWindowPropertyNames(VM& vm, PropertyNameArray& propertyNames)
    291 {
     331static void addCrossOriginWindowPropertyNames(ExecState& state, AbstractDOMWindow& window, PropertyNameArray& propertyNames)
     332{
     333    auto& vm = state.vm();
     334
    292335    static const Identifier* const properties[] = {
    293336        &static_cast<JSVMClientData*>(vm.clientData)->builtinNames().blurPublicName(),
    … …  
    305348        &static_cast<JSVMClientData*>(vm.clientData)->builtinNames().windowPublicName()
    306349    };
    307     for (auto* property : properties)
    308         propertyNames.add(*property);
     350
     351    switch (effectiveCrossOriginOptionsForAccess(state, window)) {
     352    case CrossOriginOptions::Allow:
     353        for (auto* property : properties)
     354            propertyNames.add(*property);
     355        break;
     356    case CrossOriginOptions::AllowPostMessage:
     357        propertyNames.add(static_cast<JSVMClientData*>(vm.clientData)->builtinNames().postMessagePublicName());
     358        break;
     359    case CrossOriginOptions::Deny:
     360        break;
     361    }
    309362}
    310363
    … …  
    319372        return;
    320373
     374    switch (effectiveCrossOriginOptionsForAccess(state, window)) {
     375    case CrossOriginOptions::Allow:
     376        break;
     377    case CrossOriginOptions::Deny:
     378    case CrossOriginOptions::AllowPostMessage:
     379        return;
     380    }
     381
    321382    unsigned scopedChildCount = frame->tree().scopedChildCount();
    322383    for (unsigned i = 0; i < scopedChildCount; ++i)
    … …  
    325386
    326387// https://html.spec.whatwg.org/#crossoriginownpropertykeys-(-o-)
    327 void addCrossOriginWindowOwnPropertyNames(ExecState& state, PropertyNameArray& propertyNames)
    328 {
    329     VM& vm = state.vm();
    330     addCrossOriginWindowPropertyNames(vm, propertyNames);
    331 
     388void addCrossOriginWindowOwnPropertyNames(ExecState& state, AbstractDOMWindow& window, PropertyNameArray& propertyNames)
     389{
     390    addCrossOriginWindowPropertyNames(state, window, propertyNames);
     391
     392    auto& vm = state.vm();
    332393    propertyNames.add(vm.propertyNames->toStringTagSymbol);
    333394    propertyNames.add(vm.propertyNames->hasInstanceSymbol);
    … …  
    344405    if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), DoNotReportSecurityError)) {
    345406        if (mode.includeDontEnumProperties())
    346             addCrossOriginWindowOwnPropertyNames(*exec, propertyNames);
     407            addCrossOriginWindowOwnPropertyNames(*exec, thisObject->wrapped(), propertyNames);
    347408        return;
    348409    }
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.h

    r230715 r231622  
    2323namespace WebCore {
    2424
     25class AbstractDOMWindow;
    2526class AbstractFrame;
    2627
    … …  
    3839
    3940template <DOMWindowType windowType>
    40 bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMGlobalObject*, AbstractFrame*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&, const String&);
     41bool jsDOMWindowGetOwnPropertySlotRestrictedAccess(JSDOMGlobalObject*, AbstractDOMWindow&, JSC::ExecState&, JSC::PropertyName, JSC::PropertySlot&, const String&);
    4142
    42 void addCrossOriginWindowOwnPropertyNames(JSC::ExecState&, JSC::PropertyNameArray&);
     43void addCrossOriginWindowOwnPropertyNames(JSC::ExecState&, AbstractDOMWindow&, JSC::PropertyNameArray&);
    4344
    4445} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp

    r230715 r231622  
    3838
    3939    auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
    40     auto* frame = thisObject->wrapped().frame();
    41 
    42     return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, frame, state, propertyName, slot, String());
     40    return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *state, propertyName, slot, String());
    4341}
    4442
    … …  
    4644{
    4745    auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
    48     auto* frame = thisObject->wrapped().frame();
    4946
    5047    // Indexed getters take precendence over regular properties, so caching would be invalid.
    … …  
    5350    // FIXME: Add support for indexed properties.
    5451
    55     return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, frame, state, Identifier::from(state, index), slot, String());
     52    return jsDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *state, Identifier::from(state, index), slot, String());
    5653}
    5754
    … …  
    10198}
    10299
    103 void JSRemoteDOMWindow::getOwnPropertyNames(JSObject*, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
     100void JSRemoteDOMWindow::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    104101{
     102    auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
     103
    105104    // FIXME: Add scoped children indexes.
    106105
    107106    if (mode.includeDontEnumProperties())
    108         addCrossOriginWindowOwnPropertyNames(*exec, propertyNames);
     107        addCrossOriginWindowOwnPropertyNames(*exec, thisObject->wrapped(), propertyNames);
    109108}
    110109
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r231114 r231622  
    47074707        AddToImplIncludes("JSDOMBindingSecurity.h", $conditional);
    47084708        if ($interface->type->name eq "DOMWindow") {
    4709             push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, thisObject.wrapped(), ThrowSecurityError))\n");
     4709            if ($attribute->extendedAttributes->{DoNotCheckSecurityIf}) {
     4710                my $crossOriginOptions = GetCrossOriginsOptionsFromExtendedAttributeValue($attribute->extendedAttributes->{DoNotCheckSecurityIf});
     4711                AddToImplIncludes("HTTPParsers.h", $conditional);
     4712                push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions(&state, thisObject.wrapped(), $crossOriginOptions, ThrowSecurityError))\n");
     4713            } else {
     4714                push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, thisObject.wrapped(), ThrowSecurityError))\n");
     4715            }
    47104716        } else {
    47114717            push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToFrame(&state, thisObject.wrapped().frame(), ThrowSecurityError))\n");
    … …  
    48154821}
    48164822
     4823sub GetCrossOriginsOptionsFromExtendedAttributeValue
     4824{
     4825    my $extendedAttributeValue = shift;
     4826
     4827    return "CrossOriginOptions::Allow" if $extendedAttributeValue eq "CrossOriginOptionsAllow";
     4828    return "CrossOriginOptions::AllowPostMessage" if $extendedAttributeValue eq "CrossOriginOptionsAllowPostMessage";
     4829    die "Unsupported CrossOriginOptions: " + $extendedAttributeValue;
     4830}
     4831
    48174832sub GenerateAttributeSetterBodyDefinition
    48184833{
    … …  
    48374852        AddToImplIncludes("JSDOMBindingSecurity.h", $conditional);
    48384853        if ($interface->type->name eq "DOMWindow") {
    4839             push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, thisObject.wrapped(), ThrowSecurityError))\n");
     4854            if ($attribute->extendedAttributes->{DoNotCheckSecurityIf}) {
     4855                my $crossOriginOptions = GetCrossOriginsOptionsFromExtendedAttributeValue($attribute->extendedAttributes->{DoNotCheckSecurityIf});
     4856                AddToImplIncludes("HTTPParsers.h", $conditional);
     4857                push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions(&state, thisObject.wrapped(), $crossOriginOptions, ThrowSecurityError))\n");
     4858            } else {
     4859                push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, thisObject.wrapped(), ThrowSecurityError))\n");
     4860            }
    48404861        } else {
    48414862            push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToFrame(&state, thisObject.wrapped().frame(), ThrowSecurityError))\n");
    … …  
    50585079            AddToImplIncludes("JSDOMBindingSecurity.h", $conditional);
    50595080            if ($interface->type->name eq "DOMWindow") {
    5060                 push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, castedThis->wrapped(), ThrowSecurityError))\n");
     5081                if ($operation->extendedAttributes->{DoNotCheckSecurityIf}) {
     5082                    my $crossOriginOptions = GetCrossOriginsOptionsFromExtendedAttributeValue($operation->extendedAttributes->{DoNotCheckSecurityIf});
     5083                    AddToImplIncludes("HTTPParsers.h", $conditional);
     5084                    push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindowGivenMinimumCrossOriginOptions(state, castedThis->wrapped(), $crossOriginOptions, ThrowSecurityError))\n");
     5085                } else {
     5086                    push(@$outputArray, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, castedThis->wrapped(), ThrowSecurityError))\n");
     5087                }
    50615088                push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
    50625089            } else {
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.json

    r226088 r231622  
    162162            "contextsAllowed": ["attribute", "operation"]
    163163        },
     164        "DoNotCheckSecurityIf": {
     165            "contextsAllowed": ["attribute", "operation"],
     166            "values": ["CrossOriginOptionsAllow", "CrossOriginOptionsAllowPostMessage"]
     167        },
    164168        "DoNotCheckSecurityOnGetter": {
    165169            "contextsAllowed": ["attribute"]
  • trunk/Source/WebCore/dom/Document.cpp

    r231557 r231622  
    518518    , m_cookieCacheExpiryTimer(*this, &Document::invalidateDOMCookieCache)
    519519    , m_socketProvider(page() ? &page()->socketProvider() : nullptr)
     520    , m_crossOriginOptions { CrossOriginOptions::Allow }
    520521    , m_isSynthesized(constructionFlags & Synthesized)
    521522    , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder)
    … …  
    78077808}
    78087809
     7810void Document::setCrossOriginOptions(CrossOriginOptions value)
     7811{
     7812    m_crossOriginOptions = value;
     7813    if (auto* window = domWindow())
     7814        window->setCrossOriginOptions(value);
     7815}
     7816
    78097817} // namespace WebCore
  • trunk/Source/WebCore/dom/Document.h

    r231557 r231622  
    195195
    196196enum CollectionType;
     197enum class CrossOriginOptions;
    197198enum class ShouldOpenExternalURLsPolicy;
    198199
    … …  
    14311432    String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&);
    14321433
     1434    CrossOriginOptions crossOriginOptions() const { return m_crossOriginOptions; }
     1435    void setCrossOriginOptions(CrossOriginOptions value);
     1436
    14331437protected:
    14341438    enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
    … …  
    18161820    unsigned m_writeRecursionDepth { 0 };
    18171821
     1822    CrossOriginOptions m_crossOriginOptions;
     1823
    18181824    InheritedBool m_designMode { inherit };
    18191825    MediaProducer::MediaStateFlags m_mediaState { MediaProducer::IsNotPlaying };
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r231548 r231622  
    743743                m_frame.document()->setContentLanguage(headerContentLanguage);
    744744        }
     745
     746        if (m_frame.settings().crossOriginOptionsSupportEnabled()) {
     747            String crossOriginOptionsHeader = m_documentLoader->response().httpHeaderField(HTTPHeaderName::CrossOriginOptions);
     748            if (!crossOriginOptionsHeader.isEmpty())
     749                m_frame.document()->setCrossOriginOptions(parseCrossOriginOptionsHeader(crossOriginOptionsHeader));
     750        }
    745751    }
    746752
  • trunk/Source/WebCore/page/AbstractDOMWindow.cpp

    r230613 r231622  
    3838}
    3939
    40 AbstractDOMWindow::AbstractDOMWindow(GlobalWindowIdentifier&& identifier)
     40AbstractDOMWindow::AbstractDOMWindow(GlobalWindowIdentifier&& identifier, CrossOriginOptions crossOriginOptions)
    4141    : m_identifier(WTFMove(identifier))
     42    , m_crossOriginOptions(crossOriginOptions)
    4243{
    4344    ASSERT(!allWindows().contains(identifier));
  • trunk/Source/WebCore/page/AbstractDOMWindow.h

    r230613 r231622  
    3636class AbstractFrame;
    3737
     38enum class CrossOriginOptions;
     39
    3840// FIXME: Rename DOMWindow to LocalWindow and AbstractDOMWindow to DOMWindow.
    3941class AbstractDOMWindow : public RefCounted<AbstractDOMWindow>, public EventTargetWithInlineData {
    … …  
    5355    using RefCounted::deref;
    5456
     57    CrossOriginOptions crossOriginOptions() { return m_crossOriginOptions; }
     58    void setCrossOriginOptions(CrossOriginOptions value) { m_crossOriginOptions = value; }
     59
    5560protected:
    56     explicit AbstractDOMWindow(GlobalWindowIdentifier&&);
     61    AbstractDOMWindow(GlobalWindowIdentifier&&, CrossOriginOptions);
    5762
    5863    EventTargetInterface eventTargetInterface() const final { return DOMWindowEventTargetInterfaceType; }
    … …  
    6267private:
    6368    GlobalWindowIdentifier m_identifier;
     69    CrossOriginOptions m_crossOriginOptions;
    6470};
    6571
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r231114 r231622  
    403403
    404404DOMWindow::DOMWindow(Document& document)
    405     : AbstractDOMWindow(GlobalWindowIdentifier { Process::identifier(), generateObjectIdentifier<WindowIdentifierType>() })
     405    : AbstractDOMWindow(GlobalWindowIdentifier { Process::identifier(), generateObjectIdentifier<WindowIdentifierType>() }, document.crossOriginOptions())
    406406    , ContextDestructionObserver(&document)
    407407    , FrameDestructionObserver(document.frame())
    … …  
    414414{
    415415    observeContext(&document);
     416    setCrossOriginOptions(document.crossOriginOptions());
    416417}
    417418
  • trunk/Source/WebCore/page/DOMWindow.idl

    r230867 r231622  
    5050] interface DOMWindow : EventTarget {
    5151    // The current browsing context.
    52     [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute WindowProxy window;
    53     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy self;
     52    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, Unforgeable, ImplementedAs=self] readonly attribute WindowProxy window;
     53    [Replaceable, DoNotCheckSecurityIf=CrossOriginOptionsAllow] readonly attribute WindowProxy self;
    5454    [Unforgeable] readonly attribute Document document;
    5555    attribute DOMString name;
    56     [DoNotCheckSecurity, PutForwards=href, Unforgeable] readonly attribute Location? location; // FIXME: Should not be nullable.
     56    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, PutForwards=href, Unforgeable] readonly attribute Location? location; // FIXME: Should not be nullable.
    5757    readonly attribute History history;
    5858    [EnabledAtRuntime=CustomElements, ImplementedAs=ensureCustomElementRegistry] readonly attribute CustomElementRegistry customElements;
    … …  
    6464    [Replaceable] readonly attribute BarProp toolbar;
    6565    attribute DOMString status;
    66     [DoNotCheckSecurity, CallWith=IncumbentDocument, ForwardDeclareInHeader] void close();
    67     [DoNotCheckSecurity, ForwardDeclareInHeader] readonly attribute boolean closed;
     66    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, CallWith=IncumbentDocument, ForwardDeclareInHeader] void close();
     67    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, ForwardDeclareInHeader] readonly attribute boolean closed;
    6868    void stop();
    69     [DoNotCheckSecurity, CallWith=IncumbentWindow, ForwardDeclareInHeader] void focus();
    70     [DoNotCheckSecurity, ForwardDeclareInHeader] void blur();
     69    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, CallWith=IncumbentWindow, ForwardDeclareInHeader] void focus();
     70    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, ForwardDeclareInHeader] void blur();
    7171
    7272    // Other browsing contexts.
    73     [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute WindowProxy frames;
    74     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
    75     [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute WindowProxy? top;
    76     [DoNotCheckSecurityOnGetter, CustomSetter] attribute WindowProxy? opener;
    77     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy? parent;
     73    [Replaceable, DoNotCheckSecurityIf=CrossOriginOptionsAllow, ImplementedAs=self] readonly attribute WindowProxy frames;
     74    [Replaceable, DoNotCheckSecurityIf=CrossOriginOptionsAllow] readonly attribute unsigned long length;
     75    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, Unforgeable] readonly attribute WindowProxy? top;
     76    [DoNotCheckSecurityIf=CrossOriginOptionsAllow, CustomSetter] attribute WindowProxy? opener;
     77    [Replaceable, DoNotCheckSecurityIf=CrossOriginOptionsAllow] readonly attribute WindowProxy? parent;
    7878    [CheckSecurityForNode] readonly attribute Element? frameElement;
    7979    [CallWith=ActiveWindow&FirstWindow] WindowProxy? open(optional USVString url = "about:blank", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");
    … …  
    9393    void cancelAnimationFrame(long handle); // FIXME: handle should be an unsigned long.
    9494
    95     [CallWith=ScriptState&IncumbentWindow, DoNotCheckSecurity, ForwardDeclareInHeader, MayThrowException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
     95    [CallWith=ScriptState&IncumbentWindow, DoNotCheckSecurityIf=CrossOriginOptionsAllowPostMessage, ForwardDeclareInHeader, MayThrowException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
    9696
    9797    // Obsolete members, still part of the HTML specification (https://html.spec.whatwg.org/#Window-partial).
  • trunk/Source/WebCore/page/Frame.h

    r230764 r231622  
    137137    WEBCORE_EXPORT ~Frame();
    138138
    139     DOMWindow* window() const;
     139    WEBCORE_EXPORT DOMWindow* window() const;
    140140
    141141    void addDestructionObserver(FrameDestructionObserver*);
  • trunk/Source/WebCore/page/RemoteDOMWindow.cpp

    r231037 r231622  
    3333namespace WebCore {
    3434
    35 RemoteDOMWindow::RemoteDOMWindow(Ref<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier)
    36     : AbstractDOMWindow(WTFMove(identifier))
     35RemoteDOMWindow::RemoteDOMWindow(Ref<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier, CrossOriginOptions crossOriginOptions)
     36    : AbstractDOMWindow(WTFMove(identifier), crossOriginOptions)
    3737    , m_frame(WTFMove(frame))
    3838{
  • trunk/Source/WebCore/page/RemoteDOMWindow.h

    r231037 r231622  
    4545class RemoteDOMWindow final : public AbstractDOMWindow {
    4646public:
    47     static Ref<RemoteDOMWindow> create(Ref<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier)
     47    static Ref<RemoteDOMWindow> create(Ref<RemoteFrame>&& frame, GlobalWindowIdentifier&& identifier, CrossOriginOptions crossOriginOptions)
    4848    {
    49         return adoptRef(*new RemoteDOMWindow(WTFMove(frame), WTFMove(identifier)));
     49        return adoptRef(*new RemoteDOMWindow(WTFMove(frame), WTFMove(identifier), crossOriginOptions));
    5050    }
    5151
    … …  
    6969
    7070private:
    71     WEBCORE_EXPORT RemoteDOMWindow(Ref<RemoteFrame>&&, GlobalWindowIdentifier&&);
     71    WEBCORE_EXPORT RemoteDOMWindow(Ref<RemoteFrame>&&, GlobalWindowIdentifier&&, CrossOriginOptions);
    7272
    7373    bool isRemoteDOMWindow() const final { return true; }
  • trunk/Source/WebCore/page/Settings.yaml

    r231479 r231622  
    743743  onChange: setNeedsRecalcStyleInAllFrames
    744744
     745crossOriginOptionsSupportEnabled:
     746  initial: true
     747
    745748accessibilityEventsEnabled:
    746749  initial: true
  • trunk/Source/WebCore/platform/network/HTTPHeaderNames.in

    r230968 r231622  
    5151Cookie
    5252Cookie2
     53Cross-Origin-Options
    5354Date
    5455DNT
  • trunk/Source/WebCore/platform/network/HTTPParsers.cpp

    r230968 r231622  
    914914}
    915915
    916 }
     916CrossOriginOptions parseCrossOriginOptionsHeader(StringView header)
     917{
     918    auto strippedHeader = stripLeadingAndTrailingHTTPSpaces(header);
     919    if (strippedHeader.isEmpty())
     920        return CrossOriginOptions::Allow;
     921
     922    if (equalLettersIgnoringASCIICase(strippedHeader, "deny"))
     923        return CrossOriginOptions::Deny;
     924
     925    if (equalLettersIgnoringASCIICase(strippedHeader, "allow-postmessage"))
     926        return CrossOriginOptions::AllowPostMessage;
     927
     928    return CrossOriginOptions::Allow;
     929}
     930
     931}
  • trunk/Source/WebCore/platform/network/HTTPParsers.h

    r231479 r231622  
    7272};
    7373
     74// Should be sorted from most restrictive to most permissive.
     75enum class CrossOriginOptions {
     76    Deny,
     77    AllowPostMessage,
     78    Allow,
     79};
     80
    7481bool isValidReasonPhrase(const String&);
    7582bool isValidHTTPHeaderValue(const String&);
    … …  
    112119
    113120WEBCORE_EXPORT FromOriginDisposition parseFromOriginHeader(const String&);
     121CrossOriginOptions parseCrossOriginOptionsHeader(StringView);
    114122
    115123inline bool isHTTPSpace(UChar character)
  • trunk/Source/WebKit/ChangeLog

    r231606 r231622  
     12018-05-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for 'Cross-Origin-Options' HTTP response header
     4        https://bugs.webkit.org/show_bug.cgi?id=184996
     5        <rdar://problem/39664620>
     6
     7        Reviewed by Geoff Garen.
     8
     9        * Shared/WebPreferences.yaml:
     10        Add this as an experimental feature, on by default.
     11
     12        * WebProcess/WebPage/WebPage.cpp:
     13        (WebKit::WebPage::frameBecameRemote):
     14        Make sure we pass the cross-origin options from the local Window
     15        to the remote one when transitioning.
     16
    1172018-05-09  Wenson Hsieh  <wenson_hsieh@apple.com>
    218
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r231457 r231622  
    10981098  category: experimental
    10991099
     1100CrossOriginOptionsSupportEnabled:
     1101  type: bool
     1102  defaultValue: true
     1103  humanReadableName: "Cross-Origin-Options HTTP Header"
     1104  humanReadableDescription: "Enable support for Cross-Origin-Options HTTP Header"
     1105  category: experimental
     1106
    11001107SpringTimingFunctionEnabled:
    11011108  type: bool
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r231479 r231622  
    59065906        return;
    59075907
     5908    auto* coreFrame = frame->coreFrame();
     5909    auto* previousWindow = coreFrame->window();
     5910    if (!previousWindow)
     5911        return;
     5912
    59085913    auto remoteFrame = RemoteFrame::create(WTFMove(remoteFrameIdentifier));
    5909     auto remoteWindow = RemoteDOMWindow::create(remoteFrame.copyRef(), WTFMove(remoteWindowIdentifier));
     5914    auto remoteWindow = RemoteDOMWindow::create(remoteFrame.copyRef(), WTFMove(remoteWindowIdentifier), previousWindow->crossOriginOptions());
    59105915    UNUSED_PARAM(remoteWindow);
    59115916
    … …  
    59165921    remoteFrame->windowProxy().setDOMWindow(remoteWindow.ptr());
    59175922
    5918     auto* coreFrame = frame->coreFrame();
    59195923    coreFrame->setView(nullptr);
    59205924    coreFrame->willDetachPage();
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h

    r231082 r231622  
    174174#define WebKitCustomPasteboardDataEnabledPreferenceKey @"WebKitCustomPasteboardDataEnabled"
    175175#define WebKitCacheAPIEnabledPreferenceKey @"WebKitCacheAPIEnabled"
     176#define WebKitCrossOriginOptionsSupportEnabledPreferenceKey @"WebKitCrossOriginOptionsSupportEnabled"
    176177#define WebKitFetchAPIEnabledPreferenceKey @"WebKitFetchAPIEnabled"
    177178#define WebKitWritableStreamAPIEnabledPreferenceKey @"WebKitWritableStreamAPIEnabled"
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm

    r231082 r231622  
    635635#endif
    636636        [NSNumber numberWithBool:NO], WebKitCacheAPIEnabledPreferenceKey,
     637        [NSNumber numberWithBool:NO], WebKitCrossOriginOptionsSupportEnabledPreferenceKey,
    637638        [NSNumber numberWithBool:YES], WebKitFetchAPIEnabledPreferenceKey,
    638639
    … …  
    30103011}
    30113012
     3013- (BOOL)crossOriginOptionsSupportEnabled
     3014{
     3015    return [self _boolValueForKey:WebKitCrossOriginOptionsSupportEnabledPreferenceKey];
     3016}
     3017
     3018- (void)setCrossOriginOptionsSupportEnabled:(BOOL)flag
     3019{
     3020    [self _setBoolValue:flag forKey:WebKitCrossOriginOptionsSupportEnabledPreferenceKey];
     3021}
     3022
    30123023- (BOOL)fetchAPIEnabled
    30133024{
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h

    r231383 r231622  
    544544- (void)setCacheAPIEnabled:(BOOL)enabled;
    545545
     546- (BOOL)crossOriginOptionsSupportEnabled;
     547- (void)setCrossOriginOptionsSupportEnabled:(BOOL)enabled;
     548
    546549- (void)setFetchAPIEnabled:(BOOL)flag;
    547550- (BOOL)fetchAPIEnabled;
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r231201 r231622  
    30633063    settings.setConstantPropertiesEnabled([preferences constantPropertiesEnabled]);
    30643064    settings.setColorFilterEnabled([preferences colorFilterEnabled]);
     3065    settings.setCrossOriginOptionsSupportEnabled([preferences crossOriginOptionsSupportEnabled]);
    30653066
    30663067#if ENABLE(GAMEPAD)
  • trunk/Source/WebKitLegacy/win/Interfaces/IWebPreferencesPrivate.idl

    r229578 r231622  
    229229    HRESULT setMenuItemElementEnabled([in] BOOL enabled);
    230230}
     231
     232[uuid(9A49D1DE-53DD-11E8-95E6-003EE1C28AB6)]
     233interface IWebPreferencesPrivate7 : IWebPreferencesPrivate6
     234{
     235    HRESULT crossOriginOptionsSupportEnabled([out, retval] BOOL* enabled);
     236    HRESULT setCrossOriginOptionsSupportEnabled([in] BOOL enabled);
     237}
  • trunk/Source/WebKitLegacy/win/WebPreferenceKeysPrivate.h

    r229578 r231622  
    181181#define WebKitMenuItemElementEnabledPreferenceKey "WebKitMenuItemElementEnabled"
    182182
     183#define WebKitCrossOriginOptionsSupportEnabledPreferenceKey "WebKitCrossOriginOptionsSupportEnabled"
     184
    183185#define WebKitModernMediaControlsEnabledPreferenceKey "WebKitModernMediaControlsEnabled"
    184186
  • trunk/Source/WebKitLegacy/win/WebPreferences.cpp

    r230736 r231622  
    250250    CFDictionaryAddValue(defaults, CFSTR(WebKitShouldDisplayCaptionsPreferenceKey), kCFBooleanFalse);
    251251    CFDictionaryAddValue(defaults, CFSTR(WebKitShouldDisplayTextDescriptionsPreferenceKey), kCFBooleanFalse);
     252    CFDictionaryAddValue(defaults, CFSTR(WebKitCrossOriginOptionsSupportEnabledPreferenceKey), kCFBooleanFalse);
    252253
    253254    RetainPtr<CFStringRef> linkBehaviorStringRef = adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("%d"), WebKitEditableLinkDefaultBehavior));
    … …  
    20302031}
    20312032
     2033HRESULT WebPreferences::crossOriginOptionsSupportEnabled(_Out_ BOOL* enabled)
     2034{
     2035    if (!enabled)
     2036        return E_POINTER;
     2037    *enabled = boolValueForKey(WebKitCrossOriginOptionsSupportEnabledPreferenceKey);
     2038    return S_OK;
     2039}
     2040
     2041HRESULT WebPreferences::setCrossOriginOptionsSupportEnabled(BOOL enabled)
     2042{
     2043    setBoolValue(WebKitCrossOriginOptionsSupportEnabledPreferenceKey, enabled);
     2044    return S_OK;
     2045}
     2046
    20322047HRESULT WebPreferences::setModernMediaControlsEnabled(BOOL enabled)
    20332048{
  • trunk/Source/WebKitLegacy/win/WebPreferences.h

    r229578 r231622  
    277277    virtual HRESULT STDMETHODCALLTYPE setMenuItemElementEnabled(BOOL);
    278278
     279    // IWebPreferencesPrivate7
     280    virtual HRESULT STDMETHODCALLTYPE crossOriginOptionsSupportEnabled(_Out_ BOOL*);
     281    virtual HRESULT STDMETHODCALLTYPE setCrossOriginOptionsSupportEnabled(BOOL);
     282
    279283    // WebPreferences
    280284
  • trunk/Source/WebKitLegacy/win/WebView.cpp

    r230211 r231622  
    51515151#endif
    51525152
    5153     COMPtr<IWebPreferencesPrivate6> prefsPrivate { Query, preferences };
     5153    COMPtr<IWebPreferencesPrivate7> prefsPrivate { Query, preferences };
    51545154    if (prefsPrivate) {
    51555155        hr = prefsPrivate->localStorageDatabasePath(&str);
    … …  
    52795279        return hr;
    52805280    settings.setVisualViewportAPIEnabled(!!enabled);
     5281
     5282    hr = prefsPrivate->crossOriginOptionsSupportEnabled(&enabled);
     5283    if (FAILED(hr))
     5284        return hr;
     5285    settings.setCrossOriginOptionsSupportEnabled(!!enabled);
    52815286
    52825287    hr = preferences->privateBrowsingEnabled(&enabled);
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r231082 r231622  
    863863    [preferences setVisualViewportAPIEnabled:YES];
    864864    [preferences setColorFilterEnabled:YES];
     865    [preferences setCrossOriginOptionsSupportEnabled:YES];
    865866}
    866867
  • trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp

    r229578 r231622  
    789789    // FIXME: WebGL2
    790790    // FIXME: WebRTC
     791    prefsPrivate->setCrossOriginOptionsSupportEnabled(TRUE);
    791792}
    792793
Note: See TracChangeset for help on using the changeset viewer.