<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196494] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196494">196494</a></dd>
<dt>Author</dt> <dd>barraclough@apple.com</dd>
<dt>Date</dt> <dd>2016-02-12 12:20:41 -0800 (Fri, 12 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Separate out !allowsAccess path in JSDOMWindowCustom getOwnPropertySlot
https://bugs.webkit.org/show_bug.cgi?id=154156

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* runtime/CommonIdentifiers.h:
    - added new property names, needed by jsDOMWindowGetOwnPropertySlotDisallowAccess.

Source/WebCore:

JSDOMWindowCustom getOwnPropertySlot currently allows cross-origin access to all
static properties, relying on the property to perform the access check. This is
a little insecure, since it is error prone - someone could easily add a property
to the static table without realizing it would be automatcially exposed.

Instead, add a hard-coded filter to restrict access. As a future implementation
we might consider autogenerating this (the properties are already tagged in IDL,
we might be able to track this in a flag on the static table).

By separating out the handling of the same- and cross-origin access we can
simplify &amp; make the policy being enforced much clearer.

* bindings/js/JSDOMBinding.cpp:
(WebCore::objectToStringFunctionGetter): Deleted.
    - removed objectToStringFunctionGetter - this duplicated functionality of
      nonCachingStaticFunctionGetter.
* bindings/js/JSDOMBinding.h:
(WebCore::objectToStringFunctionGetter): Deleted.
    - removed objectToStringFunctionGetter - this duplicated functionality of
      nonCachingStaticFunctionGetter.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::jsDOMWindowGetOwnPropertySlotDisallowAccess):
    - explicitly handle providing access to only the things we do want to allow cross-origin.
(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
    - push all !allowsAccess handling to jsDOMWindowGetOwnPropertySlotDisallowAccess
(WebCore::childFrameGetter): Deleted.
    - this was just a deoptimiztion - moving access into a callback saved very
      little &amp; caused more work to be duplicated.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingcpp">trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp">trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196493 => 196494)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-12 20:17:03 UTC (rev 196493)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-12 20:20:41 UTC (rev 196494)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-02-12  Gavin Barraclough  &lt;barraclough@apple.com&gt;
+
+        Separate out !allowsAccess path in JSDOMWindowCustom getOwnPropertySlot
+        https://bugs.webkit.org/show_bug.cgi?id=154156
+
+        Reviewed by Chris Dumez.
+
+        * runtime/CommonIdentifiers.h:
+            - added new property names, needed by jsDOMWindowGetOwnPropertySlotDisallowAccess.
+
</ins><span class="cx"> 2016-02-12  Sukolsak Sakshuwong  &lt;sukolsak@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update ICU header files to version 52
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (196493 => 196494)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-02-12 20:17:03 UTC (rev 196493)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-02-12 20:20:41 UTC (rev 196494)
</span><span class="lines">@@ -121,6 +121,7 @@
</span><span class="cx">     macro(forEach) \
</span><span class="cx">     macro(formatMatcher) \
</span><span class="cx">     macro(forward) \
</span><ins>+    macro(frames) \
</ins><span class="cx">     macro(from) \
</span><span class="cx">     macro(fromCharCode) \
</span><span class="cx">     macro(get) \
</span><span class="lines">@@ -154,6 +155,7 @@
</span><span class="cx">     macro(line) \
</span><span class="cx">     macro(locale) \
</span><span class="cx">     macro(localeMatcher) \
</span><ins>+    macro(location) \
</ins><span class="cx">     macro(message) \
</span><span class="cx">     macro(minute) \
</span><span class="cx">     macro(month) \
</span><span class="lines">@@ -161,16 +163,18 @@
</span><span class="cx">     macro(name) \
</span><span class="cx">     macro(next) \
</span><span class="cx">     macro(now) \
</span><del>-    macro(numberingSystem) \
</del><span class="cx">     macro(numInlinedCalls) \
</span><span class="cx">     macro(numInlinedGetByIds) \
</span><span class="cx">     macro(numInlinedPutByIds) \
</span><ins>+    macro(numberingSystem) \
</ins><span class="cx">     macro(numeric) \
</span><span class="cx">     macro(of) \
</span><span class="cx">     macro(opcode) \
</span><ins>+    macro(opener) \
</ins><span class="cx">     macro(origin) \
</span><span class="cx">     macro(osrExitSites) \
</span><span class="cx">     macro(osrExits) \
</span><ins>+    macro(parent) \
</ins><span class="cx">     macro(parse) \
</span><span class="cx">     macro(parseInt) \
</span><span class="cx">     macro(postMessage) \
</span><span class="lines">@@ -182,14 +186,15 @@
</span><span class="cx">     macro(replace) \
</span><span class="cx">     macro(resolve) \
</span><span class="cx">     macro(second) \
</span><ins>+    macro(self) \
</ins><span class="cx">     macro(sensitivity) \
</span><span class="cx">     macro(set) \
</span><span class="cx">     macro(showModalDialog) \
</span><span class="cx">     macro(size) \
</span><span class="cx">     macro(slice) \
</span><span class="cx">     macro(source) \
</span><ins>+    macro(sourceCode) \
</ins><span class="cx">     macro(sourceURL) \
</span><del>-    macro(sourceCode) \
</del><span class="cx">     macro(stack) \
</span><span class="cx">     macro(subarray) \
</span><span class="cx">     macro(target) \
</span><span class="lines">@@ -204,6 +209,7 @@
</span><span class="cx">     macro(toLocaleString) \
</span><span class="cx">     macro(toPrecision) \
</span><span class="cx">     macro(toString) \
</span><ins>+    macro(top) \
</ins><span class="cx">     macro(usage) \
</span><span class="cx">     macro(value) \
</span><span class="cx">     macro(valueOf) \
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (196493 => 196494)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-12 20:17:03 UTC (rev 196493)
+++ trunk/Source/WebCore/ChangeLog        2016-02-12 20:20:41 UTC (rev 196494)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-02-12  Gavin Barraclough  &lt;barraclough@apple.com&gt;
+
+        Separate out !allowsAccess path in JSDOMWindowCustom getOwnPropertySlot
+        https://bugs.webkit.org/show_bug.cgi?id=154156
+
+        Reviewed by Chris Dumez.
+
+        JSDOMWindowCustom getOwnPropertySlot currently allows cross-origin access to all
+        static properties, relying on the property to perform the access check. This is
+        a little insecure, since it is error prone - someone could easily add a property
+        to the static table without realizing it would be automatcially exposed.
+
+        Instead, add a hard-coded filter to restrict access. As a future implementation
+        we might consider autogenerating this (the properties are already tagged in IDL,
+        we might be able to track this in a flag on the static table).
+
+        By separating out the handling of the same- and cross-origin access we can
+        simplify &amp; make the policy being enforced much clearer.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::objectToStringFunctionGetter): Deleted.
+            - removed objectToStringFunctionGetter - this duplicated functionality of
+              nonCachingStaticFunctionGetter.
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::objectToStringFunctionGetter): Deleted.
+            - removed objectToStringFunctionGetter - this duplicated functionality of
+              nonCachingStaticFunctionGetter.
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::jsDOMWindowGetOwnPropertySlotDisallowAccess):
+            - explicitly handle providing access to only the things we do want to allow cross-origin.
+        (WebCore::JSDOMWindow::getOwnPropertySlot):
+        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
+            - push all !allowsAccess handling to jsDOMWindowGetOwnPropertySlotDisallowAccess
+        (WebCore::childFrameGetter): Deleted.
+            - this was just a deoptimiztion - moving access into a callback saved very
+              little &amp; caused more work to be duplicated.
+
</ins><span class="cx"> 2016-02-12  Sukolsak Sakshuwong  &lt;sukolsak@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update ICU header files to version 52
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (196493 => 196494)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2016-02-12 20:17:03 UTC (rev 196493)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2016-02-12 20:20:41 UTC (rev 196494)
</span><span class="lines">@@ -334,11 +334,6 @@
</span><span class="cx">     frame-&gt;document()-&gt;domWindow()-&gt;printErrorMessage(message);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-EncodedJSValue objectToStringFunctionGetter(ExecState* exec, EncodedJSValue, PropertyName propertyName)
-{
-    return JSValue::encode(JSFunction::create(exec-&gt;vm(), exec-&gt;lexicalGlobalObject(), 0, propertyName.publicName(), objectProtoFuncToString));
-}
-
</del><span class="cx"> Structure* getCachedDOMStructure(JSDOMGlobalObject&amp; globalObject, const ClassInfo* classInfo)
</span><span class="cx"> {
</span><span class="cx">     JSDOMStructureMap&amp; structures = globalObject.structures();
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (196493 => 196494)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-02-12 20:17:03 UTC (rev 196493)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-02-12 20:20:41 UTC (rev 196494)
</span><span class="lines">@@ -661,7 +661,6 @@
</span><span class="cx"> bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&amp;, String&amp; message);
</span><span class="cx"> 
</span><span class="cx"> void printErrorMessageForFrame(Frame*, const String&amp; message);
</span><del>-JSC::EncodedJSValue objectToStringFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
</del><span class="cx"> 
</span><span class="cx"> inline String propertyNameToString(JSC::PropertyName propertyName)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (196493 => 196494)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2016-02-12 20:17:03 UTC (rev 196493)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2016-02-12 20:20:41 UTC (rev 196494)
</span><span class="lines">@@ -66,11 +66,6 @@
</span><span class="cx">         visitor.addOpaqueRoot(frame);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static EncodedJSValue childFrameGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
-{
-    return JSValue::encode(toJS(exec, jsCast&lt;JSDOMWindow*&gt;(JSValue::decode(thisValue))-&gt;wrapped().frame()-&gt;tree().scopedChild(propertyNameToAtomicString(propertyName))-&gt;document()-&gt;domWindow()));
-}
-
</del><span class="cx"> static EncodedJSValue namedItemGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
</span><span class="cx"> {
</span><span class="cx">     JSDOMWindowBase* thisObj = jsCast&lt;JSDOMWindow*&gt;(JSValue::decode(thisValue));
</span><span class="lines">@@ -117,6 +112,107 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+static bool jsDOMWindowGetOwnPropertySlotCrossOrigin(JSDOMWindow* thisObject, ExecState* exec, PropertyName propertyName, PropertySlot&amp; slot, String&amp; errorMessage)
+{
+    // These are the functions we allow access to cross-origin (DoNotCheckSecurity in IDL).
+    // Always provide the original function, on a fresh uncached function object.
+    if (propertyName == exec-&gt;propertyNames().blur) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter&lt;jsDOMWindowPrototypeFunctionBlur, 0&gt;);
+        return true;
+    }
+    if (propertyName == exec-&gt;propertyNames().close) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter&lt;jsDOMWindowPrototypeFunctionClose, 0&gt;);
+        return true;
+    }
+    if (propertyName == exec-&gt;propertyNames().focus) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter&lt;jsDOMWindowPrototypeFunctionFocus, 0&gt;);
+        return true;
+    }
+    if (propertyName == exec-&gt;propertyNames().postMessage) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter&lt;jsDOMWindowPrototypeFunctionPostMessage, 2&gt;);
+        return true;
+    }
+
+    // Allow access to toString() cross-domain, but always Object.prototype.toString.
+    if (propertyName == exec-&gt;propertyNames().toString) {
+        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter&lt;objectProtoFuncToString, 0&gt;);
+        return true;
+    }
+
+    // When accessing cross-origin known Window properties, we always use the original property getter,
+    // even if the property was removed / redefined. As of early 2016, this matches Firefox and Chrome's
+    // behavior.
+    if (auto* entry = JSDOMWindow::info()-&gt;staticPropHashTable-&gt;entry(propertyName)) {
+        // Only allow access to these specific properties.
+        if (propertyName == exec-&gt;propertyNames().location
+            || propertyName == exec-&gt;propertyNames().closed
+            || propertyName == exec-&gt;propertyNames().length
+            || propertyName == exec-&gt;propertyNames().self
+            || propertyName == exec-&gt;propertyNames().window
+            || propertyName == exec-&gt;propertyNames().frames
+            || propertyName == exec-&gt;propertyNames().opener
+            || propertyName == exec-&gt;propertyNames().parent
+            || propertyName == exec-&gt;propertyNames().top) {
+            slot.setCacheableCustom(thisObject, ReadOnly | DontDelete | DontEnum, entry-&gt;propertyGetter());
+            return true;
+        }
+
+        // For any other entries in the static property table, deny access. (Early return also prevents
+        // named getter from returning frames with matching names - this seems a little questionable, see
+        // FIXME comment on prototype search below.)
+        thisObject-&gt;printErrorMessage(errorMessage);
+        slot.setUndefined();
+        return true;
+    }
+
+    // Do prototype lookup early so that functions and attributes in the prototype can have
+    // precedence over the index and name getters.
+    // FIXME: This seems like a silly idea. It only serves to suppress named property access
+    // to frames that happen to have names corresponding to properties on the prototype.
+    // This seems to only serve to leak some information cross-origin.
+    JSValue proto = thisObject-&gt;prototype();
+    if (proto.isObject() &amp;&amp; asObject(proto)-&gt;getPropertySlot(exec, propertyName, slot)) {
+        thisObject-&gt;printErrorMessage(errorMessage);
+        slot.setUndefined();
+        return true;
+    }
+
+#if ENABLE(USER_MESSAGE_HANDLERS)
+    if (propertyName == exec-&gt;propertyNames().webkit &amp;&amp; thisObject-&gt;wrapped().shouldHaveWebKitNamespaceForWorld(thisObject-&gt;world())) {
+        slot.setCacheableCustom(thisObject, ReadOnly | DontDelete | DontEnum, jsDOMWindowWebKit);
+        return true;
+    }
+#endif
+
+    // After this point it is no longer valid to cache any results because of
+    // the impure nature of the property accesses which follow. We can move this 
+    // statement further down when we add ways to mitigate these impurities with, 
+    // for example, watchpoints.
+    slot.disableCaching();
+
+    // Check for child frames by name before built-in properties to
+    // match Mozilla. This does not match IE, but some sites end up
+    // naming frames things that conflict with window properties that
+    // are in Moz but not IE. Since we have some of these, we have to do
+    // it the Moz way.
+    if (auto* scopedChild = thisObject-&gt;wrapped().frame()-&gt;tree().scopedChild(propertyNameToAtomicString(propertyName))) {
+        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, toJS(exec, scopedChild-&gt;document()-&gt;domWindow()));
+        return true;
+    }
+
+    // allow window[1] or parent[1] etc. (#56983)
+    Optional&lt;uint32_t&gt; index = parseIndex(propertyName);
+    if (index &amp;&amp; index.value() &lt; thisObject-&gt;wrapped().frame()-&gt;tree().scopedChildCount()) {
+        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum,
+            toJS(exec, thisObject-&gt;wrapped().frame()-&gt;tree().scopedChild(index.value())-&gt;document()-&gt;domWindow()));
+        return true;
+    }
+
+    thisObject-&gt;printErrorMessage(errorMessage);
+    slot.setUndefined();
+    return true;
+}
+
</ins><span class="cx"> bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot&amp; slot)
</span><span class="cx"> {
</span><span class="cx">     JSDOMWindow* thisObject = jsCast&lt;JSDOMWindow*&gt;(object);
</span><span class="lines">@@ -151,11 +247,12 @@
</span><span class="cx">     // because we always allow access to some function, just different ones depending whether access
</span><span class="cx">     // is allowed.
</span><span class="cx">     String errorMessage;
</span><del>-    bool allowsAccess = shouldAllowAccessToDOMWindow(exec, thisObject-&gt;wrapped(), errorMessage);
</del><ins>+    if (!shouldAllowAccessToDOMWindow(exec, thisObject-&gt;wrapped(), errorMessage))
+        return jsDOMWindowGetOwnPropertySlotCrossOrigin(thisObject, exec, propertyName, slot, errorMessage);
</ins><span class="cx">     
</span><span class="cx">     // Look for overrides before looking at any of our own properties, but ignore overrides completely
</span><span class="cx">     // if this is cross-domain access.
</span><del>-    if (allowsAccess &amp;&amp; JSGlobalObject::getOwnPropertySlot(thisObject, exec, propertyName, slot))
</del><ins>+    if (JSGlobalObject::getOwnPropertySlot(thisObject, exec, propertyName, slot))
</ins><span class="cx">         return true;
</span><span class="cx">     
</span><span class="cx">     // We need this code here because otherwise JSDOMWindowBase will stop the search before we even get to the
</span><span class="lines">@@ -179,12 +276,6 @@
</span><span class="cx">             slot.setUndefined();
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><del>-    } else if (propertyName == exec-&gt;propertyNames().toString) {
-        // Allow access to toString() cross-domain, but always Object.prototype.toString.
-        if (!allowsAccess) {
-            slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter);
-            return true;
-        }
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="lines">@@ -194,7 +285,7 @@
</span><span class="cx">     // and have to handle them specially here.
</span><span class="cx">     // Once https://webkit.org/b/145669 is resolved, they can once again be auto generated.
</span><span class="cx">     if (RuntimeEnabledFeatures::sharedFeatures().indexedDBEnabled() &amp;&amp; (propertyName == exec-&gt;propertyNames().indexedDB || propertyName == exec-&gt;propertyNames().webkitIndexedDB)) {
</span><del>-        slot.setCustom(thisObject, allowsAccess ? DontDelete | ReadOnly | CustomAccessor : ReadOnly | DontDelete | DontEnum, jsDOMWindowIndexedDB);
</del><ins>+        slot.setCustom(thisObject, DontDelete | ReadOnly | CustomAccessor, jsDOMWindowIndexedDB);
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="lines">@@ -202,16 +293,16 @@
</span><span class="cx">     // When accessing cross-origin known Window properties, we always use the original property getter,
</span><span class="cx">     // even if the property was removed / redefined. As of early 2016, this matches Firefox and Chrome's
</span><span class="cx">     // behavior.
</span><del>-    if (!thisObject-&gt;staticFunctionsReified() || !allowsAccess) {
</del><ins>+    if (!thisObject-&gt;staticFunctionsReified()) {
</ins><span class="cx">         if (auto* entry = JSDOMWindow::info()-&gt;staticPropHashTable-&gt;entry(propertyName)) {
</span><del>-            slot.setCacheableCustom(thisObject, allowsAccess ? entry-&gt;attributes() : ReadOnly | DontDelete | DontEnum, entry-&gt;propertyGetter());
</del><ins>+            slot.setCacheableCustom(thisObject, entry-&gt;attributes(), entry-&gt;propertyGetter());
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(USER_MESSAGE_HANDLERS)
</span><span class="cx">     if (propertyName == exec-&gt;propertyNames().webkit &amp;&amp; thisObject-&gt;wrapped().shouldHaveWebKitNamespaceForWorld(thisObject-&gt;world())) {
</span><del>-        slot.setCacheableCustom(thisObject, allowsAccess ? DontDelete | ReadOnly : ReadOnly | DontDelete | DontEnum, jsDOMWindowWebKit);
</del><ins>+        slot.setCacheableCustom(thisObject, DontDelete | ReadOnly, jsDOMWindowWebKit);
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="lines">@@ -219,15 +310,8 @@
</span><span class="cx">     // Do prototype lookup early so that functions and attributes in the prototype can have
</span><span class="cx">     // precedence over the index and name getters.  
</span><span class="cx">     JSValue proto = thisObject-&gt;prototype();
</span><del>-    if (proto.isObject()) {
-        if (asObject(proto)-&gt;getPropertySlot(exec, propertyName, slot)) {
-            if (!allowsAccess) {
-                thisObject-&gt;printErrorMessage(errorMessage);
-                slot.setUndefined();
-            }
-            return true;
-        }
-    }
</del><ins>+    if (proto.isObject() &amp;&amp; asObject(proto)-&gt;getPropertySlot(exec, propertyName, slot))
+        return true;
</ins><span class="cx"> 
</span><span class="cx">     // After this point it is no longer valid to cache any results because of
</span><span class="cx">     // the impure nature of the property accesses which follow. We can move this 
</span><span class="lines">@@ -240,8 +324,8 @@
</span><span class="cx">     // naming frames things that conflict with window properties that
</span><span class="cx">     // are in Moz but not IE. Since we have some of these, we have to do
</span><span class="cx">     // it the Moz way.
</span><del>-    if (thisObject-&gt;wrapped().frame()-&gt;tree().scopedChild(propertyNameToAtomicString(propertyName))) {
-        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter);
</del><ins>+    if (auto* scopedChild = thisObject-&gt;wrapped().frame()-&gt;tree().scopedChild(propertyNameToAtomicString(propertyName))) {
+        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, toJS(exec, scopedChild-&gt;document()-&gt;domWindow()));
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -256,12 +340,6 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!allowsAccess) {
-        thisObject-&gt;printErrorMessage(errorMessage);
-        slot.setUndefined();
-        return true;
-    }
-
</del><span class="cx">     // Allow shortcuts like 'Image1' instead of document.images.Image1
</span><span class="cx">     Document* document = thisObject-&gt;wrapped().frame()-&gt;document();
</span><span class="cx">     if (is&lt;HTMLDocument&gt;(*document)) {
</span><span class="lines">@@ -286,26 +364,27 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    Identifier propertyName = Identifier::from(exec, index);
+    
</ins><span class="cx">     // We need to check for cross-domain access here without printing the generic warning message
</span><span class="cx">     // because we always allow access to some function, just different ones depending whether access
</span><span class="cx">     // is allowed.
</span><span class="cx">     String errorMessage;
</span><del>-    bool allowsAccess = shouldAllowAccessToDOMWindow(exec, thisObject-&gt;wrapped(), errorMessage);
</del><ins>+    if (!shouldAllowAccessToDOMWindow(exec, thisObject-&gt;wrapped(), errorMessage))
+        return jsDOMWindowGetOwnPropertySlotCrossOrigin(thisObject, exec, propertyName, slot, errorMessage);
</ins><span class="cx"> 
</span><span class="cx">     // Look for overrides before looking at any of our own properties, but ignore overrides completely
</span><span class="cx">     // if this is cross-domain access.
</span><del>-    if (allowsAccess &amp;&amp; JSGlobalObject::getOwnPropertySlotByIndex(thisObject, exec, index, slot))
</del><ins>+    if (JSGlobalObject::getOwnPropertySlotByIndex(thisObject, exec, index, slot))
</ins><span class="cx">         return true;
</span><span class="cx">     
</span><del>-    Identifier propertyName = Identifier::from(exec, index);
-    
</del><span class="cx">     // Check for child frames by name before built-in properties to
</span><span class="cx">     // match Mozilla. This does not match IE, but some sites end up
</span><span class="cx">     // naming frames things that conflict with window properties that
</span><span class="cx">     // are in Moz but not IE. Since we have some of these, we have to do
</span><span class="cx">     // it the Moz way.
</span><del>-    if (thisObject-&gt;wrapped().frame()-&gt;tree().scopedChild(propertyNameToAtomicString(propertyName))) {
-        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, childFrameGetter);
</del><ins>+    if (auto* scopedChild = thisObject-&gt;wrapped().frame()-&gt;tree().scopedChild(propertyNameToAtomicString(propertyName))) {
+        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, toJS(exec, scopedChild-&gt;document()-&gt;domWindow()));
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -313,13 +392,8 @@
</span><span class="cx">     // precedence over the index and name getters.  
</span><span class="cx">     JSValue proto = thisObject-&gt;prototype();
</span><span class="cx">     if (proto.isObject()) {
</span><del>-        if (asObject(proto)-&gt;getPropertySlot(exec, index, slot)) {
-            if (!allowsAccess) {
-                thisObject-&gt;printErrorMessage(errorMessage);
-                slot.setUndefined();
-            }
</del><ins>+        if (asObject(proto)-&gt;getPropertySlot(exec, index, slot))
</ins><span class="cx">             return true;
</span><del>-        }
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Search the whole frame hierarchy somewhere around here.
</span><span class="lines">@@ -332,12 +406,6 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!allowsAccess) {
-        thisObject-&gt;printErrorMessage(errorMessage);
-        slot.setUndefined();
-        return true;
-    }
-
</del><span class="cx">     // Allow shortcuts like 'Image1' instead of document.images.Image1
</span><span class="cx">     Document* document = thisObject-&gt;wrapped().frame()-&gt;document();
</span><span class="cx">     if (is&lt;HTMLDocument&gt;(*document)) {
</span></span></pre>
</div>
</div>

</body>
</html>