<!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>[38599] 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/38599">38599</a></dd>
<dt>Author</dt> <dd>ap@webkit.org</dd>
<dt>Date</dt> <dd>2008-11-19 10:28:57 -0800 (Wed, 19 Nov 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=22355
        Systematize code for replacing global constructors

        Test: fast/workers/worker-replace-global-constructor.html

        * bindings/js/JSDOMWindowBase.cpp:
        (setJSDOMWindowBaseEvent): Changed to put the value as property, matching what generated
        code for global constructor setters does.
        (setJSDOMWindowBaseAudio): Ditto.
        (setJSDOMWindowBaseImage): Ditto.
        (setJSDOMWindowBaseMessageChannel): Ditto.
        (setJSDOMWindowBaseOption): Ditto.
        (setJSDOMWindowBaseWorker): Ditto.
        (setJSDOMWindowBaseXMLHttpRequest): Ditto.
        (setJSDOMWindowBaseXSLTProcessor): Ditto.
        (WebCore::JSDOMWindowBase::put): Removed special cases for global constructors.

        * bindings/js/JSWorkerContext.cpp:
        (WebCore::JSWorkerContext::getOwnPropertySlot): Look up overrides before own properties,
        as it is done for Window.
        (WebCore::setJSWorkerContextMessageEvent): Implemented in the same way as Window global
        constructors are.
        (WebCore::setJSWorkerContextWorkerLocation): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorebindingsjsJSDOMWindowBasecpp">trunk/WebCore/bindings/js/JSDOMWindowBase.cpp</a></li>
<li><a href="#trunkWebCorebindingsjsJSWorkerContextcpp">trunk/WebCore/bindings/js/JSWorkerContext.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastworkersworkerreplaceglobalconstructorexpectedtxt">trunk/LayoutTests/fast/workers/worker-replace-global-constructor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastworkersworkerreplaceglobalconstructorhtml">trunk/LayoutTests/fast/workers/worker-replace-global-constructor.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (38598 => 38599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2008-11-19 18:09:47 UTC (rev 38598)
+++ trunk/LayoutTests/ChangeLog        2008-11-19 18:28:57 UTC (rev 38599)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2008-11-19  Alexey Proskuryakov  &lt;ap@webkit.org&gt;
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=22355
+        Systematize code for replacing global constructors
+
+        * fast/workers/worker-replace-global-constructor-expected.txt: Added.
+        * fast/workers/worker-replace-global-constructor.html: Added.
+
</ins><span class="cx"> 2008-11-18  Cameron Zwarich  &lt;zwarich@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Maciej Stachowiak and Geoff Garen.
</span></span></pre></div>
<a id="trunkLayoutTestsfastworkersworkerreplaceglobalconstructorexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/workers/worker-replace-global-constructor-expected.txt (0 => 38599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/workers/worker-replace-global-constructor-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/workers/worker-replace-global-constructor-expected.txt        2008-11-19 18:28:57 UTC (rev 38599)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+Test replacing global constructors in a worker context.
+
+self.MessageEvent = 'PASS'; MessageEvent;: PASS
+DONE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/workers/worker-replace-global-constructor-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsfastworkersworkerreplaceglobalconstructorhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/workers/worker-replace-global-constructor.html (0 => 38599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/workers/worker-replace-global-constructor.html                                (rev 0)
+++ trunk/LayoutTests/fast/workers/worker-replace-global-constructor.html        2008-11-19 18:28:57 UTC (rev 38599)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;body&gt;
+&lt;p&gt;Test replacing global constructors in a worker context.&lt;/p&gt;
+&lt;div id=result&gt;&lt;/div&gt;
+&lt;script&gt;
+function log(message)
+{
+    document.getElementById(&quot;result&quot;).innerHTML += message + &quot;&lt;br&gt;&quot;;
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+var worker = new Worker('resources/worker-common.js');
+worker.postMessage(&quot;eval self.MessageEvent = 'PASS'; MessageEvent;&quot;);
+worker.postMessage(&quot;eval foo//bar&quot;);
+
+worker.onmessage = function(evt) {
+    if (!/foo\/\/bar/.test(evt.data))
+        log(evt.data);
+    else {
+        log(&quot;DONE&quot;);
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+}
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/workers/worker-replace-global-constructor.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (38598 => 38599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2008-11-19 18:09:47 UTC (rev 38598)
+++ trunk/WebCore/ChangeLog        2008-11-19 18:28:57 UTC (rev 38599)
</span><span class="lines">@@ -2,6 +2,34 @@
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin Adler.
</span><span class="cx"> 
</span><ins>+        https://bugs.webkit.org/show_bug.cgi?id=22355
+        Systematize code for replacing global constructors
+
+        Test: fast/workers/worker-replace-global-constructor.html
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (setJSDOMWindowBaseEvent): Changed to put the value as property, matching what generated
+        code for global constructor setters does.
+        (setJSDOMWindowBaseAudio): Ditto.
+        (setJSDOMWindowBaseImage): Ditto.
+        (setJSDOMWindowBaseMessageChannel): Ditto.
+        (setJSDOMWindowBaseOption): Ditto.
+        (setJSDOMWindowBaseWorker): Ditto.
+        (setJSDOMWindowBaseXMLHttpRequest): Ditto.
+        (setJSDOMWindowBaseXSLTProcessor): Ditto.
+        (WebCore::JSDOMWindowBase::put): Removed special cases for global constructors.
+
+        * bindings/js/JSWorkerContext.cpp:
+        (WebCore::JSWorkerContext::getOwnPropertySlot): Look up overrides before own properties,
+        as it is done for Window.
+        (WebCore::setJSWorkerContextMessageEvent): Implemented in the same way as Window global
+        constructors are.
+        (WebCore::setJSWorkerContextWorkerLocation): Ditto.
+
+2008-11-19  Alexey Proskuryakov  &lt;ap@webkit.org&gt;
+
+        Reviewed by Darin Adler.
+
</ins><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=22341
</span><span class="cx">         Text codecs should not use static data without locking
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCorebindingsjsJSDOMWindowBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/js/JSDOMWindowBase.cpp (38598 => 38599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/js/JSDOMWindowBase.cpp        2008-11-19 18:09:47 UTC (rev 38598)
+++ trunk/WebCore/bindings/js/JSDOMWindowBase.cpp        2008-11-19 18:28:57 UTC (rev 38599)
</span><span class="lines">@@ -477,6 +477,70 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void setJSDOMWindowBaseEvent(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;Event&quot;), value);
+}
+
+void setJSDOMWindowBaseAudio(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;Audio&quot;), value);
+}
+
+void setJSDOMWindowBaseImage(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;Image&quot;), value);
+}
+
+void setJSDOMWindowBaseMessageChannel(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;MessageChannel&quot;), value);
+}
+
+void setJSDOMWindowBaseOption(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;Option&quot;), value);
+}
+
+void setJSDOMWindowBaseWorker(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;Worker&quot;), value);
+}
+
+void setJSDOMWindowBaseXMLHttpRequest(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;XMLHttpRequest&quot;), value);
+}
+
+void setJSDOMWindowBaseXSLTProcessor(ExecState* exec, JSObject* thisObject, JSValue* value)
+{
+    if (!static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;allowsAccessFrom(exec))
+        return;
+    // Shadowing a built-in constructor
+    static_cast&lt;JSDOMWindowBase*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;XSLTProcessor&quot;), value);
+}
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> JSValue* JSDOMWindowBase::childFrameGetter(ExecState* exec, const Identifier&amp; propertyName, const PropertySlot&amp; slot)
</span><span class="lines">@@ -582,69 +646,12 @@
</span><span class="cx">         }
</span><span class="cx">         if (entry-&gt;attributes() &amp; ReadOnly)
</span><span class="cx">             return;
</span><del>-
-        // Don't call the put function for replacable properties.
-        if (!(entry-&gt;propertyPutter() == setJSDOMWindowBaseEvent
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseAudio
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseImage
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseOption
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseMessageChannel
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseWorker
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseXMLHttpRequest
-                || entry-&gt;propertyPutter() == setJSDOMWindowBaseXSLTProcessor)) {
-            entry-&gt;propertyPutter()(exec, this, value);
-            return;
-        }
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (allowsAccessFrom(exec))
</span><span class="cx">         Base::put(exec, propertyName, value, slot);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-} // namespace WebCore
-
-void setJSDOMWindowBaseEvent(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseAudio(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseImage(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseMessageChannel(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseOption(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseWorker(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseXMLHttpRequest(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-void setJSDOMWindowBaseXSLTProcessor(ExecState*, JSObject*, JSValue*)
-{
-    ASSERT_NOT_REACHED();
-}
-
-namespace WebCore {
-
</del><span class="cx"> String JSDOMWindowBase::crossDomainAccessErrorMessage(const JSGlobalObject* other) const
</span><span class="cx"> {
</span><span class="cx">     KURL originURL = asJSDOMWindow(other)-&gt;impl()-&gt;url();
</span></span></pre></div>
<a id="trunkWebCorebindingsjsJSWorkerContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/js/JSWorkerContext.cpp (38598 => 38599)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/js/JSWorkerContext.cpp        2008-11-19 18:09:47 UTC (rev 38598)
+++ trunk/WebCore/bindings/js/JSWorkerContext.cpp        2008-11-19 18:28:57 UTC (rev 38599)
</span><span class="lines">@@ -147,6 +147,9 @@
</span><span class="cx"> 
</span><span class="cx"> bool JSWorkerContext::getOwnPropertySlot(ExecState* exec, const Identifier&amp; propertyName, PropertySlot&amp; slot)
</span><span class="cx"> {
</span><ins>+    // Look for overrides before looking at any of our own properties.
+    if (JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot))
+        return true;
</ins><span class="cx">     return getStaticValueSlot&lt;JSWorkerContext, Base&gt;(exec, getJSWorkerContextTable(exec), this, propertyName, slot);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -251,15 +254,16 @@
</span><span class="cx">     return getStaticFunctionSlot&lt;JSObject&gt;(exec, getJSWorkerContextPrototypeTable(exec), this, propertyName, slot);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void setJSWorkerContextMessageEvent(ExecState*, JSObject*, JSValue*)
</del><ins>+void setJSWorkerContextMessageEvent(ExecState* exec, JSObject* thisObject, JSValue* value)
</ins><span class="cx"> {
</span><del>-    // FIXME: Do we need to override put for global constructors, like JSDOMWindowBase does?
-    ASSERT_NOT_REACHED();
</del><ins>+    // Shadowing a built-in constructor
+    static_cast&lt;JSWorkerContext*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;MessageEvent&quot;), value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void setJSWorkerContextWorkerLocation(ExecState*, JSObject*, JSValue*)
</del><ins>+void setJSWorkerContextWorkerLocation(ExecState* exec, JSObject* thisObject, JSValue* value)
</ins><span class="cx"> {
</span><del>-    ASSERT_NOT_REACHED();
</del><ins>+    // Shadowing a built-in constructor
+    static_cast&lt;JSWorkerContext*&gt;(thisObject)-&gt;putDirect(Identifier(exec, &quot;Location&quot;), value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>