<!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>[166126] trunk</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/166126">166126</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2014-03-22 16:06:37 -0700 (Sat, 22 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>toThis() on a JSWorkerGlobalScope should return a JSProxy and not undefined
https://bugs.webkit.org/show_bug.cgi?id=130554

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

Fixed toThis() on WorkerGlobalScope to return a JSProxy instead of the JSGlobalObject.
Did some cleanup as well.  Moved the setting of the thisObject in a JSGlobalObject to
happen in finishCreation() so that it will also happen for other derived classes including
JSWorkerGlobalScopeBase.

* API/JSContextRef.cpp:
(JSGlobalContextCreateInGroup):
* jsc.cpp:
(GlobalObject::create):
* API/tests/testapi.c:
(globalObject_initialize): Eliminated ASSERT that the global object we are creating matches
the result from JSContextGetGlobalObject() as that will return the proxy.       
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): Removed thisValue parameter and the call to setGlobalThis() since
we now call setGlobalThis in finishCreation().
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::finishCreation):
(JSC::JSGlobalObject::setGlobalThis): Made this a private method.

Source/WebCore: 

Fixed toThis() on WorkerGlobalScope to return a JSProxy instead of the JSGlobalObject.
Added cast from JSProxy-&gt;target() if the jsCast&lt;&gt;() to the native object fails
in toJSDedicatedWorkerGlobalScope() and toJSSharedWorkerGlobalScope().
The original cast is needed for access to the local side of the worker, while the JSProxy
cast is used on the remote side of a worker.

Test: fast/workers/worker-strict.html

* bindings/js/JSWorkerGlobalScopeBase.cpp:
(WebCore::toJSDedicatedWorkerGlobalScope):
(WebCore::toJSSharedWorkerGlobalScope):

* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate): Changed to pass in the JSProxy and not
the WorkerGlobalScope object as the this object to script evaluation.

* workers/DedicatedWorkerGlobalScope.idl:
* workers/SharedWorkerGlobalScope.idl:
* workers/WorkerGlobalScope.idl:
Added the new CustomProxyToJSObject attribute so we'll call to&lt;{nativeClass}&gt;() for
getting the object to use for global evaluation.

LayoutTests: 

Fixed toThis() on WorkerGlobalScope to return a JSProxy instead of the JSGlobalObject.
New regressions tests.

* fast/workers/resources/worker-strict.js: Added.
* fast/workers/worker-strict-expected.txt: Added.
* fast/workers/worker-strict.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIJSContextRefcpp">trunk/Source/JavaScriptCore/API/JSContextRef.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="#trunkSourceJavaScriptCorejsccpp">trunk/Source/JavaScriptCore/jsc.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjecth">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSWorkerGlobalScopeBasecpp">trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWorkerScriptControllercpp">trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersDedicatedWorkerGlobalScopeidl">trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl</a></li>
<li><a href="#trunkSourceWebCoreworkersSharedWorkerGlobalScopeidl">trunk/Source/WebCore/workers/SharedWorkerGlobalScope.idl</a></li>
<li><a href="#trunkSourceWebCoreworkersWorkerGlobalScopeidl">trunk/Source/WebCore/workers/WorkerGlobalScope.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastworkersresourcesworkerstrictjs">trunk/LayoutTests/fast/workers/resources/worker-strict.js</a></li>
<li><a href="#trunkLayoutTestsfastworkersworkerstrictexpectedtxt">trunk/LayoutTests/fast/workers/worker-strict-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastworkersworkerstricthtml">trunk/LayoutTests/fast/workers/worker-strict.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/LayoutTests/ChangeLog        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-03-22  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        toThis() on a JSWorkerGlobalScope should return a JSProxy and not undefined
+        https://bugs.webkit.org/show_bug.cgi?id=130554
+
+        Reviewed by Geoffrey Garen.
+
+        Fixed toThis() on WorkerGlobalScope to return a JSProxy instead of the JSGlobalObject.
+        New regressions tests.
+
+        * fast/workers/resources/worker-strict.js: Added.
+        * fast/workers/worker-strict-expected.txt: Added.
+        * fast/workers/worker-strict.html: Added.
+
</ins><span class="cx"> 2014-03-22  Martin Hodovan  &lt;mhodovan@inf.u-szeged.hu&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: std::isfinite(num) in WebCore::CSSPrimitiveValue::CSSPrimitiveValue
</span></span></pre></div>
<a id="trunkLayoutTestsfastworkersresourcesworkerstrictjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/workers/resources/worker-strict.js (0 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/workers/resources/worker-strict.js                                (rev 0)
+++ trunk/LayoutTests/fast/workers/resources/worker-strict.js        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&quot;use strict&quot;;
+
+postMessage(&quot;SUCCESS: postMessage() called directly&quot;);
+
+(function () {
+    this.done = function() { return &quot;SUCCESS: called function via attribute on WorkerGlobalScope&quot;; };
+
+    this.postMessage(this.done());
+
+    this.postMessage(&quot;DONE&quot;);
+}).call(this);
</ins></span></pre></div>
<a id="trunkLayoutTestsfastworkersworkerstrictexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/workers/worker-strict-expected.txt (0 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/workers/worker-strict-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/workers/worker-strict-expected.txt        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Test calling functions in strict mode script from WorkerContext. Should print SUCCESS lines, followed by DONE.
+
+SUCCESS: postMessage() called directly
+SUCCESS: called function via attribute on WorkerGlobalScope
+DONE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastworkersworkerstricthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/workers/worker-strict.html (0 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/workers/worker-strict.html                                (rev 0)
+++ trunk/LayoutTests/fast/workers/worker-strict.html        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;body&gt;
+&lt;p&gt;Test calling functions in strict mode script from WorkerContext. Should print SUCCESS lines, followed by DONE.&lt;/p&gt;
+&lt;div id=result&gt;&lt;/div&gt;
+&lt;script&gt;
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function log(message)
+{
+    document.getElementById(&quot;result&quot;).innerHTML += message + &quot;&lt;br&gt;&quot;;
+}
+
+var worker = new Worker(&quot;resources/worker-strict.js&quot;);
+worker.onmessage = function(event) {
+    log(event.data);
+    if (event.data == &quot;DONE&quot;) {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+};
+&lt;/script&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIJSContextRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSContextRef.cpp (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSContextRef.cpp        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/JavaScriptCore/API/JSContextRef.cpp        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -129,7 +129,6 @@
</span><span class="cx"> 
</span><span class="cx">     if (!globalObjectClass) {
</span><span class="cx">         JSGlobalObject* globalObject = JSGlobalObject::create(*vm, JSGlobalObject::createStructure(*vm, jsNull()));
</span><del>-        globalObject-&gt;setGlobalThis(*vm, JSProxy::create(*vm, JSProxy::createStructure(*vm, globalObject, globalObject-&gt;prototype()), globalObject));
</del><span class="cx">         return JSGlobalContextRetain(toGlobalRef(globalObject-&gt;globalExec()));
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIteststestapic"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/tests/testapi.c (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/testapi.c        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/JavaScriptCore/API/tests/testapi.c        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -891,10 +891,8 @@
</span><span class="cx">     // Ensure that an execution context is passed in
</span><span class="cx">     ASSERT(context);
</span><span class="cx"> 
</span><del>-    // Ensure that the global object is set to the object that we were passed
</del><span class="cx">     JSObjectRef globalObject = JSContextGetGlobalObject(context);
</span><span class="cx">     ASSERT(globalObject);
</span><del>-    ASSERT(object == globalObject);
</del><span class="cx"> 
</span><span class="cx">     // Ensure that the standard global properties have been set on the global object
</span><span class="cx">     JSStringRef array = JSStringCreateWithUTF8CString(&quot;Array&quot;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-03-22  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        toThis() on a JSWorkerGlobalScope should return a JSProxy and not undefined
+        https://bugs.webkit.org/show_bug.cgi?id=130554
+
+        Reviewed by Geoffrey Garen.
+
+        Fixed toThis() on WorkerGlobalScope to return a JSProxy instead of the JSGlobalObject.
+        Did some cleanup as well.  Moved the setting of the thisObject in a JSGlobalObject to
+        happen in finishCreation() so that it will also happen for other derived classes including
+        JSWorkerGlobalScopeBase.
+
+        * API/JSContextRef.cpp:
+        (JSGlobalContextCreateInGroup):
+        * jsc.cpp:
+        (GlobalObject::create):
+        * API/tests/testapi.c:
+        (globalObject_initialize): Eliminated ASSERT that the global object we are creating matches
+        the result from JSContextGetGlobalObject() as that will return the proxy.       
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init): Removed thisValue parameter and the call to setGlobalThis() since
+        we now call setGlobalThis in finishCreation().
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::finishCreation):
+        (JSC::JSGlobalObject::setGlobalThis): Made this a private method.
+
</ins><span class="cx"> 2014-03-22  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix debug build.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejsccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jsc.cpp (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jsc.cpp        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/JavaScriptCore/jsc.cpp        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -351,7 +351,6 @@
</span><span class="cx">         GlobalObject* object = new (NotNull, allocateCell&lt;GlobalObject&gt;(vm.heap)) GlobalObject(vm, structure);
</span><span class="cx">         object-&gt;finishCreation(vm, arguments);
</span><span class="cx">         vm.heap.addFinalizer(object, destroy);
</span><del>-        object-&gt;setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, object, object-&gt;prototype()), object));
</del><span class="cx">         return object;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -196,11 +196,10 @@
</span><span class="cx">     m_globalThis.set(vm, this, globalThis);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSGlobalObject::init(JSObject* thisValue)
</del><ins>+void JSGlobalObject::init()
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(vm().currentThreadIsHoldingAPILock());
</span><span class="cx"> 
</span><del>-    setGlobalThis(vm(), thisValue);
</del><span class="cx">     JSGlobalObject::globalExec()-&gt;init(0, 0, this, CallFrame::noCaller(), 0, 0);
</span><span class="cx"> 
</span><span class="cx">     m_debugger = 0;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;JSArray.h&quot;
</span><span class="cx"> #include &quot;JSArrayBufferPrototype.h&quot;
</span><span class="cx"> #include &quot;JSClassRef.h&quot;
</span><ins>+#include &quot;JSProxy.h&quot;
</ins><span class="cx"> #include &quot;JSSegmentedVariableObject.h&quot;
</span><span class="cx"> #include &quot;JSWeakObjectMapRefInternal.h&quot;
</span><span class="cx"> #include &quot;NumberPrototype.h&quot;
</span><span class="lines">@@ -294,7 +295,8 @@
</span><span class="cx">         Base::finishCreation(vm);
</span><span class="cx">         structure()-&gt;setGlobalObject(vm, this);
</span><span class="cx">         m_experimentsEnabled = m_globalObjectMethodTable-&gt;javaScriptExperimentsEnabled(this);
</span><del>-        init(this);
</del><ins>+        init();
+        setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, this, prototype()), this));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void finishCreation(VM&amp; vm, JSObject* thisValue)
</span><span class="lines">@@ -302,7 +304,8 @@
</span><span class="cx">         Base::finishCreation(vm);
</span><span class="cx">         structure()-&gt;setGlobalObject(vm, this);
</span><span class="cx">         m_experimentsEnabled = m_globalObjectMethodTable-&gt;javaScriptExperimentsEnabled(this);
</span><del>-        init(thisValue);
</del><ins>+        init();
+        setGlobalThis(vm, thisValue);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     struct NewGlobalVar {
</span><span class="lines">@@ -535,7 +538,6 @@
</span><span class="cx"> 
</span><span class="cx">     VM&amp; vm() const { return *Heap::heap(this)-&gt;vm(); }
</span><span class="cx">     JSObject* globalThis() const;
</span><del>-    JS_EXPORT_PRIVATE void setGlobalThis(VM&amp;, JSObject* globalThis);
</del><span class="cx"> 
</span><span class="cx">     static Structure* createStructure(VM&amp; vm, JSValue prototype)
</span><span class="cx">     {
</span><span class="lines">@@ -588,9 +590,11 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     friend class LLIntOffsetsExtractor;
</span><del>-        
</del><ins>+
+    JS_EXPORT_PRIVATE void setGlobalThis(VM&amp;, JSObject* globalThis);
+
</ins><span class="cx">     // FIXME: Fold reset into init.
</span><del>-    JS_EXPORT_PRIVATE void init(JSObject* thisValue);
</del><ins>+    JS_EXPORT_PRIVATE void init();
</ins><span class="cx">     void reset(JSValue prototype);
</span><span class="cx"> 
</span><span class="cx">     void createThrowTypeError(VM&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/WebCore/ChangeLog        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2014-03-22  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        toThis() on a JSWorkerGlobalScope should return a JSProxy and not undefined
+        https://bugs.webkit.org/show_bug.cgi?id=130554
+
+        Reviewed by Geoffrey Garen.
+
+        Fixed toThis() on WorkerGlobalScope to return a JSProxy instead of the JSGlobalObject.
+        Added cast from JSProxy-&gt;target() if the jsCast&lt;&gt;() to the native object fails
+        in toJSDedicatedWorkerGlobalScope() and toJSSharedWorkerGlobalScope().
+        The original cast is needed for access to the local side of the worker, while the JSProxy
+        cast is used on the remote side of a worker.
+
+        Test: fast/workers/worker-strict.html
+
+        * bindings/js/JSWorkerGlobalScopeBase.cpp:
+        (WebCore::toJSDedicatedWorkerGlobalScope):
+        (WebCore::toJSSharedWorkerGlobalScope):
+
+        * bindings/js/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::evaluate): Changed to pass in the JSProxy and not
+        the WorkerGlobalScope object as the this object to script evaluation.
+
+        * workers/DedicatedWorkerGlobalScope.idl:
+        * workers/SharedWorkerGlobalScope.idl:
+        * workers/WorkerGlobalScope.idl:
+        Added the new CustomProxyToJSObject attribute so we'll call to&lt;{nativeClass}&gt;() for
+        getting the object to use for global evaluation.
+
</ins><span class="cx"> 2014-03-22  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Some #include hygiene in Node/Element etc
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSWorkerGlobalScopeBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -130,6 +130,8 @@
</span><span class="cx">     const ClassInfo* classInfo = asObject(value)-&gt;classInfo();
</span><span class="cx">     if (classInfo == JSDedicatedWorkerGlobalScope::info())
</span><span class="cx">         return jsCast&lt;JSDedicatedWorkerGlobalScope*&gt;(asObject(value));
</span><ins>+    if (classInfo == JSProxy::info())
+        return jsDynamicCast&lt;JSDedicatedWorkerGlobalScope*&gt;(jsCast&lt;JSProxy*&gt;(asObject(value))-&gt;target());
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -141,6 +143,8 @@
</span><span class="cx">     const ClassInfo* classInfo = asObject(value)-&gt;classInfo();
</span><span class="cx">     if (classInfo == JSSharedWorkerGlobalScope::info())
</span><span class="cx">         return jsCast&lt;JSSharedWorkerGlobalScope*&gt;(asObject(value));
</span><ins>+    if (classInfo == JSProxy::info())
+        return jsDynamicCast&lt;JSSharedWorkerGlobalScope*&gt;(jsCast&lt;JSProxy*&gt;(asObject(value))-&gt;target());
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWorkerScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -132,7 +132,7 @@
</span><span class="cx">     JSLockHolder lock(exec);
</span><span class="cx"> 
</span><span class="cx">     JSValue evaluationException;
</span><del>-    JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper.get(), &amp;evaluationException);
</del><ins>+    JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper-&gt;globalThis(), &amp;evaluationException);
</ins><span class="cx"> 
</span><span class="cx">     if ((evaluationException &amp;&amp; isTerminatedExecutionException(evaluationException)) ||  m_workerGlobalScopeWrapper-&gt;vm().watchdog.didFire()) {
</span><span class="cx">         forbidExecution();
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersDedicatedWorkerGlobalScopeidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     GlobalContext=DedicatedWorkerGlobalScope,
</span><ins>+    CustomProxyToJSObject,
</ins><span class="cx">     JSGenerateToNativeObject,
</span><span class="cx">     JSNoStaticTables,
</span><span class="cx"> ] interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersSharedWorkerGlobalScopeidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/SharedWorkerGlobalScope.idl (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/SharedWorkerGlobalScope.idl        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/WebCore/workers/SharedWorkerGlobalScope.idl        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     GlobalContext=SharedWorkerGlobalScope,
</span><ins>+    CustomProxyToJSObject,
</ins><span class="cx">     Conditional=SHARED_WORKERS,
</span><span class="cx">     JSGenerateToNativeObject,
</span><span class="cx">     JSNoStaticTables,
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersWorkerGlobalScopeidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.idl (166125 => 166126)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/WorkerGlobalScope.idl        2014-03-22 20:57:04 UTC (rev 166125)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.idl        2014-03-22 23:06:37 UTC (rev 166126)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     GlobalContext=WorkerGlobalScope,
</span><ins>+    CustomProxyToJSObject,
</ins><span class="cx">     JSCustomMarkFunction,
</span><span class="cx">     JSCustomGetOwnPropertySlotAndDescriptor,
</span><span class="cx">     EventTarget,
</span></span></pre>
</div>
</div>

</body>
</html>