2010-09-07 Jessie Berlin <jberlin@apple.com>
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Sep 2010 18:09:31 +0000 (18:09 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Sep 2010 18:09:31 +0000 (18:09 +0000)
        Reviewed by Darin Adler.

        Indicate which one of the ScriptWorlds for a Frame the Window Object has been cleared for
        https://bugs.webkit.org/show_bug.cgi?id=45217

        WebKit2:

        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:

        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
        (WebKit::InjectedBundlePageLoaderClient::didClearWindowObjectForFrame):
        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:

        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):

        WebKitTools:

        Make WebKitTestRunner work with this change.

        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
        (WTR::InjectedBundlePage::didClearWindowForFrame):
        Make sure the ScriptWorld here is the normal world, since that is no longer being done in
        WebFrameLoaderClient.
        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66894 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp
WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h
WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
WebKitTools/ChangeLog
WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h

index 28957b0..2e30e8c 100644 (file)
@@ -1,3 +1,19 @@
+2010-09-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Indicate which one of the ScriptWorlds for a Frame the Window Object has been cleared for
+        https://bugs.webkit.org/show_bug.cgi?id=45217
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
+        (WebKit::InjectedBundlePageLoaderClient::didClearWindowObjectForFrame):
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+
 2010-09-06  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Darin Adler.
index ea43049..b723474 100644 (file)
@@ -57,7 +57,7 @@ typedef void (*WKBundlePageDidDocumentFinishLoadForFrameCallback)(WKBundlePageRe
 typedef void (*WKBundlePageDidFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
 typedef void (*WKBundlePageDidFailLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo); // FIXME: Add WKErrorRef.
 typedef void (*WKBundlePageDidReceiveTitleForFrameCallback)(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, const void *clientInfo);
-typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window, const void *clientInfo);
+typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo);
 typedef void (*WKBundlePageDidCancelClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
 typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
 typedef void (*WKBundlePageDidChangeLocationWithinPageForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
index 237499c..8ddf9bb 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "InjectedBundlePageLoaderClient.h"
 
+#include "InjectedBundleScriptWorld.h"
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
 #include <wtf/text/WTFString.h>
@@ -94,10 +95,10 @@ void InjectedBundlePageLoaderClient::didReceiveTitleForFrame(WebPage* page, cons
         m_client.didReceiveTitleForFrame(toRef(page), toRef(title.impl()), toRef(frame), m_client.clientInfo);
 }
 
-void InjectedBundlePageLoaderClient::didClearWindowObjectForFrame(WebPage* page, WebFrame* frame, JSGlobalContextRef context, JSObjectRef window)
+void InjectedBundlePageLoaderClient::didClearWindowObjectForFrame(WebPage* page, WebFrame* frame, DOMWrapperWorld* world)
 {
     if (m_client.didClearWindowObjectForFrame)
-        m_client.didClearWindowObjectForFrame(toRef(page), toRef(frame), context, window, m_client.clientInfo);
+        m_client.didClearWindowObjectForFrame(toRef(page), toRef(frame), toRef(InjectedBundleScriptWorld::getOrCreate(world).get()), m_client.clientInfo);
 }
 
 void InjectedBundlePageLoaderClient::didCancelClientRedirectForFrame(WebPage* page, WebFrame* frame)
index 00c7fc6..0f547c5 100644 (file)
 #include <JavaScriptCore/JSBase.h>
 #include <wtf/Forward.h>
 
+namespace WebCore {
+class DOMWrapperWorld;
+}
+
 namespace WebKit {
 
 class WebPage;
@@ -48,7 +52,7 @@ public:
     void didFinishLoadForFrame(WebPage*, WebFrame*);
     void didFailLoadWithErrorForFrame(WebPage*, WebFrame*);
     void didReceiveTitleForFrame(WebPage*, const WTF::String&, WebFrame*);
-    void didClearWindowObjectForFrame(WebPage*, WebFrame*, JSGlobalContextRef, JSObjectRef);
+    void didClearWindowObjectForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld*);
     void didCancelClientRedirectForFrame(WebPage*, WebFrame*);
     void willPerformClientRedirectForFrame(WebPage*, WebFrame*, const WTF::String& url, double delay, double date);
     void didChangeLocationWithinPageForFrame(WebPage*, WebFrame*);
index 55793aa..e4f611f 100644 (file)
@@ -994,15 +994,7 @@ void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*
     if (!webPage)
         return;
 
-    if (world != mainThreadNormalWorld())
-        return;
-
-    // FIXME: Is there a way to get this and know that it's a JSGlobalContextRef?
-    // The const_cast here is a bit ugly.
-    JSGlobalContextRef context = const_cast<JSGlobalContextRef>(toRef(m_frame->coreFrame()->script()->globalObject(world)->globalExec()));
-    JSObjectRef windowObject = toRef(m_frame->coreFrame()->script()->globalObject(world));
-
-    webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, context, windowObject);
+    webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world);
 }
 
 void WebFrameLoaderClient::documentElementAvailable()
index eea96c8..eba5a70 100644 (file)
@@ -1,3 +1,18 @@
+2010-09-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Indicate which one of the ScriptWorlds for a Frame the Window Object has been cleared for
+        https://bugs.webkit.org/show_bug.cgi?id=45217
+        
+        Make WebKitTestRunner work with this change.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::didClearWindowForFrame):
+        Make sure the ScriptWorld here is the normal world, since that is no longer being done in
+        WebFrameLoaderClient.
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
+
 2010-09-07  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, build fix.
index c7f9a84..bf7a029 100644 (file)
@@ -35,6 +35,7 @@
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKRetainPtr.h>
 #include <WebKit2/WKBundleRange.h>
+#include <WebKit2/WKBundleScriptWorld.h>
 
 using namespace std;
 
@@ -198,9 +199,9 @@ void InjectedBundlePage::didReceiveTitleForFrame(WKBundlePageRef page, WKStringR
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReceiveTitleForFrame(title, frame);
 }
 
-void InjectedBundlePage::didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window, const void *clientInfo)
+void InjectedBundlePage::didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo)
 {
-    static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didClearWindowForFrame(frame, context, window);
+    static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didClearWindowForFrame(frame, world);
 }
 
 void InjectedBundlePage::didCancelClientRedirectForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo)
@@ -412,11 +413,17 @@ void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFram
     InjectedBundle::shared().os() << "TITLE CHANGED: " << title << "\n";
 }
 
-void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window)
+void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
 {
     if (!InjectedBundle::shared().isTestRunning())
         return;
 
+    if (WKBundleScriptWorldNormalWorld() != world)
+        return;
+
+    JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world);
+    JSObjectRef window = JSContextGetGlobalObject(context);
+
     JSValueRef exception = 0;
     InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception);
     InjectedBundle::shared().gcController()->makeWindowObject(context, window, &exception);
index 3f63bf3..cde1655 100644 (file)
@@ -52,7 +52,7 @@ private:
     static void didFinishLoadForFrame(WKBundlePageRef, WKBundleFrameRef, const void*);
     static void didFailLoadWithErrorForFrame(WKBundlePageRef, WKBundleFrameRef, const void*);
     static void didReceiveTitleForFrame(WKBundlePageRef, WKStringRef title, WKBundleFrameRef, const void*);
-    static void didClearWindowForFrame(WKBundlePageRef, WKBundleFrameRef, JSGlobalContextRef, JSObjectRef window, const void*);
+    static void didClearWindowForFrame(WKBundlePageRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void*);
     static void didCancelClientRedirectForFrame(WKBundlePageRef, WKBundleFrameRef, const void*);
     static void willPerformClientRedirectForFrame(WKBundlePageRef, WKBundleFrameRef, WKURLRef url, double delay, double date, const void*);
     static void didChangeLocationWithinPageForFrame(WKBundlePageRef, WKBundleFrameRef, const void*);
@@ -67,7 +67,7 @@ private:
     void didFinishLoadForFrame(WKBundleFrameRef);
     void didFailLoadWithErrorForFrame(WKBundleFrameRef);
     void didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef);
-    void didClearWindowForFrame(WKBundleFrameRef, JSGlobalContextRef, JSObjectRef window);
+    void didClearWindowForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
     void didCancelClientRedirectForFrame(WKBundleFrameRef);
     void willPerformClientRedirectForFrame(WKBundleFrameRef, WKURLRef url, double delay, double date);
     void didChangeLocationWithinPageForFrame(WKBundleFrameRef);