<!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>[209020] 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/209020">209020</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-11-28 14:29:39 -0800 (Mon, 28 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix exception scope verification failures in ObjectConstructor.cpp and ObjectPrototype.cpp.
https://bugs.webkit.org/show_bug.cgi?id=165051

Reviewed by Saam Barati.

Source/JavaScriptCore:

Also,
1. Replaced returning JSValue() with returning { }.
2. Replaced uses of exec-&gt;propertyNames() with vm.propertyNames.

* runtime/ObjectConstructor.cpp:
(JSC::constructObject):
(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyDescriptors):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorGetOwnPropertySymbols):
(JSC::objectConstructorKeys):
(JSC::ownEnumerablePropertyKeys):
(JSC::toPropertyDescriptor):
(JSC::defineProperties):
(JSC::objectConstructorDefineProperties):
(JSC::objectConstructorCreate):
(JSC::setIntegrityLevel):
(JSC::objectConstructorSeal):
(JSC::objectConstructorPreventExtensions):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):
(JSC::ownPropertyKeys):
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncValueOf):
(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncIsPrototypeOf):
(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncToLocaleString):
(JSC::objectProtoFuncToString):

Source/WebCore:

No new tests because this is covered by the existing test
http/tests/security/cross-frame-access-object-prototype.html with the help of a
new ASSERT in ObjectPrototype.cpp.

Fixed jsDOMWindowGetOwnPropertySlotRestrictedAccess() to return false when it
throws an exception.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeObjectConstructorcpp">trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeObjectPrototypecpp">trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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 (209019 => 209020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-11-28 22:29:39 UTC (rev 209020)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-11-28  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Fix exception scope verification failures in ObjectConstructor.cpp and ObjectPrototype.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=165051
+
+        Reviewed by Saam Barati.
+
+        Also,
+        1. Replaced returning JSValue() with returning { }.
+        2. Replaced uses of exec-&gt;propertyNames() with vm.propertyNames.
+
+        * runtime/ObjectConstructor.cpp:
+        (JSC::constructObject):
+        (JSC::objectConstructorGetPrototypeOf):
+        (JSC::objectConstructorGetOwnPropertyDescriptor):
+        (JSC::objectConstructorGetOwnPropertyDescriptors):
+        (JSC::objectConstructorGetOwnPropertyNames):
+        (JSC::objectConstructorGetOwnPropertySymbols):
+        (JSC::objectConstructorKeys):
+        (JSC::ownEnumerablePropertyKeys):
+        (JSC::toPropertyDescriptor):
+        (JSC::defineProperties):
+        (JSC::objectConstructorDefineProperties):
+        (JSC::objectConstructorCreate):
+        (JSC::setIntegrityLevel):
+        (JSC::objectConstructorSeal):
+        (JSC::objectConstructorPreventExtensions):
+        (JSC::objectConstructorIsSealed):
+        (JSC::objectConstructorIsFrozen):
+        (JSC::ownPropertyKeys):
+        * runtime/ObjectPrototype.cpp:
+        (JSC::objectProtoFuncValueOf):
+        (JSC::objectProtoFuncHasOwnProperty):
+        (JSC::objectProtoFuncIsPrototypeOf):
+        (JSC::objectProtoFuncDefineGetter):
+        (JSC::objectProtoFuncDefineSetter):
+        (JSC::objectProtoFuncLookupGetter):
+        (JSC::objectProtoFuncLookupSetter):
+        (JSC::objectProtoFuncToLocaleString):
+        (JSC::objectProtoFuncToString):
+
</ins><span class="cx"> 2016-11-26  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix exception scope verification failures in miscellaneous files.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeObjectConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp (209019 => 209020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp        2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp        2016-11-28 22:29:39 UTC (rev 209020)
</span><span class="lines">@@ -133,6 +133,7 @@
</span><span class="cx">         return constructEmptyObject(exec, globalObject-&gt;objectStructureForObjectConstructor());
</span><span class="cx"> 
</span><span class="cx">     // 3. Return ToObject(value).
</span><ins>+    scope.release();
</ins><span class="cx">     return arg.toObject(exec, globalObject);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -164,7 +165,8 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSObject* object = exec-&gt;argument(0).toObject(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>-    return JSValue::encode(object-&gt;getPrototype(exec-&gt;vm(), exec));
</del><ins>+    scope.release();
+    return JSValue::encode(object-&gt;getPrototype(vm, exec));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorSetPrototypeOf(ExecState* exec)
</span><span class="lines">@@ -194,11 +196,14 @@
</span><span class="cx">     VM&amp; vm = exec-&gt;vm();
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     PropertyDescriptor descriptor;
</span><del>-    if (!object-&gt;getOwnPropertyDescriptor(exec, propertyName, descriptor))
</del><ins>+    if (!object-&gt;getOwnPropertyDescriptor(exec, propertyName, descriptor)) {
+        scope.release();
</ins><span class="cx">         return jsUndefined();
</span><del>-    RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+    }
+    RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> 
</span><span class="cx">     JSObject* result = constructObjectFromPropertyDescriptor(exec, descriptor);
</span><ins>+    ASSERT(!!scope.exception() == !result);
</ins><span class="cx">     if (!result)
</span><span class="cx">         return jsUndefined();
</span><span class="cx">     return result;
</span><span class="lines">@@ -210,20 +215,21 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
</span><span class="cx">     object-&gt;methodTable(vm)-&gt;getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
</span><del>-    RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+    RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> 
</span><span class="cx">     JSObject* descriptors = constructEmptyObject(exec);
</span><del>-    RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+    RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> 
</span><span class="cx">     for (auto&amp; propertyName : properties) {
</span><span class="cx">         PropertyDescriptor descriptor;
</span><span class="cx">         bool didGetDescriptor = object-&gt;getOwnPropertyDescriptor(exec, propertyName, descriptor);
</span><del>-        RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+        RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> 
</span><span class="cx">         if (!didGetDescriptor)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         JSObject* fromDescriptor = constructObjectFromPropertyDescriptor(exec, descriptor);
</span><ins>+        ASSERT(!!scope.exception() == !fromDescriptor);
</ins><span class="cx">         if (!fromDescriptor)
</span><span class="cx">             return jsUndefined();
</span><span class="cx"> 
</span><span class="lines">@@ -243,6 +249,7 @@
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">     auto propertyName = exec-&gt;argument(1).toPropertyKey(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(objectConstructorGetOwnPropertyDescriptor(exec, object, propertyName));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -252,6 +259,7 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSObject* object = exec-&gt;argument(0).toObject(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(objectConstructorGetOwnPropertyDescriptors(exec, object));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -262,6 +270,7 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSObject* object = exec-&gt;argument(0).toObject(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Include));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -272,6 +281,7 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSObject* object = exec-&gt;argument(0).toObject(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Symbols, DontEnumPropertiesMode::Include));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -282,6 +292,7 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSObject* object = exec-&gt;argument(0).toObject(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Exclude));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -291,6 +302,7 @@
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">     JSObject* object = exec-&gt;argument(0).toObject(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::StringsAndSymbols, DontEnumPropertiesMode::Exclude));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -307,15 +319,19 @@
</span><span class="cx">     }
</span><span class="cx">     JSObject* description = asObject(in);
</span><span class="cx"> 
</span><del>-    if (description-&gt;hasProperty(exec, exec-&gt;propertyNames().enumerable)) {
-        JSValue value = description-&gt;get(exec, exec-&gt;propertyNames().enumerable);
</del><ins>+    bool hasProperty = description-&gt;hasProperty(exec, vm.propertyNames-&gt;enumerable);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description-&gt;get(exec, vm.propertyNames-&gt;enumerable);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx">         desc.setEnumerable(value.toBoolean(exec));
</span><span class="cx">     } else
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx"> 
</span><del>-    if (description-&gt;hasProperty(exec, exec-&gt;propertyNames().configurable)) {
-        JSValue value = description-&gt;get(exec, exec-&gt;propertyNames().configurable);
</del><ins>+    hasProperty = description-&gt;hasProperty(exec, vm.propertyNames-&gt;configurable);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description-&gt;get(exec, vm.propertyNames-&gt;configurable);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx">         desc.setConfigurable(value.toBoolean(exec));
</span><span class="cx">     } else
</span><span class="lines">@@ -322,22 +338,28 @@
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx"> 
</span><span class="cx">     JSValue value;
</span><del>-    if (description-&gt;hasProperty(exec, exec-&gt;propertyNames().value)) {
-        JSValue value = description-&gt;get(exec, exec-&gt;propertyNames().value);
</del><ins>+    hasProperty = description-&gt;hasProperty(exec, vm.propertyNames-&gt;value);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description-&gt;get(exec, vm.propertyNames-&gt;value);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx">         desc.setValue(value);
</span><span class="cx">     } else
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx"> 
</span><del>-    if (description-&gt;hasProperty(exec, exec-&gt;propertyNames().writable)) {
-        JSValue value = description-&gt;get(exec, exec-&gt;propertyNames().writable);
</del><ins>+    hasProperty = description-&gt;hasProperty(exec, vm.propertyNames-&gt;writable);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue value = description-&gt;get(exec, vm.propertyNames-&gt;writable);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx">         desc.setWritable(value.toBoolean(exec));
</span><span class="cx">     } else
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx"> 
</span><del>-    if (description-&gt;hasProperty(exec, exec-&gt;propertyNames().get)) {
-        JSValue get = description-&gt;get(exec, exec-&gt;propertyNames().get);
</del><ins>+    hasProperty = description-&gt;hasProperty(exec, vm.propertyNames-&gt;get);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue get = description-&gt;get(exec, vm.propertyNames-&gt;get);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx">         if (!get.isUndefined()) {
</span><span class="cx">             CallData callData;
</span><span class="lines">@@ -350,8 +372,10 @@
</span><span class="cx">     } else
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx"> 
</span><del>-    if (description-&gt;hasProperty(exec, exec-&gt;propertyNames().set)) {
-        JSValue set = description-&gt;get(exec, exec-&gt;propertyNames().set);
</del><ins>+    hasProperty = description-&gt;hasProperty(exec, vm.propertyNames-&gt;set);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
+        JSValue set = description-&gt;get(exec, vm.propertyNames-&gt;set);
</ins><span class="cx">         RETURN_IF_EXCEPTION(scope, false);
</span><span class="cx">         if (!set.isUndefined()) {
</span><span class="cx">             CallData callData;
</span><span class="lines">@@ -408,15 +432,17 @@
</span><span class="cx"> 
</span><span class="cx">     PropertyNameArray propertyNames(exec, PropertyNameMode::StringsAndSymbols);
</span><span class="cx">     asObject(properties)-&gt;methodTable(vm)-&gt;getOwnPropertyNames(asObject(properties), exec, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude));
</span><del>-    RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+    RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">     size_t numProperties = propertyNames.size();
</span><span class="cx">     Vector&lt;PropertyDescriptor&gt; descriptors;
</span><span class="cx">     MarkedArgumentBuffer markBuffer;
</span><span class="cx">     for (size_t i = 0; i &lt; numProperties; i++) {
</span><span class="cx">         JSValue prop = properties-&gt;get(exec, propertyNames[i]);
</span><del>-        RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+        RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">         PropertyDescriptor descriptor;
</span><del>-        if (!toPropertyDescriptor(exec, prop, descriptor))
</del><ins>+        bool success = toPropertyDescriptor(exec, prop, descriptor);
+        ASSERT(!scope.exception() || !success);
+        if (UNLIKELY(!success))
</ins><span class="cx">             return jsNull();
</span><span class="cx">         descriptors.append(descriptor);
</span><span class="cx">         // Ensure we mark all the values that we're accumulating
</span><span class="lines">@@ -431,10 +457,10 @@
</span><span class="cx">     }
</span><span class="cx">     for (size_t i = 0; i &lt; numProperties; i++) {
</span><span class="cx">         Identifier propertyName = propertyNames[i];
</span><del>-        if (exec-&gt;propertyNames().isPrivateName(propertyName))
</del><ins>+        if (vm.propertyNames-&gt;isPrivateName(propertyName))
</ins><span class="cx">             continue;
</span><span class="cx">         object-&gt;methodTable(vm)-&gt;defineOwnProperty(object, exec, propertyName, descriptors[i], true);
</span><del>-        RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+        RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">     }
</span><span class="cx">     return object;
</span><span class="cx"> }
</span><span class="lines">@@ -448,8 +474,10 @@
</span><span class="cx">         return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Properties can only be defined on Objects.&quot;));
</span><span class="cx">     JSObject* targetObj = asObject(exec-&gt;argument(0));
</span><span class="cx">     JSObject* props = exec-&gt;argument(1).toObject(exec);
</span><del>-    if (!props)
-        return JSValue::encode(JSValue());
</del><ins>+    ASSERT(!!scope.exception() == !props);
+    if (UNLIKELY(!props))
+        return encodedJSValue();
+    scope.release();
</ins><span class="cx">     return JSValue::encode(defineProperties(exec, targetObj, props));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -468,6 +496,7 @@
</span><span class="cx">         return JSValue::encode(newObject);
</span><span class="cx">     if (!exec-&gt;argument(1).isObject())
</span><span class="cx">         return throwVMTypeError(exec, scope, ASCIILiteral(&quot;Property descriptor list must be an Object.&quot;));
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(defineProperties(exec, newObject, asObject(exec-&gt;argument(1))));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -501,7 +530,9 @@
</span><span class="cx">         if (level == IntegrityLevel::Sealed)
</span><span class="cx">             desc.setConfigurable(false);
</span><span class="cx">         else {
</span><del>-            if (!object-&gt;getOwnPropertyDescriptor(exec, propertyName, desc))
</del><ins>+            bool hasPropertyDescriptor = object-&gt;getOwnPropertyDescriptor(exec, propertyName, desc);
+            RETURN_IF_EXCEPTION(scope, false);
+            if (!hasPropertyDescriptor)
</ins><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="cx">             if (desc.isDataDescriptor())
</span><span class="lines">@@ -534,7 +565,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool success = setIntegrityLevel&lt;IntegrityLevel::Sealed&gt;(exec, vm, object);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>-    if (!success) {
</del><ins>+    if (UNLIKELY(!success)) {
</ins><span class="cx">         throwTypeError(exec, scope, ASCIILiteral(&quot;Unable to prevent extension in Object.seal&quot;));
</span><span class="cx">         return encodedJSValue();
</span><span class="cx">     }
</span><span class="lines">@@ -574,11 +605,12 @@
</span><span class="cx"> 
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorPreventExtensions(ExecState* exec)
</span><span class="cx"> {
</span><ins>+    VM&amp; vm = exec-&gt;vm();
</ins><span class="cx">     JSValue argument = exec-&gt;argument(0);
</span><span class="cx">     if (!argument.isObject())
</span><span class="cx">         return JSValue::encode(argument);
</span><span class="cx">     JSObject* object = asObject(argument);
</span><del>-    object-&gt;methodTable(exec-&gt;vm())-&gt;preventExtensions(object, exec);
</del><ins>+    object-&gt;methodTable(vm)-&gt;preventExtensions(object, exec);
</ins><span class="cx">     return JSValue::encode(object);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -603,7 +635,7 @@
</span><span class="cx">     PropertyNameArray::const_iterator end = properties.end();
</span><span class="cx">     for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
</span><span class="cx">         Identifier propertyName = *iter;
</span><del>-        if (exec-&gt;propertyNames().isPrivateName(propertyName))
</del><ins>+        if (vm.propertyNames-&gt;isPrivateName(propertyName))
</ins><span class="cx">             continue;
</span><span class="cx">         // a. Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
</span><span class="cx">         PropertyDescriptor desc;
</span><span class="lines">@@ -642,7 +674,7 @@
</span><span class="cx">     PropertyNameArray::const_iterator end = properties.end();
</span><span class="cx">     for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
</span><span class="cx">         Identifier propertyName = *iter;
</span><del>-        if (exec-&gt;propertyNames().isPrivateName(propertyName))
</del><ins>+        if (vm.propertyNames-&gt;isPrivateName(propertyName))
</ins><span class="cx">             continue;
</span><span class="cx">         // a. Let desc be the result of calling the [[GetOwnProperty]] internal method of O with P.
</span><span class="cx">         PropertyDescriptor desc;
</span><span class="lines">@@ -698,6 +730,7 @@
</span><span class="cx">             const auto&amp; identifier = properties[i];
</span><span class="cx">             ASSERT(!identifier.isSymbol());
</span><span class="cx">             keys-&gt;push(exec, jsOwnedString(exec, identifier.string()));
</span><ins>+            RETURN_IF_EXCEPTION(scope, nullptr);
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -707,8 +740,10 @@
</span><span class="cx">         for (size_t i = 0; i &lt; numProperties; i++) {
</span><span class="cx">             const auto&amp; identifier = properties[i];
</span><span class="cx">             ASSERT(identifier.isSymbol());
</span><del>-            if (!exec-&gt;propertyNames().isPrivateName(identifier))
</del><ins>+            if (!vm.propertyNames-&gt;isPrivateName(identifier)) {
</ins><span class="cx">                 keys-&gt;push(exec, Symbol::create(vm, static_cast&lt;SymbolImpl&amp;&gt;(*identifier.impl())));
</span><ins>+                RETURN_IF_EXCEPTION(scope, nullptr);
+            }
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -719,15 +754,19 @@
</span><span class="cx">         for (size_t i = 0; i &lt; numProperties; i++) {
</span><span class="cx">             const auto&amp; identifier = properties[i];
</span><span class="cx">             if (identifier.isSymbol()) {
</span><del>-                if (!exec-&gt;propertyNames().isPrivateName(identifier))
</del><ins>+                if (!vm.propertyNames-&gt;isPrivateName(identifier))
</ins><span class="cx">                     propertySymbols.append(identifier);
</span><del>-            } else
</del><ins>+            } else {
</ins><span class="cx">                 keys-&gt;push(exec, jsOwnedString(exec, identifier.string()));
</span><ins>+                RETURN_IF_EXCEPTION(scope, nullptr);
+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // To ensure the order defined in the spec (9.1.12), we append symbols at the last elements of keys.
</span><del>-        for (const auto&amp; identifier : propertySymbols)
</del><ins>+        for (const auto&amp; identifier : propertySymbols) {
</ins><span class="cx">             keys-&gt;push(exec, Symbol::create(vm, static_cast&lt;SymbolImpl&amp;&gt;(*identifier.impl())));
</span><ins>+            RETURN_IF_EXCEPTION(scope, nullptr);
+        }
</ins><span class="cx"> 
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeObjectPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp (209019 => 209020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp        2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp        2016-11-28 22:29:39 UTC (rev 209020)
</span><span class="lines">@@ -83,8 +83,8 @@
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue().toThis(exec, StrictMode);
</span><span class="cx">     JSObject* valueObj = thisValue.toObject(exec);
</span><del>-    if (!valueObj)
-        return JSValue::encode(JSValue());
</del><ins>+    if (UNLIKELY(!valueObj))
+        return encodedJSValue();
</ins><span class="cx">     return JSValue::encode(valueObj);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -97,8 +97,9 @@
</span><span class="cx">     auto propertyName = exec-&gt;argument(0).toPropertyKey(exec);
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">     JSObject* thisObject = thisValue.toObject(exec);
</span><ins>+    ASSERT(!!scope.exception() == !thisObject);
</ins><span class="cx">     if (UNLIKELY(!thisObject))
</span><del>-        return JSValue::encode(JSValue());
</del><ins>+        return encodedJSValue();
</ins><span class="cx"> 
</span><span class="cx">     Structure* structure = thisObject-&gt;structure(vm);
</span><span class="cx">     HasOwnPropertyCache* hasOwnPropertyCache = vm.ensureHasOwnPropertyCache();
</span><span class="lines">@@ -123,8 +124,9 @@
</span><span class="cx"> 
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue().toThis(exec, StrictMode);
</span><span class="cx">     JSObject* thisObj = thisValue.toObject(exec);
</span><del>-    if (!thisObj)
-        return JSValue::encode(JSValue());
</del><ins>+    ASSERT(!!scope.exception() == !thisObj);
+    if (UNLIKELY(!thisObj))
+        return encodedJSValue();
</ins><span class="cx"> 
</span><span class="cx">     if (!exec-&gt;argument(0).isObject())
</span><span class="cx">         return JSValue::encode(jsBoolean(false));
</span><span class="lines">@@ -164,6 +166,7 @@
</span><span class="cx">     descriptor.setConfigurable(true);
</span><span class="cx"> 
</span><span class="cx">     bool shouldThrow = true;
</span><ins>+    scope.release();
</ins><span class="cx">     thisObject-&gt;methodTable(vm)-&gt;defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
</span><span class="cx"> 
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="lines">@@ -191,6 +194,7 @@
</span><span class="cx">     descriptor.setConfigurable(true);
</span><span class="cx"> 
</span><span class="cx">     bool shouldThrow = true;
</span><ins>+    scope.release();
</ins><span class="cx">     thisObject-&gt;methodTable(vm)-&gt;defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
</span><span class="cx"> 
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="lines">@@ -208,7 +212,9 @@
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> 
</span><span class="cx">     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
</span><del>-    if (thisObject-&gt;getPropertySlot(exec, propertyName, slot)) {
</del><ins>+    bool hasProperty = thisObject-&gt;getPropertySlot(exec, propertyName, slot);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
</ins><span class="cx">         if (slot.isAccessor()) {
</span><span class="cx">             GetterSetter* getterSetter = slot.getterSetter();
</span><span class="cx">             return getterSetter-&gt;isGetterNull() ? JSValue::encode(jsUndefined()) : JSValue::encode(getterSetter-&gt;getter());
</span><span class="lines">@@ -236,7 +242,9 @@
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> 
</span><span class="cx">     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
</span><del>-    if (thisObject-&gt;getPropertySlot(exec, propertyName, slot)) {
</del><ins>+    bool hasProperty = thisObject-&gt;getPropertySlot(exec, propertyName, slot);
+    ASSERT(!scope.exception() || !hasProperty);
+    if (hasProperty) {
</ins><span class="cx">         if (slot.isAccessor()) {
</span><span class="cx">             GetterSetter* getterSetter = slot.getterSetter();
</span><span class="cx">             return getterSetter-&gt;isSetterNull() ? JSValue::encode(jsUndefined()) : JSValue::encode(getterSetter-&gt;setter());
</span><span class="lines">@@ -278,7 +286,8 @@
</span><span class="cx">     RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> 
</span><span class="cx">     // 2. Let toString be the result of calling the [[Get]] internal method of O passing &quot;toString&quot; as the argument.
</span><del>-    JSValue toString = object-&gt;get(exec, exec-&gt;propertyNames().toString);
</del><ins>+    JSValue toString = object-&gt;get(exec, vm.propertyNames-&gt;toString);
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
</ins><span class="cx"> 
</span><span class="cx">     // 3. If IsCallable(toString) is false, throw a TypeError exception.
</span><span class="cx">     CallData callData;
</span><span class="lines">@@ -287,6 +296,7 @@
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><span class="cx">     // 4. Return the result of calling the [[Call]] internal method of toString passing O as the this value and no arguments.
</span><ins>+    scope.release();
</ins><span class="cx">     return JSValue::encode(call(exec, toString, callType, callData, object, exec-&gt;emptyList()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -299,6 +309,7 @@
</span><span class="cx">     if (thisValue.isUndefinedOrNull())
</span><span class="cx">         return JSValue::encode(thisValue.isUndefined() ? vm.smallStrings.undefinedObjectString() : vm.smallStrings.nullObjectString());
</span><span class="cx">     JSObject* thisObject = thisValue.toObject(exec);
</span><ins>+    ASSERT(!!scope.exception() == !thisObject);
</ins><span class="cx">     if (!thisObject)
</span><span class="cx">         return JSValue::encode(jsUndefined());
</span><span class="cx"> 
</span><span class="lines">@@ -306,11 +317,12 @@
</span><span class="cx">     if (result)
</span><span class="cx">         return JSValue::encode(result);
</span><span class="cx"> 
</span><del>-    PropertyName toStringTagSymbol = exec-&gt;propertyNames().toStringTagSymbol;
</del><ins>+    PropertyName toStringTagSymbol = vm.propertyNames-&gt;toStringTagSymbol;
+    scope.release();
</ins><span class="cx">     return JSValue::encode(thisObject-&gt;getPropertySlot(exec, toStringTagSymbol, [&amp;] (bool found, PropertySlot&amp; toStringTagSlot) -&gt; JSValue {
</span><span class="cx">         if (found) {
</span><span class="cx">             JSValue stringTag = toStringTagSlot.getValue(exec, toStringTagSymbol);
</span><del>-            RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+            RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">             if (stringTag.isString()) {
</span><span class="cx">                 JSRopeString::RopeBuilder ropeBuilder(vm);
</span><span class="cx">                 ropeBuilder.append(vm.smallStrings.objectStringStart());
</span><span class="lines">@@ -323,8 +335,8 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        String tag = thisObject-&gt;methodTable(exec-&gt;vm())-&gt;toStringName(thisObject, exec);
-        RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+        String tag = thisObject-&gt;methodTable(vm)-&gt;toStringName(thisObject, exec);
+        RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">         String newString = WTF::tryMakeString(&quot;[object &quot;, WTFMove(tag), &quot;]&quot;);
</span><span class="cx">         if (!newString)
</span><span class="cx">             return throwOutOfMemoryError(exec, scope);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209019 => 209020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/WebCore/ChangeLog        2016-11-28 22:29:39 UTC (rev 209020)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-11-28  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Fix exception scope verification failures in ObjectConstructor.cpp and ObjectPrototype.cpp.
+        https://bugs.webkit.org/show_bug.cgi?id=165051
+
+        Reviewed by Saam Barati.
+
+        No new tests because this is covered by the existing test
+        http/tests/security/cross-frame-access-object-prototype.html with the help of a
+        new ASSERT in ObjectPrototype.cpp.
+
+        Fixed jsDOMWindowGetOwnPropertySlotRestrictedAccess() to return false when it
+        throws an exception.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
+
</ins><span class="cx"> 2016-11-28  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Obvious change in saturation/color when swiping to a previously visited page
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (209019 => 209020)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2016-11-28 22:24:08 UTC (rev 209019)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2016-11-28 22:29:39 UTC (rev 209020)
</span><span class="lines">@@ -134,7 +134,7 @@
</span><span class="cx">         // FIXME comment on prototype search below.)
</span><span class="cx">         throwSecurityError(*exec, scope, errorMessage);
</span><span class="cx">         slot.setUndefined();
</span><del>-        return true;
</del><ins>+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Check for child frames by name before built-in properties to match Mozilla. This does
</span><span class="lines">@@ -148,7 +148,7 @@
</span><span class="cx"> 
</span><span class="cx">     throwSecurityError(*exec, scope, errorMessage);
</span><span class="cx">     slot.setUndefined();
</span><del>-    return true;
</del><ins>+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Property access sequence is:
</span></span></pre>
</div>
</div>

</body>
</html>