<!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>[171543] trunk/Source/JavaScriptCore</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/171543">171543</a></dd>
<dt>Author</dt> <dd>mhahnenberg@apple.com</dd>
<dt>Date</dt> <dd>2014-07-24 15:56:05 -0700 (Thu, 24 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Creating a JSGlobalObject with a custom JSClassRef results in a JSProxy with the wrong prototype
https://bugs.webkit.org/show_bug.cgi?id=135250

Reviewed by Geoffrey Garen.

JSGlobalObject::resetPrototype (which is called from JSGlobalContextCreateInGroup) doesn't change its 
JSProxy's prototype as well. This results in a JSProxy where no properties in the original prototype 
chain (as created from the JSClassRef hierarchy) are accessible. Changing resetPrototype to also change
the JSProxy's prototype fixes the issue.

* API/JSValueRef.cpp:
(JSValueIsObjectOfClass): Also fixed a bug where a JSProxy for a JSGlobalObject with a custom JSClassRef
would claim it wasn't of the specified class, even if the target was of the specified class.
* API/tests/CustomGlobalObjectClassTest.c: Added.
(jsDoSomething):
(customGlobalObjectClassTest):
* API/tests/CustomGlobalObjectClassTest.h: Added.
* API/tests/testapi.c:
(assertTrue):
(main):
* JavaScriptCore.vcxproj/testapi/testapi.vcxproj:
* JavaScriptCore.vcxproj/testapi/testapi.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::resetPrototype):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIJSValueRefcpp">trunk/Source/JavaScriptCore/API/JSValueRef.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIteststestapic">trunk/Source/JavaScriptCore/API/tests/testapi.c</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojtestapitestapivcxproj">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorevcxprojtestapitestapivcxprojfilters">trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj.filters</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPItestsCustomGlobalObjectClassTestc">trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPItestsCustomGlobalObjectClassTesth">trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreAPIJSValueRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSValueRef.cpp (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSValueRef.cpp        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/API/JSValueRef.cpp        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -179,6 +179,9 @@
</span><span class="cx">     JSValue jsValue = toJS(exec, value);
</span><span class="cx">     
</span><span class="cx">     if (JSObject* o = jsValue.getObject()) {
</span><ins>+        if (o-&gt;inherits(JSProxy::info()))
+            o = jsCast&lt;JSProxy*&gt;(o)-&gt;target();
+
</ins><span class="cx">         if (o-&gt;inherits(JSCallbackObject&lt;JSGlobalObject&gt;::info()))
</span><span class="cx">             return jsCast&lt;JSCallbackObject&lt;JSGlobalObject&gt;*&gt;(o)-&gt;inherits(jsClass);
</span><span class="cx">         if (o-&gt;inherits(JSCallbackObject&lt;JSDestructibleObject&gt;::info()))
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPItestsCustomGlobalObjectClassTestc"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c (0 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c                                (rev 0)
+++ trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;CustomGlobalObjectClassTest.h&quot;
+
+#include &lt;JavaScriptCore/JavaScriptCore.h&gt;
+#include &lt;stdio.h&gt;
+
+extern bool assertTrue(bool value, const char* message);
+
+static bool executedCallback = false;
+
+static JSValueRef jsDoSomething(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef args[], JSValueRef* exception)
+{
+    (void)function;
+    (void)thisObject;
+    (void)argc;
+    (void)args;
+    (void)exception;
+    executedCallback = true;
+    return JSValueMakeNull(ctx);
+}
+
+static JSStaticFunction bridgedFunctions[] = {
+    {&quot;doSomething&quot;, jsDoSomething, kJSPropertyAttributeDontDelete},
+    {0, 0, 0},
+};
+
+static JSClassRef bridgedObjectClass = NULL;
+static JSClassDefinition bridgedClassDef;
+
+static JSClassRef jsClassRef()
+{
+    if (!bridgedObjectClass) {
+        bridgedClassDef = kJSClassDefinitionEmpty;
+        bridgedClassDef.className = &quot;BridgedObject&quot;;
+        bridgedClassDef.staticFunctions = bridgedFunctions;
+        bridgedObjectClass = JSClassCreate(&amp;bridgedClassDef);
+    }
+    return bridgedObjectClass;
+}
+
+void customGlobalObjectClassTest()
+{
+    JSClassRef bridgedObjectJsClassRef = jsClassRef();
+    JSGlobalContextRef globalContext = JSGlobalContextCreate(bridgedObjectJsClassRef);
+    
+    JSObjectRef globalObj = JSContextGetGlobalObject(globalContext);
+    
+    JSPropertyNameArrayRef propertyNames = JSObjectCopyPropertyNames(globalContext, globalObj);
+    size_t propertyCount = JSPropertyNameArrayGetCount(propertyNames);
+    assertTrue(propertyCount == 1, &quot;Property count == 1&quot;);
+    
+    JSStringRef propertyNameRef = JSPropertyNameArrayGetNameAtIndex(propertyNames, 0);
+    size_t propertyNameLength = JSStringGetLength(propertyNameRef);
+    size_t bufferSize = sizeof(char) * (propertyNameLength + 1);
+    char* buffer = (char*)malloc(bufferSize);
+    JSStringGetUTF8CString(propertyNameRef, buffer, bufferSize);
+    buffer[propertyNameLength] = '\0';
+    assertTrue(!strncmp(buffer, &quot;doSomething&quot;, propertyNameLength), &quot;First property name is doSomething&quot;);
+    free(buffer);
+    
+    bool hasMethod = JSObjectHasProperty(globalContext, globalObj, propertyNameRef);
+    assertTrue(hasMethod, &quot;Property found by name&quot;);
+    
+    JSValueRef doSomethingProperty =
+    JSObjectGetProperty(globalContext, globalObj, propertyNameRef, NULL);
+    assertTrue(!JSValueIsUndefined(globalContext, doSomethingProperty), &quot;Property is defined&quot;);
+    
+    bool globalObjectClassMatchesClassRef = JSValueIsObjectOfClass(globalContext, globalObj, bridgedObjectJsClassRef);
+    assertTrue(globalObjectClassMatchesClassRef, &quot;Global object is the right class&quot;);
+    
+    JSStringRef script = JSStringCreateWithUTF8CString(&quot;doSomething();&quot;);
+    JSEvaluateScript(globalContext, script, NULL, NULL, 1, NULL);
+    JSStringRelease(script);
+
+    assertTrue(executedCallback, &quot;Executed custom global object callback&quot;);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPItestsCustomGlobalObjectClassTesth"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.h (0 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.h        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CustomGlobalObjectClassTest_h
+#define CustomGlobalObjectClassTest_h
+
+void customGlobalObjectClassTest(void);
+
+#endif // CustomGlobalObjectClassTest_h
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIteststestapic"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/tests/testapi.c (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/testapi.c        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/API/tests/testapi.c        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -45,10 +45,13 @@
</span><span class="cx"> #include &lt;windows.h&gt;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#include &quot;CustomGlobalObjectClassTest.h&quot;
+
</ins><span class="cx"> #if JSC_OBJC_API_ENABLED
</span><span class="cx"> void testObjectiveCAPI(void);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+bool assertTrue(bool value, const char* message);
</ins><span class="cx"> extern void JSSynchronousGarbageCollectForDebugging(JSContextRef);
</span><span class="cx"> 
</span><span class="cx"> static JSGlobalContextRef context;
</span><span class="lines">@@ -975,7 +978,7 @@
</span><span class="cx">     v = NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool assertTrue(bool value, const char* message)
</del><ins>+bool assertTrue(bool value, const char* message)
</ins><span class="cx"> {
</span><span class="cx">     if (!value) {
</span><span class="cx">         if (message)
</span><span class="lines">@@ -2075,6 +2078,8 @@
</span><span class="cx">     if (globalContextNameTest())
</span><span class="cx">         printf(&quot;PASS: global context name behaves as expected.\n&quot;);
</span><span class="cx"> 
</span><ins>+    customGlobalObjectClassTest();
+
</ins><span class="cx">     if (failed) {
</span><span class="cx">         printf(&quot;FAIL: Some tests failed.\n&quot;);
</span><span class="cx">         return 1;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2014-07-24  Mark Hahnenberg  &lt;mhahnenberg@apple.com&gt;
+
+        Creating a JSGlobalObject with a custom JSClassRef results in a JSProxy with the wrong prototype
+        https://bugs.webkit.org/show_bug.cgi?id=135250
+
+        Reviewed by Geoffrey Garen.
+
+        JSGlobalObject::resetPrototype (which is called from JSGlobalContextCreateInGroup) doesn't change its 
+        JSProxy's prototype as well. This results in a JSProxy where no properties in the original prototype 
+        chain (as created from the JSClassRef hierarchy) are accessible. Changing resetPrototype to also change
+        the JSProxy's prototype fixes the issue.
+
+        * API/JSValueRef.cpp:
+        (JSValueIsObjectOfClass): Also fixed a bug where a JSProxy for a JSGlobalObject with a custom JSClassRef
+        would claim it wasn't of the specified class, even if the target was of the specified class.
+        * API/tests/CustomGlobalObjectClassTest.c: Added.
+        (jsDoSomething):
+        (customGlobalObjectClassTest):
+        * API/tests/CustomGlobalObjectClassTest.h: Added.
+        * API/tests/testapi.c:
+        (assertTrue):
+        (main):
+        * JavaScriptCore.vcxproj/testapi/testapi.vcxproj:
+        * JavaScriptCore.vcxproj/testapi/testapi.vcxproj.filters:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::resetPrototype):
+
</ins><span class="cx"> 2014-07-24  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Replay: don't encode/decode primitive types that lack explicit sizes
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojtestapitestapivcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -292,8 +292,10 @@
</span><span class="cx">   &lt;/ItemGroup&gt;
</span><span class="cx">   &lt;ItemGroup&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\..\API\tests\testapi.c&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\..\API\tests\CustomGlobalObjectClassTest.c&quot; /&gt;
+    &lt;ClInclude Include=&quot;..\..\API\tests\CustomGlobalObjectClassTest.h&quot; /&gt;
</ins><span class="cx">   &lt;/ItemGroup&gt;
</span><span class="cx">   &lt;Import Project=&quot;$(VCTargetsPath)\Microsoft.Cpp.targets&quot; /&gt;
</span><span class="cx">   &lt;ImportGroup Label=&quot;ExtensionTargets&quot;&gt;
</span><span class="cx">   &lt;/ImportGroup&gt;
</span><del>-&lt;/Project&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+&lt;/Project&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorevcxprojtestapitestapivcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj.filters (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj.filters        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/testapi/testapi.vcxproj.filters        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -8,5 +8,7 @@
</span><span class="cx">   &lt;/ItemGroup&gt;
</span><span class="cx">   &lt;ItemGroup&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\..\API\tests\testapi.c&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\..\API\tests\CustomGlobalObjectClassTest.c&quot; /&gt;
+    &lt;ClInclude Include=&quot;..\..\API\tests\CustomGlobalObjectClassTest.h&quot; /&gt;
</ins><span class="cx">   &lt;/ItemGroup&gt;
</span><del>-&lt;/Project&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+&lt;/Project&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -1977,6 +1977,7 @@
</span><span class="cx">                 BCF605140E203EF800B9A64D /* ArgList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF605120E203EF800B9A64D /* ArgList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 BCFD8C920EEB2EE700283848 /* JumpTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCFD8C900EEB2EE700283848 /* JumpTable.cpp */; };
</span><span class="cx">                 BCFD8C930EEB2EE700283848 /* JumpTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFD8C910EEB2EE700283848 /* JumpTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                C20328201981979D0088B499 /* CustomGlobalObjectClassTest.c in Sources */ = {isa = PBXBuildFile; fileRef = C203281E1981979D0088B499 /* CustomGlobalObjectClassTest.c */; };
</ins><span class="cx">                 C20B25991706536200C21F4E /* Region.h in Headers */ = {isa = PBXBuildFile; fileRef = C20B25981706536200C21F4E /* Region.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 C20BA92D16BB1C1500B3AEA2 /* StructureRareDataInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C21122DE15DD9AB300790E3A /* GCThreadSharedData.cpp */; };
</span><span class="lines">@@ -3611,6 +3612,8 @@
</span><span class="cx">                 BCF605120E203EF800B9A64D /* ArgList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BCFD8C900EEB2EE700283848 /* JumpTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JumpTable.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BCFD8C910EEB2EE700283848 /* JumpTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JumpTable.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                C203281E1981979D0088B499 /* CustomGlobalObjectClassTest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CustomGlobalObjectClassTest.c; path = API/tests/CustomGlobalObjectClassTest.c; sourceTree = &quot;&lt;group&gt;&quot;; };
+                C203281F1981979D0088B499 /* CustomGlobalObjectClassTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomGlobalObjectClassTest.h; path = API/tests/CustomGlobalObjectClassTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 C20B25981706536200C21F4E /* Region.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Region.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C20BA92C16BB1C1500B3AEA2 /* StructureRareDataInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureRareDataInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 C21122DE15DD9AB300790E3A /* GCThreadSharedData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCThreadSharedData.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4073,6 +4076,8 @@
</span><span class="cx">                 141211000A48772600480255 /* tests */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                C203281E1981979D0088B499 /* CustomGlobalObjectClassTest.c */,
+                                C203281F1981979D0088B499 /* CustomGlobalObjectClassTest.h */,
</ins><span class="cx">                                 C29ECB021804D0ED00D2CBB4 /* CurrentThisInsideBlockGetterTest.h */,
</span><span class="cx">                                 C29ECB011804D0ED00D2CBB4 /* CurrentThisInsideBlockGetterTest.mm */,
</span><span class="cx">                                 C288B2DC18A54D3E007BE40B /* DateTests.h */,
</span><span class="lines">@@ -7453,6 +7458,7 @@
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><span class="cx">                                 C29ECB031804D0ED00D2CBB4 /* CurrentThisInsideBlockGetterTest.mm in Sources */,
</span><ins>+                                C20328201981979D0088B499 /* CustomGlobalObjectClassTest.c in Sources */,
</ins><span class="cx">                                 C288B2DE18A54D3E007BE40B /* DateTests.mm in Sources */,
</span><span class="cx">                                 C2181FC218A948FB0025A235 /* JSExportTests.mm in Sources */,
</span><span class="cx">                                 1440F6100A4F85670005F061 /* testapi.c in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (171542 => 171543)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2014-07-24 22:55:57 UTC (rev 171542)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2014-07-24 22:56:05 UTC (rev 171543)
</span><span class="lines">@@ -623,6 +623,9 @@
</span><span class="cx">     JSObject* objectPrototype = m_objectPrototype.get();
</span><span class="cx">     if (oldLastInPrototypeChain != objectPrototype)
</span><span class="cx">         oldLastInPrototypeChain-&gt;setPrototype(vm, objectPrototype);
</span><ins>+
+    // Whenever we change the prototype of the global object, we need to create a new JSProxy with the correct prototype.
+    setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, this, prototype, PureForwardingProxyType), this));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor&amp; visitor)
</span></span></pre>
</div>
</div>

</body>
</html>