[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

aroben at apple.com aroben at apple.com
Wed Apr 7 23:40:43 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 11dd5265c3c8b645d042f190171ec3aea31905d6
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 13 23:49:05 2009 +0000

    Tell the WebFrameLoadDelegate when window objects in isolated worlds are cleared
    
    Fixes <http://webkit.org/b/31124>.
    
    Reviewed by Dave Hyatt.
    
    WebCore:
    
    Tell FrameLoaderClient when window objects in isolated worlds are
    cleared
    
    Test: http/tests/security/isolatedWorld/didClearWindowObject.html
    
    * bindings/js/JSDOMBinding.h:
    (WebCore::WebCoreJSClientData::getAllWorlds): Added. Copies all the
    worlds in m_worldSet to the passed-in Vector.
    
    * bindings/js/ScriptController.cpp:
    (WebCore::ScriptController::getAllWorlds): Added. Calls through to
    WebCoreJSClientData.
    (WebCore::ScriptController::initScript): Changed to call
    FrameLoader::dispatchDidClearWindowObjectInWorld.
    
    * bindings/js/ScriptController.h: Added getAllWorlds.
    
    * loader/EmptyClients.h:
    (WebCore::EmptyFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
    Updated for FrameLoaderClient change.
    
    * loader/FrameLoader.cpp:
    (WebCore::FrameLoader::receivedFirstData):
    (WebCore::FrameLoader::begin):
    Changed to call dispatchDidClearWindowObjectsInAllWorlds.
    
    (WebCore::FrameLoader::dispatchDidClearWindowObjectsInAllWorlds):
    Added. Retrieves all the worlds, then calls through to
    dispatchDidClearWindowObjectInWorld for each one.
    (WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld): Replaces
    dispatchWindowObjectAvailable. Calls up to the client, then, if the
    world is the mainThreadNormalWorld(), tells the Inspector about it,
    too.
    
    * loader/FrameLoader.h: Replaced dispatchWindowObjectAvailable with
    dispatchDidClearWindowObjectInWorld. Added
    dispatchDidClearWindowObjectsInAllWorlds.
    
    * loader/FrameLoaderClient.h: Replaced windowObjectCleared with
    dispatchDidClearWindowObjectForWorld.
    
    WebKit:
    
    Add WebFrameLoadDelegatePrivat.h to WebKit.xcodeproj
    
    * WebKit.xcodeproj/project.pbxproj: Added
    WebFrameLoadDelegatePrivate.h, which already existed.
    
    WebKit/gtk:
    
    Update for changes to FrameLoaderClient
    
    * WebCoreSupport/FrameLoaderClientGtk.cpp:
    (WebKit::FrameLoaderClient::dispatchDidClearWindowObjectInWorld):
    * WebCoreSupport/FrameLoaderClientGtk.h:
    Replaced windowObjectCleared with this function. Does nothing if the
    passed-in world is not the mainThreadNormalWorld().
    
    WebKit/haiku:
    
    Update for changes to FrameLoaderClient
    
    * WebCoreSupport/FrameLoaderClientHaiku.cpp:
    (WebCore::FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld):
    * WebCoreSupport/FrameLoaderClientHaiku.h:
    Replaced windowObjectCleared with this function. Does nothing if the
    passed-in world is not the mainThreadNormalWorld().
    
    WebKit/mac:
    
    * WebCoreSupport/WebFrameLoaderClient.h:
    * WebCoreSupport/WebFrameLoaderClient.mm:
    (WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
    Replaced windowObjectCleared with this function. If the delegate
    implements it, call
    -webView:didClearWindowObjectForFrame:inScriptWorld:. Otherwise, if
    the passed-in world is the mainThreadNormalWorld(), call
    -webView:didClearWindowObject:forFrame:.
    
    * WebView/WebDelegateImplementationCaching.h: Added a new entry in the
    frame load delegate implementation cache for the new delegate method.
    
    * WebView/WebFrameLoadDelegatePrivate.h:
    * WebView/WebScriptWorld.mm:
    (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in
    existence.
    (-[WebScriptWorld initWithWorld:]): Add ourselves to allWorlds().
    (-[WebScriptWorld dealloc]): Remove ourselves from allWorlds().
    (+[WebScriptWorld findOrCreateWorld:]): Returns the existing
    WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't
    already exist.
    
    * WebView/WebScriptWorldInternal.h: Declared +findOrCreateWorld:.
    
    * WebView/WebView.mm:
    (-[WebView _cacheFrameLoadDelegateImplementations]): Cache the
    implementation of the new frame load delegate method.
    
    WebKit/qt:
    
    Update for changes to FrameLoaderClient
    
    * WebCoreSupport/FrameLoaderClientQt.cpp:
    (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld):
    * WebCoreSupport/FrameLoaderClientQt.h:
    Replaced windowObjectCleared with this function. Does nothing if the
    passed-in world is not the mainThreadNormalWorld().
    
    WebKit/win:
    
    * Interfaces/IWebFrameLoadDelegatePrivate2.idl: Added
    didClearWindowObjectForFrameInScriptWorld.
    
    * WebFrame.cpp:
    (WebFrame::dispatchDidClearWindowObjectInWorld):
    * WebFrame.h:
    Replaced windowObjectCleared with this function. If the delegate
    implements IWebFrameLoadDelegatePrivate2, call
    didClearWindowObjectForFrameInScriptWorld. Otherwise, if the passed-in
    world is the mainThreadNormalWorld(), call
    didClearWindowObjectForFrame.
    
    * WebScriptWorld.cpp:
    (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in
    existence.
    (WebScriptWorld::WebScriptWorld): Add ourselves to allWorlds().
    (WebScriptWorld::~WebScriptWorld): Remove ourselves from allWorlds().
    (WebScriptWorld::standardWorld): Added this non-COM getter for the
    standard world, which the COM getter now calls through to.
    (WebScriptWorld::findOrCreateWorld): Added. Returns the existing
    WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't
    already exist.
    
    * WebScriptWorld.h: Added new standardWorld overload, made one
    overload of createInstance private, and added findOrCreateWorld.
    
    WebKit/wx:
    
    Update for changes to FrameLoaderClient
    
    * WebKitSupport/FrameLoaderClientWx.cpp:
    (WebCore::FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld):
    * WebKitSupport/FrameLoaderClientWx.h:
    Replaced windowObjectCleared with this function. Does nothing if the
    passed-in world is not the mainThreadNormalWorld().
    
    WebKitTools:
    
    Add support for
    http/tests/security/isolatedWorld/didClearWindowObject.html
    
    * DumpRenderTree/mac/DumpRenderTreeMac.h: Declared worldIDForWorld.
    
    * DumpRenderTree/mac/FrameLoadDelegate.mm:
    (-[FrameLoadDelegate didClearWindowObjectInStandardWorldForFrame:]):
    Added. Moved code here from -webView:didClearWindowObject:forFrame:.
    (-[FrameLoadDelegate didClearWindowObjectForFrame:inIsolatedWorld:]):
    Added. Sets a __worldID property on the global object whose value is
    the ID of this world.
    (-[FrameLoadDelegate webView:didClearWindowObjectForFrame:inScriptWorld:]):
    Respond to this new delegate callback by calling through to one of the
    above new methods.
    * DumpRenderTree/mac/LayoutTestControllerMac.mm:
    (worldMap): Added. Returns a HashMap containing all the worlds we've
    created.
    (worldIDForWorld): Added. Returns the ID for this world, or 0 if we
    haven't kept track of this world.
    (LayoutTestController::evaluateScriptInIsolatedWorld): Use worldMap()
    instead of declaring our own.
    
    * DumpRenderTree/win/DumpRenderTreeWin.h: Declared worldIDForWorld.
    
    * DumpRenderTree/win/FrameLoadDelegate.cpp:
    (FrameLoadDelegate::didClearWindowObject): Moved code from hear to
    didClearWindowObjectForFrameInStandardWorld.
    (FrameLoadDelegate::didClearWindowObjectForFrameInScriptWorld):
    Respond to this new delegate callback by calling through to one of the
    below new methods.
    (FrameLoadDelegate::didClearWindowObjectForFrameInIsolatedWorld):
    Added. Sets a __worldID property on the gobal object whose value is
    the ID of this world.
    (FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld):
    Added. Moved code here from didClearWindowObject.
    
    * DumpRenderTree/win/FrameLoadDelegate.h: Added the
    didClearWindowObjectForFrame* functions.
    
    * DumpRenderTree/win/LayoutTestControllerWin.cpp:
    (worldMap): Added. Returns a HashMap containing all the worlds we've
    created.
    (worldIDForWorld): Added. Returns the ID of this world, or 0 if we
    haven't kept track of this world.
    (LayoutTestController::evaluateScriptInIsolatedWorld): Use worldMap()
    instead of declaring our own.
    
    LayoutTests:
    
    Test that delegates can modify global objects in isolated worlds
    
    * http/tests/security/isolatedWorld/didClearWindowObject-expected.txt: Added.
    * http/tests/security/isolatedWorld/didClearWindowObject.html: Added.
    Tests that the global object in the normal world does not have a
    __worldID property, and that the global object in isolated worlds has
    a __worldID property whose value is equal to the world's ID.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50973 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f6a021e..2b16d68 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-04  Adam Roben  <aroben at apple.com>
+
+        Test that delegates can modify global objects in isolated worlds
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * http/tests/security/isolatedWorld/didClearWindowObject-expected.txt: Added.
+        * http/tests/security/isolatedWorld/didClearWindowObject.html: Added.
+        Tests that the global object in the normal world does not have a
+        __worldID property, and that the global object in isolated worlds has
+        a __worldID property whose value is equal to the world's ID.
+
 2009-11-13  Dumitru Daniliuc  <dumi at chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/http/tests/security/isolatedWorld/didClearWindowObject-expected.txt b/LayoutTests/http/tests/security/isolatedWorld/didClearWindowObject-expected.txt
new file mode 100644
index 0000000..c3da268
--- /dev/null
+++ b/LayoutTests/http/tests/security/isolatedWorld/didClearWindowObject-expected.txt
@@ -0,0 +1,2 @@
+PASS: __worldID is undefined in normal world.
+PASS: __worldID in isolated world should be 1 and is.
diff --git a/LayoutTests/http/tests/security/isolatedWorld/didClearWindowObject.html b/LayoutTests/http/tests/security/isolatedWorld/didClearWindowObject.html
new file mode 100644
index 0000000..60a508f
--- /dev/null
+++ b/LayoutTests/http/tests/security/isolatedWorld/didClearWindowObject.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="console"></div>
+<script>
+var message;
+if ("__worldID" in window)
+    message = "FAIL: __worldID in normal world is " + __worldID + ".";
+else
+    message = "PASS: __worldID is undefined in normal world.";
+var pre = document.createElement("pre");
+pre.appendChild(document.createTextNode(message));
+document.getElementById("console").appendChild(pre);
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    var worldID = 1;
+    layoutTestController.evaluateScriptInIsolatedWorld(
+        worldID,
+        '\
+            var message; \
+            if (!("__worldID" in window)) \
+                message = "FAIL: __worldID is undefined in isolated world ' + worldID + '."; \
+            else if (__worldID != ' + worldID + ') \
+                message = "FAIL: __worldID in isolated world is " + __worldID + " but should be ' + worldID + '."; \
+            else \
+                message = "PASS: __worldID in isolated world should be ' + worldID + ' and is."; \
+            var pre = document.createElement("pre"); \
+            pre.appendChild(document.createTextNode(message)); \
+            document.getElementById("console").appendChild(pre); \
+        ');
+}
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 67ec6d7..34c167b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,51 @@
+2009-11-13  Adam Roben  <aroben at apple.com>
+
+        Tell FrameLoaderClient when window objects in isolated worlds are
+        cleared
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Test: http/tests/security/isolatedWorld/didClearWindowObject.html
+
+        Reviewed by Dave Hyatt.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::WebCoreJSClientData::getAllWorlds): Added. Copies all the
+        worlds in m_worldSet to the passed-in Vector.
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::getAllWorlds): Added. Calls through to
+        WebCoreJSClientData.
+        (WebCore::ScriptController::initScript): Changed to call
+        FrameLoader::dispatchDidClearWindowObjectInWorld.
+
+        * bindings/js/ScriptController.h: Added getAllWorlds.
+
+        * loader/EmptyClients.h:
+        (WebCore::EmptyFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+        Updated for FrameLoaderClient change.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::receivedFirstData):
+        (WebCore::FrameLoader::begin):
+        Changed to call dispatchDidClearWindowObjectsInAllWorlds.
+
+        (WebCore::FrameLoader::dispatchDidClearWindowObjectsInAllWorlds):
+        Added. Retrieves all the worlds, then calls through to
+        dispatchDidClearWindowObjectInWorld for each one.
+        (WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld): Replaces
+        dispatchWindowObjectAvailable. Calls up to the client, then, if the
+        world is the mainThreadNormalWorld(), tells the Inspector about it,
+        too.
+
+        * loader/FrameLoader.h: Replaced dispatchWindowObjectAvailable with
+        dispatchDidClearWindowObjectInWorld. Added
+        dispatchDidClearWindowObjectsInAllWorlds.
+
+        * loader/FrameLoaderClient.h: Replaced windowObjectCleared with
+        dispatchDidClearWindowObjectForWorld.
+
 2009-11-13  Vitaly Repeshko  <vitalyr at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 4e78c4c..f0181e9 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -197,6 +197,11 @@ namespace WebCore {
         DOMWrapperWorld* currentWorld() { return m_worldStack.last(); }
         DOMWrapperWorld* normalWorld() { return &m_normalWorld; }
 
+        void getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
+        {
+            copyToVector(m_worldSet, worlds);
+        }
+
         void rememberWorld(DOMWrapperWorld* world)
         {
             ASSERT(!m_worldSet.contains(world));
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp
index c5f17d9..61dfdd7 100644
--- a/WebCore/bindings/js/ScriptController.cpp
+++ b/WebCore/bindings/js/ScriptController.cpp
@@ -45,6 +45,7 @@
 #include <runtime/JSLock.h>
 
 using namespace JSC;
+using namespace std;
 
 namespace WebCore {
 
@@ -170,6 +171,11 @@ PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()
     return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
 }
 
+void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
+{
+    static_cast<WebCoreJSClientData*>(JSDOMWindow::commonJSGlobalData()->clientData)->getAllWorlds(worlds);
+}
+
 void ScriptController::clearWindowShell()
 {
     if (m_windowShells.isEmpty())
@@ -216,7 +222,7 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
 
     {
         EnterDOMWrapperWorld worldEntry(*JSDOMWindow::commonJSGlobalData(), world);
-        m_frame->loader()->dispatchWindowObjectAvailable();
+        m_frame->loader()->dispatchDidClearWindowObjectInWorld(world);
     }
 
     return windowShell;
diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h
index fc6b553..8801622 100644
--- a/WebCore/bindings/js/ScriptController.h
+++ b/WebCore/bindings/js/ScriptController.h
@@ -87,6 +87,8 @@ public:
         return windowShell(world)->window();
     }
 
+    static void getAllWorlds(Vector<DOMWrapperWorld*>&);
+
     ScriptValue executeScript(const ScriptSourceCode&);
     ScriptValue executeScript(const String& script, bool forceUserGesture = false);
     ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h
index 35f8647..da529e3 100644
--- a/WebCore/loader/EmptyClients.h
+++ b/WebCore/loader/EmptyClients.h
@@ -293,7 +293,7 @@ public:
     virtual String overrideMediaType() const { return String(); }
 
     virtual void redirectDataToPlugin(Widget*) { }
-    virtual void windowObjectCleared() { }
+    virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) { }
     virtual void documentElementAvailable() { }
     virtual void didPerformFirstNavigation() const { }
 
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 45d4c76..dc1e1aa 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -740,7 +740,7 @@ void FrameLoader::receivedFirstData()
     begin(m_workingURL, false);
 
     dispatchDidCommitLoad();
-    dispatchWindowObjectAvailable();
+    dispatchDidClearWindowObjectsInAllWorlds();
     
     if (m_documentLoader) {
         String ptitle = m_documentLoader->title();
@@ -829,7 +829,7 @@ void FrameLoader::begin(const KURL& url, bool dispatch, SecurityOrigin* origin)
     m_frame->domWindow()->setSecurityOrigin(document->securityOrigin());
 
     if (dispatch)
-        dispatchWindowObjectAvailable();
+        dispatchDidClearWindowObjectsInAllWorlds();
     
     updateFirstPartyForCookies();
 
@@ -3868,15 +3868,28 @@ void FrameLoader::dispatchDocumentElementAvailable()
     m_client->documentElementAvailable();
 }
 
-void FrameLoader::dispatchWindowObjectAvailable()
+void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
 {
-    // FIXME: should this be isolated-worlds-aware?
-    if (!m_frame->script()->isEnabled() || !m_frame->script()->existingWindowShell(mainThreadNormalWorld()))
+    if (!m_frame->script()->isEnabled())
         return;
 
-    m_client->windowObjectCleared();
+    Vector<DOMWrapperWorld*> worlds;
+    ScriptController::getAllWorlds(worlds);
+    for (size_t i = 0; i < worlds.size(); ++i)
+        dispatchDidClearWindowObjectInWorld(worlds[i]);
+}
+
+void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
+{
+    if (!m_frame->script()->isEnabled() || !m_frame->script()->existingWindowShell(world))
+        return;
+
+    m_client->dispatchDidClearWindowObjectInWorld(world);
 
 #if ENABLE(INSPECTOR)
+    if (world != mainThreadNormalWorld())
+        return;
+
     if (Page* page = m_frame->page()) {
         if (InspectorController* inspector = page->inspectorController())
             inspector->inspectedWindowScriptObjectCleared(m_frame);
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index 3bf6196..0059903 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -50,6 +50,7 @@ class AuthenticationChallenge;
 class CachedFrameBase;
 class CachedPage;
 class CachedResource;
+class DOMWrapperWorld;
 class Document;
 class DocumentLoader;
 class Event;
@@ -246,7 +247,7 @@ public:
 
     PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const HashMap<String, String>& args);
 
-    void dispatchWindowObjectAvailable();
+    void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
     void dispatchDocumentElementAvailable();
 
     // Mixed content related functions.
@@ -394,6 +395,7 @@ private:
     bool shouldReloadToHandleUnreachableURL(DocumentLoader*);
 
     void dispatchDidCommitLoad();
+    void dispatchDidClearWindowObjectsInAllWorlds();
 
     void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
     void load(DocumentLoader*);                                                         // Calls loadWithDocumentLoader   
diff --git a/WebCore/loader/FrameLoaderClient.h b/WebCore/loader/FrameLoaderClient.h
index 81c726a..a42147b 100644
--- a/WebCore/loader/FrameLoaderClient.h
+++ b/WebCore/loader/FrameLoaderClient.h
@@ -47,6 +47,7 @@ namespace WebCore {
     class AuthenticationChallenge;
     class CachedFrame;
     class Color;
+    class DOMWrapperWorld;
     class DocumentLoader;
     class Element;
     class FormState;
@@ -222,7 +223,7 @@ namespace WebCore {
         virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) = 0;
         virtual String overrideMediaType() const = 0;
 
-        virtual void windowObjectCleared() = 0;
+        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) = 0;
         virtual void documentElementAvailable() = 0;
         virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
 
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 242d44e..0ff88ba 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,15 @@
+2009-11-13  Adam Roben  <aroben at apple.com>
+
+        Add WebFrameLoadDelegatePrivat.h to WebKit.xcodeproj
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * WebKit.xcodeproj/project.pbxproj: Added
+        WebFrameLoadDelegatePrivate.h, which already existed.
+
 2009-11-12  Adam Roben  <aroben at apple.com>
 
         Replace worldIDs with world objects
diff --git a/WebKit/WebKit.xcodeproj/project.pbxproj b/WebKit/WebKit.xcodeproj/project.pbxproj
index a36ea6c..2af9d27 100644
--- a/WebKit/WebKit.xcodeproj/project.pbxproj
+++ b/WebKit/WebKit.xcodeproj/project.pbxproj
@@ -336,6 +336,7 @@
 		C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */; };
 		C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */; };
+		C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; };
 		DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; };
 		DD89682109AA87240097E7F0 /* WebElementDictionary.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */; };
@@ -627,6 +628,7 @@
 		C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorld.h; sourceTree = "<group>"; };
 		C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptWorld.mm; sourceTree = "<group>"; };
 		C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorldInternal.h; sourceTree = "<group>"; };
+		C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFrameLoadDelegatePrivate.h; sourceTree = "<group>"; };
 		DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTypesInternal.h; sourceTree = "<group>"; };
 		DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		DD89681F09AA87240097E7F0 /* WebElementDictionary.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebElementDictionary.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -1109,6 +1111,7 @@
 				F5143A370221DCCE01A80181 /* WebFrame.mm */,
 				930D02BD06275F710076701E /* WebFrameInternal.h */,
 				5152FAE5033FC52200CA2ACD /* WebFrameLoadDelegate.h */,
+				C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */,
 				9CF0E249021361B00ECA16EA /* WebFramePrivate.h */,
 				51A8B52E04282B5900CA2D3A /* WebFrameView.h */,
 				51A8B52F04282B5900CA2D3A /* WebFrameView.mm */,
@@ -1524,6 +1527,7 @@
 				0A2D87FD107AF52B00CDDEE3 /* WebPluginHalterClient.h in Headers */,
 				C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
 				C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */,
+				C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 7ae2797..9c8dbdd 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-13  Adam Roben  <aroben at apple.com>
+
+        Update for changes to FrameLoaderClient
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        (WebKit::FrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+        * WebCoreSupport/FrameLoaderClientGtk.h:
+        Replaced windowObjectCleared with this function. Does nothing if the
+        passed-in world is not the mainThreadNormalWorld().
+
 2009-11-12  Shinichiro Hamaji  <hamaji at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index f76729d..bac2aba 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -500,8 +500,11 @@ String FrameLoaderClient::overrideMediaType() const
     return String();
 }
 
-void FrameLoaderClient::windowObjectCleared()
+void FrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
+    if (world != mainThreadNormalWorld())
+        return;
+
     // Is this obsolete now?
     g_signal_emit_by_name(m_frame, "cleared");
 
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
index c820135..66f478a 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
@@ -114,7 +114,7 @@ namespace WebKit {
         virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
         virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const WTF::Vector<WebCore::String>& paramNames, const WTF::Vector<WebCore::String>& paramValues);
         virtual WebCore::String overrideMediaType() const;
-        virtual void windowObjectCleared();
+        virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
         virtual void documentElementAvailable();
         virtual void didPerformFirstNavigation() const;
 
diff --git a/WebKit/haiku/ChangeLog b/WebKit/haiku/ChangeLog
index 0be5b8e..57da91e 100644
--- a/WebKit/haiku/ChangeLog
+++ b/WebKit/haiku/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-13  Adam Roben  <aroben at apple.com>
+
+        Update for changes to FrameLoaderClient
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * WebCoreSupport/FrameLoaderClientHaiku.cpp:
+        (WebCore::FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld):
+        * WebCoreSupport/FrameLoaderClientHaiku.h:
+        Replaced windowObjectCleared with this function. Does nothing if the
+        passed-in world is not the mainThreadNormalWorld().
+
 2009-10-30  Evan Stade  <estade at chromium.org>
 
         Reviewed by David Levin.
diff --git a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
index a8ba16f..02882a0 100644
--- a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
+++ b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
@@ -42,6 +42,7 @@
 #include "Page.h"
 #include "PlatformString.h"
 #include "ResourceRequest.h"
+#include "ScriptController.h"
 #include "WebView.h"
 
 #include <Message.h>
@@ -759,8 +760,11 @@ String FrameLoaderClientHaiku::overrideMediaType() const
     return String();
 }
 
-void FrameLoaderClientHaiku::windowObjectCleared()
+void FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
+    if (world != mainThreadNormalWorld())
+        return;
+
     if (m_webView) {
         BMessage message(JAVASCRIPT_WINDOW_OBJECT_CLEARED);
         m_messenger->SendMessage(&message);
diff --git a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
index 33af321..1c3e2a1 100644
--- a/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
+++ b/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
@@ -228,7 +228,7 @@ namespace WebCore {
         virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType);
         virtual String overrideMediaType() const;
 
-        virtual void windowObjectCleared();
+        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
         virtual void documentElementAvailable();
 
         virtual void didPerformFirstNavigation() const;
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index a8d4068..d0623a7 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,5 +1,42 @@
 2009-11-13  Adam Roben  <aroben at apple.com>
 
+        Tell the WebFrameLoadDelegate when window objects in isolated worlds
+        are cleared
+
+        Fixes <http://webkit.org/b/31124>.
+
+        Reviewed by Dave Hyatt.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+        Replaced windowObjectCleared with this function. If the delegate
+        implements it, call
+        -webView:didClearWindowObjectForFrame:inScriptWorld:. Otherwise, if
+        the passed-in world is the mainThreadNormalWorld(), call
+        -webView:didClearWindowObject:forFrame:.
+
+        * WebView/WebDelegateImplementationCaching.h: Added a new entry in the
+        frame load delegate implementation cache for the new delegate method.
+
+        * WebView/WebFrameLoadDelegatePrivate.h:
+        * WebView/WebScriptWorld.mm:
+        (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in
+        existence.
+        (-[WebScriptWorld initWithWorld:]): Add ourselves to allWorlds().
+        (-[WebScriptWorld dealloc]): Remove ourselves from allWorlds().
+        (+[WebScriptWorld findOrCreateWorld:]): Returns the existing
+        WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't
+        already exist.
+
+        * WebView/WebScriptWorldInternal.h: Declared +findOrCreateWorld:.
+
+        * WebView/WebView.mm:
+        (-[WebView _cacheFrameLoadDelegateImplementations]): Cache the
+        implementation of the new frame load delegate method.
+
+2009-11-13  Adam Roben  <aroben at apple.com>
+
         Finish replacing worldIDs with world objects
 
         The only remaining use of worldIDs was in a method only used by DRT
diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
index 6d365dd..d69ab73 100644
--- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
+++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
@@ -191,7 +191,7 @@ private:
     virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType);
     virtual WebCore::String overrideMediaType() const;
     
-    virtual void windowObjectCleared();
+    virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
     virtual void documentElementAvailable();
     virtual void didPerformFirstNavigation() const;
 
diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
index bc6c8f4..e93d177 100644
--- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
@@ -69,6 +69,7 @@
 #import "WebPolicyDelegatePrivate.h"
 #import "WebPreferences.h"
 #import "WebResourceLoadDelegate.h"
+#import "WebScriptWorldInternal.h"
 #import "WebSecurityOriginInternal.h"
 #import "WebUIDelegate.h"
 #import "WebUIDelegatePrivate.h"
@@ -128,6 +129,7 @@
 
 using namespace WebCore;
 using namespace HTMLNames;
+using namespace std;
 
 #if ENABLE(MAC_JAVA_BRIDGE)
 @interface NSView (WebJavaPluginDetails)
@@ -1689,12 +1691,23 @@ String WebFrameLoaderClient::overrideMediaType() const
 void WebFrameLoaderClient::documentElementAvailable() {
 }
 
-void WebFrameLoaderClient::windowObjectCleared()
+void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
-    Frame *frame = core(m_webFrame.get());
-    ScriptController *script = frame->script();
     WebView *webView = getWebView(m_webFrame.get());
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
+
+    if (implementations->didClearWindowObjectForFrameInScriptWorldFunc) {
+        CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameInScriptWorldFunc,
+            webView, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:), m_webFrame.get(), [WebScriptWorld findOrCreateWorld:world]);
+        return;
+    }
+
+    if (world != mainThreadNormalWorld())
+        return;
+
+    Frame *frame = core(m_webFrame.get());
+    ScriptController *script = frame->script();
+
     if (implementations->didClearWindowObjectForFrameFunc) {
         CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameFunc, webView, @selector(webView:didClearWindowObject:forFrame:),
             script->windowScriptObject(), m_webFrame.get());
diff --git a/WebKit/mac/WebView/WebDelegateImplementationCaching.h b/WebKit/mac/WebView/WebDelegateImplementationCaching.h
index edf3cad..8f0d145 100644
--- a/WebKit/mac/WebView/WebDelegateImplementationCaching.h
+++ b/WebKit/mac/WebView/WebDelegateImplementationCaching.h
@@ -49,6 +49,7 @@ struct WebResourceDelegateImplementationCache {
 
 struct WebFrameLoadDelegateImplementationCache {
     IMP didClearWindowObjectForFrameFunc;
+    IMP didClearWindowObjectForFrameInScriptWorldFunc;
     IMP didClearInspectorWindowObjectForFrameFunc;
     IMP windowScriptObjectAvailableFunc;
     IMP didHandleOnloadEventsForFrameFunc;
diff --git a/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h b/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h
index 80fa08a..45a4f08 100644
--- a/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h
+++ b/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h
@@ -28,6 +28,7 @@
 
 #import <WebKit/WebFrameLoadDelegate.h>
 
+ at class WebScriptWorld;
 @class WebSecurityOrigin;
 
 @interface NSObject (WebFrameLoadDelegatePrivate)
@@ -36,4 +37,6 @@
 
 - (void)webView:(WebView *)webView didRunInsecureContent:(WebSecurityOrigin *)origin;
 
+- (void)webView:(WebView *)webView didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world;
+
 @end
diff --git a/WebKit/mac/WebView/WebScriptWorld.mm b/WebKit/mac/WebView/WebScriptWorld.mm
index 8e954cd..0310701 100644
--- a/WebKit/mac/WebView/WebScriptWorld.mm
+++ b/WebKit/mac/WebView/WebScriptWorld.mm
@@ -40,6 +40,13 @@ using namespace WebCore;
 @implementation WebScriptWorldPrivate
 @end
 
+typedef HashMap<DOMWrapperWorld*, WebScriptWorld*> WorldMap;
+static WorldMap& allWorlds()
+{
+    static WorldMap& map = *new WorldMap;
+    return map;
+}
+
 @implementation WebScriptWorld
 
 - (id)initWithWorld:(PassRefPtr<DOMWrapperWorld>)world
@@ -55,6 +62,9 @@ using namespace WebCore;
     _private = [[WebScriptWorldPrivate alloc] init];
     _private->world = world;
 
+    ASSERT_ARG(world, !allWorlds().contains(_private->world.get()));
+    allWorlds().add(_private->world.get(), self);
+
     return self;
 }
 
@@ -65,6 +75,9 @@ using namespace WebCore;
 
 - (void)dealloc
 {
+    ASSERT(allWorlds().contains(_private->world.get()));
+    allWorlds().remove(_private->world.get());
+
     [_private release];
     _private = nil;
     [super dealloc];
@@ -81,9 +94,26 @@ using namespace WebCore;
     return [[[self alloc] init] autorelease];
 }
 
+ at end
+
+ at implementation WebScriptWorld (WebInternal)
+
 DOMWrapperWorld* core(WebScriptWorld *world)
 {
     return world ? world->_private->world.get() : 0;
 }
 
++ (WebScriptWorld *)findOrCreateWorld:(DOMWrapperWorld*) world
+{
+    ASSERT_ARG(world, world);
+
+    if (world == mainThreadNormalWorld())
+        return [self standardWorld];
+
+    if (WebScriptWorld *existingWorld = allWorlds().get(world))
+        return existingWorld;
+
+    return [[[self alloc] initWithWorld:world] autorelease];
+}
+
 @end
diff --git a/WebKit/mac/WebView/WebScriptWorldInternal.h b/WebKit/mac/WebView/WebScriptWorldInternal.h
index bff808e..785d9c0 100644
--- a/WebKit/mac/WebView/WebScriptWorldInternal.h
+++ b/WebKit/mac/WebView/WebScriptWorldInternal.h
@@ -29,3 +29,7 @@ namespace WebCore {
 }
 
 WebCore::DOMWrapperWorld* core(WebScriptWorld *);
+
+ at interface WebScriptWorld (WebInternal)
++ (WebScriptWorld *)findOrCreateWorld:(WebCore::DOMWrapperWorld*)world;
+ at end
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 27186bd..36f6d03 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -1349,6 +1349,7 @@ static inline IMP getMethod(id o, SEL s)
     cache->didCancelClientRedirectForFrameFunc = getMethod(delegate, @selector(webView:didCancelClientRedirectForFrame:));
     cache->didChangeLocationWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didChangeLocationWithinPageForFrame:));
     cache->didClearWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearWindowObject:forFrame:));
+    cache->didClearWindowObjectForFrameInScriptWorldFunc = getMethod(delegate, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:));
     cache->didClearInspectorWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearInspectorWindowObject:forFrame:));
     cache->didCommitLoadForFrameFunc = getMethod(delegate, @selector(webView:didCommitLoadForFrame:));
     cache->didFailLoadWithErrorForFrameFunc = getMethod(delegate, @selector(webView:didFailLoadWithError:forFrame:));
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index f811879..d64ceda 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-13  Adam Roben  <aroben at apple.com>
+
+        Update for changes to FrameLoaderClient
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld):
+        * WebCoreSupport/FrameLoaderClientQt.h:
+        Replaced windowObjectCleared with this function. Does nothing if the
+        passed-in world is not the mainThreadNormalWorld().
+
 2009-11-13  Andras Becsi  <becsi.andras at stud.u-szeged.hu>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index d9396e9..77eee7b 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -53,8 +53,9 @@
 #include "QNetworkReplyHandler.h"
 #include "ResourceHandleInternal.h"
 #include "ResourceHandle.h"
-#include "Settings.h"
+#include "ScriptController.h"
 #include "ScriptString.h"
+#include "Settings.h"
 #include "QWebPageClient.h"
 
 #include "qwebpage.h"
@@ -600,8 +601,11 @@ bool FrameLoaderClientQt::canHandleRequest(const WebCore::ResourceRequest&) cons
     return true;
 }
 
-void FrameLoaderClientQt::windowObjectCleared()
+void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
+    if (world != mainThreadNormalWorld())
+        return;
+
     if (dumpFrameLoaderCallbacks)
         printf("%s - didClearWindowObjectForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
 
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index 66c4252..e49f849 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -197,7 +197,7 @@ namespace WebCore {
         virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType);
         virtual String overrideMediaType() const;
 
-        virtual void windowObjectCleared();
+        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
         virtual void documentElementAvailable();
         virtual void didPerformFirstNavigation() const;
 
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index f25d0af..9aab65e 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,5 +1,40 @@
 2009-11-13  Adam Roben  <aroben at apple.com>
 
+        Tell the WebFrameLoadDelegate when window objects in isolated worlds
+        are cleared
+
+        Fixes <http://webkit.org/b/31124>.
+
+        Reviewed by Dave Hyatt.
+
+        * Interfaces/IWebFrameLoadDelegatePrivate2.idl: Added
+        didClearWindowObjectForFrameInScriptWorld.
+
+        * WebFrame.cpp:
+        (WebFrame::dispatchDidClearWindowObjectInWorld):
+        * WebFrame.h:
+        Replaced windowObjectCleared with this function. If the delegate
+        implements IWebFrameLoadDelegatePrivate2, call
+        didClearWindowObjectForFrameInScriptWorld. Otherwise, if the passed-in
+        world is the mainThreadNormalWorld(), call
+        didClearWindowObjectForFrame.
+
+        * WebScriptWorld.cpp:
+        (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in
+        existence.
+        (WebScriptWorld::WebScriptWorld): Add ourselves to allWorlds().
+        (WebScriptWorld::~WebScriptWorld): Remove ourselves from allWorlds().
+        (WebScriptWorld::standardWorld): Added this non-COM getter for the
+        standard world, which the COM getter now calls through to.
+        (WebScriptWorld::findOrCreateWorld): Added. Returns the existing
+        WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't
+        already exist.
+
+        * WebScriptWorld.h: Added new standardWorld overload, made one
+        overload of createInstance private, and added findOrCreateWorld.
+
+2009-11-13  Adam Roben  <aroben at apple.com>
+
         Build fix
 
         * Interfaces/WebKit.idl: Un-sort the #includes again. Apparently they
diff --git a/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl b/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl
index d646528..a38223c 100644
--- a/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl
+++ b/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl
@@ -31,8 +31,9 @@ import "IWebView.idl";
 #endif
 
 interface IWebFrame;
-interface IWebView;
+interface IWebScriptWorld;
 interface IWebSecurityOrigin;
+interface IWebView;
 
 [
     object,
@@ -45,4 +46,6 @@ interface IWebFrameLoadDelegatePrivate2 : IWebFrameLoadDelegatePrivate
     HRESULT didDisplayInsecureContent([in] IWebView* sender);
 
     HRESULT didRunInsecureContent([in] IWebView* sender, [in] IWebSecurityOrigin* origin);
+
+    HRESULT didClearWindowObjectForFrameInScriptWorld([in] IWebView* webView, [in] IWebFrame* frame, [in] IWebScriptWorld*);
 }
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index 25d7c4c..3c6db59 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -119,6 +119,7 @@ extern "C" {
 
 using namespace WebCore;
 using namespace HTMLNames;
+using namespace std;
 
 using JSC::JSGlobalObject;
 using JSC::JSLock;
@@ -1716,7 +1717,7 @@ String WebFrame::overrideMediaType() const
     return String();
 }
 
-void WebFrame::windowObjectCleared()
+void WebFrame::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
     Frame* coreFrame = core(this);
     ASSERT(coreFrame);
@@ -1726,14 +1727,24 @@ void WebFrame::windowObjectCleared()
         return;
 
     COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
-    if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate))) {
-        JSContextRef context = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
-        JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld()));
-        ASSERT(windowObject);
+    if (FAILED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
+        return;
 
-        if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this)))
-            frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject);
+    COMPtr<IWebFrameLoadDelegatePrivate2> delegatePrivate(Query, frameLoadDelegate);
+    if (delegatePrivate) {
+        delegatePrivate->didClearWindowObjectForFrameInScriptWorld(d->webView, this, WebScriptWorld::findOrCreateWorld(world).get());
+        return;
     }
+
+    if (world != mainThreadNormalWorld())
+        return;
+
+    JSContextRef context = toRef(coreFrame->script()->globalObject(world)->globalExec());
+    JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(world));
+    ASSERT(windowObject);
+
+    if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this)))
+        frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject);
 }
 
 void WebFrame::documentElementAvailable()
diff --git a/WebKit/win/WebFrame.h b/WebKit/win/WebFrame.h
index 103375a..fa7dd4b 100644
--- a/WebKit/win/WebFrame.h
+++ b/WebKit/win/WebFrame.h
@@ -312,7 +312,7 @@ public:
     virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType);
     virtual WebCore::String overrideMediaType() const;
 
-    virtual void windowObjectCleared();
+    virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
     virtual void documentElementAvailable();
     virtual void didPerformFirstNavigation() const;
 
diff --git a/WebKit/win/WebScriptWorld.cpp b/WebKit/win/WebScriptWorld.cpp
index 5f1cffa..03eede7 100644
--- a/WebKit/win/WebScriptWorld.cpp
+++ b/WebKit/win/WebScriptWorld.cpp
@@ -31,22 +31,41 @@
 
 using namespace WebCore;
 
+typedef HashMap<DOMWrapperWorld*, WebScriptWorld*> WorldMap;
+static WorldMap& allWorlds()
+{
+    static WorldMap& map = *new WorldMap;
+    return map;
+}
+
 inline WebScriptWorld::WebScriptWorld(PassRefPtr<DOMWrapperWorld> world)
     : m_refCount(0)
     , m_world(world)
 {
     ASSERT_ARG(world, m_world);
 
+    ASSERT_ARG(world, !allWorlds().contains(m_world.get()));
+    allWorlds().add(m_world.get(), this);
+
     ++gClassCount;
     gClassNameCount.add("WebScriptWorld");
 }
 
 WebScriptWorld::~WebScriptWorld()
 {
+    ASSERT(allWorlds().contains(m_world.get()));
+    allWorlds().remove(m_world.get());
+
     --gClassCount;
     gClassNameCount.remove("WebScriptWorld");
 }
 
+WebScriptWorld* WebScriptWorld::standardWorld()
+{
+    static WebScriptWorld* standardWorld = createInstance(mainThreadNormalWorld()).releaseRef();
+    return standardWorld;
+}
+
 COMPtr<WebScriptWorld> WebScriptWorld::createInstance()
 {
     return createInstance(ScriptController::createWorld());
@@ -57,6 +76,17 @@ COMPtr<WebScriptWorld> WebScriptWorld::createInstance(PassRefPtr<DOMWrapperWorld
     return new WebScriptWorld(world);
 }
 
+COMPtr<WebScriptWorld> WebScriptWorld::findOrCreateWorld(DOMWrapperWorld* world)
+{
+    if (world == mainThreadNormalWorld())
+        return standardWorld();
+
+    if (WebScriptWorld* existingWorld = allWorlds().get(world))
+        return existingWorld;
+
+    return createInstance(world);
+}
+
 ULONG WebScriptWorld::AddRef()
 {
     return ++m_refCount;
@@ -94,9 +124,7 @@ HRESULT WebScriptWorld::standardWorld(IWebScriptWorld** outWorld)
     if (!outWorld)
         return E_POINTER;
 
-    static WebScriptWorld* standardWorld = createInstance(mainThreadNormalWorld()).releaseRef();
-
-    *outWorld = standardWorld;
-    standardWorld->AddRef();
+    *outWorld = standardWorld();
+    (*outWorld)->AddRef();
     return S_OK;
 }
diff --git a/WebKit/win/WebScriptWorld.h b/WebKit/win/WebScriptWorld.h
index b5b288f..b800225 100644
--- a/WebKit/win/WebScriptWorld.h
+++ b/WebKit/win/WebScriptWorld.h
@@ -33,8 +33,10 @@ namespace WebCore {
 
 class WebScriptWorld : public Noncopyable, public IWebScriptWorld {
 public:
+    static WebScriptWorld* standardWorld();
     static COMPtr<WebScriptWorld> createInstance();
-    static COMPtr<WebScriptWorld> createInstance(PassRefPtr<WebCore::DOMWrapperWorld>);
+
+    static COMPtr<WebScriptWorld> findOrCreateWorld(WebCore::DOMWrapperWorld*);
 
     virtual ULONG STDMETHODCALLTYPE AddRef();
     virtual ULONG STDMETHODCALLTYPE Release();
@@ -42,6 +44,8 @@ public:
     WebCore::DOMWrapperWorld* world() const { return m_world.get(); }
 
 private:
+    static COMPtr<WebScriptWorld> createInstance(PassRefPtr<WebCore::DOMWrapperWorld>);
+
     WebScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>);
     ~WebScriptWorld();
 
diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog
index 2e8c284..d05688b 100644
--- a/WebKit/wx/ChangeLog
+++ b/WebKit/wx/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-13  Adam Roben  <aroben at apple.com>
+
+        Update for changes to FrameLoaderClient
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * WebKitSupport/FrameLoaderClientWx.cpp:
+        (WebCore::FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld):
+        * WebKitSupport/FrameLoaderClientWx.h:
+        Replaced windowObjectCleared with this function. Does nothing if the
+        passed-in world is not the mainThreadNormalWorld().
+
 2009-11-10  Robin Dunn  <robin at alldunn.com>
 
         Reviewed by Kevin Ollivier.
diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
index 9d12ca7..7a42560 100644
--- a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
+++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
@@ -831,8 +831,11 @@ String FrameLoaderClientWx::overrideMediaType() const
     return String();
 }
 
-void FrameLoaderClientWx::windowObjectCleared()
+void FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
+    if (world != mainThreadNormalWorld())
+        return;
+
     if (m_webView) {
         wxWebViewWindowObjectClearedEvent wkEvent(m_webView);
         Frame* coreFrame = m_webView->GetMainFrame()->GetFrame();
diff --git a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
index bfa162f..75bca4d 100644
--- a/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
+++ b/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
@@ -202,7 +202,7 @@ namespace WebCore {
         virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType);
         virtual String overrideMediaType() const;
 
-        virtual void windowObjectCleared();
+        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
         virtual void documentElementAvailable();
         
         virtual void didPerformFirstNavigation() const;
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index f94a265..e16a51f 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -18,6 +18,60 @@
 
 2009-11-13  Adam Roben  <aroben at apple.com>
 
+        Add support for
+        http/tests/security/isolatedWorld/didClearWindowObject.html
+
+        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
+        window objects in isolated worlds are cleared
+
+        Reviewed by Dave Hyatt.
+
+        * DumpRenderTree/mac/DumpRenderTreeMac.h: Declared worldIDForWorld.
+
+        * DumpRenderTree/mac/FrameLoadDelegate.mm:
+        (-[FrameLoadDelegate didClearWindowObjectInStandardWorldForFrame:]):
+        Added. Moved code here from -webView:didClearWindowObject:forFrame:.
+        (-[FrameLoadDelegate didClearWindowObjectForFrame:inIsolatedWorld:]):
+        Added. Sets a __worldID property on the global object whose value is
+        the ID of this world.
+        (-[FrameLoadDelegate webView:didClearWindowObjectForFrame:inScriptWorld:]):
+        Respond to this new delegate callback by calling through to one of the
+        above new methods.
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (worldMap): Added. Returns a HashMap containing all the worlds we've
+        created.
+        (worldIDForWorld): Added. Returns the ID for this world, or 0 if we
+        haven't kept track of this world.
+        (LayoutTestController::evaluateScriptInIsolatedWorld): Use worldMap()
+        instead of declaring our own.
+
+        * DumpRenderTree/win/DumpRenderTreeWin.h: Declared worldIDForWorld.
+
+        * DumpRenderTree/win/FrameLoadDelegate.cpp:
+        (FrameLoadDelegate::didClearWindowObject): Moved code from hear to
+        didClearWindowObjectForFrameInStandardWorld.
+        (FrameLoadDelegate::didClearWindowObjectForFrameInScriptWorld):
+        Respond to this new delegate callback by calling through to one of the
+        below new methods.
+        (FrameLoadDelegate::didClearWindowObjectForFrameInIsolatedWorld):
+        Added. Sets a __worldID property on the gobal object whose value is
+        the ID of this world.
+        (FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld):
+        Added. Moved code here from didClearWindowObject.
+
+        * DumpRenderTree/win/FrameLoadDelegate.h: Added the
+        didClearWindowObjectForFrame* functions.
+
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (worldMap): Added. Returns a HashMap containing all the worlds we've
+        created.
+        (worldIDForWorld): Added. Returns the ID of this world, or 0 if we
+        haven't kept track of this world.
+        (LayoutTestController::evaluateScriptInIsolatedWorld): Use worldMap()
+        instead of declaring our own.
+
+2009-11-13  Adam Roben  <aroben at apple.com>
+
         Finish replacing worldIDs with world objects
 
         The only remaining use of worldIDs was in a method only used by DRT
diff --git a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h
index 72d5db1..fe1ac00 100644
--- a/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h
+++ b/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h
@@ -42,6 +42,7 @@
 @class NavigationController;
 @class PolicyDelegate;
 @class WebFrame;
+ at class WebScriptWorld;
 @class WebView;
 
 typedef const struct __CFString* CFStringRef;
@@ -62,4 +63,6 @@ extern CFRunLoopTimerRef waitToDumpWatchdog;
 WebView* createWebViewAndOffscreenWindow();
 void setPersistentUserStyleSheetLocation(CFStringRef);
 
+unsigned worldIDForWorld(WebScriptWorld *);
+
 #endif // DumpRenderTreeMac_h 
diff --git a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
index d8a444a..963eae7 100644
--- a/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
+++ b/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm
@@ -48,6 +48,7 @@
 #import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/WebNSURLExtras.h>
+#import <WebKit/WebScriptWorld.h>
 #import <WebKit/WebSecurityOriginPrivate.h>
 #import <wtf/Assertions.h>
 
@@ -236,11 +237,8 @@
     ASSERT_NOT_REACHED();
 }
 
-- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)obj forFrame:(WebFrame *)frame
+- (void)didClearWindowObjectInStandardWorldForFrame:(WebFrame *)frame
 {
-    ASSERT(obj == [frame windowObject]);
-    ASSERT([obj JSObject] == JSContextGetGlobalObject([frame globalContext]));
-
     // Make New-Style LayoutTestController
     JSContextRef context = [frame globalContext];
     JSObjectRef globalObject = JSContextGetGlobalObject(context);
@@ -258,7 +256,9 @@
 
     // Make Old-Style controllers
 
-    AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender];
+    WebView *webView = [frame webView];
+    WebScriptObject *obj = [frame windowObject];
+    AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:webView];
     [obj setValue:asc forKey:@"appleScriptController"];
     [asc release];
 
@@ -282,11 +282,32 @@
 
     [obj setValue:[PlainTextController sharedPlainTextController] forKey:@"plainText"];
 
-    TextInputController *tic = [[TextInputController alloc] initWithWebView:sender];
+    TextInputController *tic = [[TextInputController alloc] initWithWebView:webView];
     [obj setValue:tic forKey:@"textInputController"];
     [tic release];
 }
 
+- (void)didClearWindowObjectForFrame:(WebFrame *)frame inIsolatedWorld:(WebScriptWorld *)world
+{
+    JSGlobalContextRef ctx = [frame _globalContextForScriptWorld:world];
+    if (!ctx)
+        return;
+
+    JSObjectRef globalObject = JSContextGetGlobalObject(ctx);
+    if (!globalObject)
+        return;
+
+    JSObjectSetProperty(ctx, globalObject, JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
+}
+
+- (void)webView:(WebView *)sender didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world
+{
+    if (world == [WebScriptWorld standardWorld])
+        [self didClearWindowObjectInStandardWorldForFrame:frame];
+    else
+        [self didClearWindowObjectForFrame:frame inIsolatedWorld:world];
+}
+
 - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
 {
     if (!done && gLayoutTestController->dumpFrameLoadCallbacks()) {
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index 59d544b..3345388 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -532,6 +532,24 @@ void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef scrip
     [[[mainFrame webView] inspector] evaluateInFrontend:nil callId:callId script:scriptNS];
 }
 
+typedef HashMap<unsigned, RetainPtr<WebScriptWorld> > WorldMap;
+static WorldMap& worldMap()
+{
+    static WorldMap& map = *new WorldMap;
+    return map;
+}
+
+unsigned worldIDForWorld(WebScriptWorld *world)
+{
+    WorldMap::const_iterator end = worldMap().end();
+    for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) {
+        if (it->second == world)
+            return it->first;
+    }
+
+    return 0;
+}
+
 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
 {
     RetainPtr<CFStringRef> scriptCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, script));
@@ -543,9 +561,7 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObj
     if (!worldID)
         world = [WebScriptWorld world];
     else {
-        typedef HashMap<unsigned, RetainPtr<WebScriptWorld> > WorldMap;
-        static WorldMap& worldMap = *new WorldMap;
-        RetainPtr<WebScriptWorld>& worldSlot = worldMap.add(worldID, 0).first->second;
+        RetainPtr<WebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
         if (!worldSlot)
             worldSlot.adoptNS([[WebScriptWorld alloc] init]);
         world = worldSlot.get();
diff --git a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
index 6eb468d..54ec87b 100644
--- a/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
+++ b/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h
@@ -30,6 +30,7 @@
 #define DumpRenderTreeWin_h
 
 struct IWebFrame;
+struct IWebScriptWorld;
 struct IWebView;
 struct PolicyDelegate;
 typedef const struct __CFString* CFStringRef;
@@ -55,6 +56,8 @@ WindowToWebViewMap& windowToWebViewMap();
 void setPersistentUserStyleSheetLocation(CFStringRef);
 bool setAlwaysAcceptCookies(bool alwaysAcceptCookies);
 
+unsigned worldIDForWorld(IWebScriptWorld*);
+
 extern UINT_PTR waitToDumpWatchdog;
 
 #endif // DumpRenderTreeWin_h
diff --git a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp
index 939090a..37d5e1c 100644
--- a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp
+++ b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp
@@ -289,12 +289,53 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::willCloseFrame(
     return E_NOTIMPL;
 }
 
-HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didClearWindowObject( 
-    /* [in] */ IWebView*webView,
-    /* [in] */ JSContextRef context,
-    /* [in] */ JSObjectRef windowObject,
-    /* [in] */ IWebFrame* frame)
+HRESULT FrameLoadDelegate::didClearWindowObject(IWebView*, JSContextRef, JSObjectRef, IWebFrame*)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT FrameLoadDelegate::didClearWindowObjectForFrameInScriptWorld(IWebView* webView, IWebFrame* frame, IWebScriptWorld* world)
+{
+    ASSERT_ARG(webView, webView);
+    ASSERT_ARG(frame, frame);
+    ASSERT_ARG(world, world);
+    if (!webView || !frame || !world)
+        return E_POINTER;
+
+    COMPtr<IWebScriptWorld> standardWorld;
+    if (FAILED(world->standardWorld(&standardWorld)))
+        return S_OK;
+
+    if (world == standardWorld)
+        didClearWindowObjectForFrameInStandardWorld(frame);
+    else
+        didClearWindowObjectForFrameInIsolatedWorld(frame, world);
+    return S_OK;
+}
+
+void FrameLoadDelegate::didClearWindowObjectForFrameInIsolatedWorld(IWebFrame* frame, IWebScriptWorld* world)
+{
+    COMPtr<IWebFramePrivate> framePrivate(Query, frame);
+    if (!framePrivate)
+        return;
+
+    JSGlobalContextRef ctx = framePrivate->globalContextForScriptWorld(world);
+    if (!ctx)
+        return;
+
+    JSObjectRef globalObject = JSContextGetGlobalObject(ctx);
+    if (!globalObject)
+        return;
+
+    JSObjectSetProperty(ctx, globalObject, JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
+    return;
+}
+
+void FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld(IWebFrame* frame)
 {
+    JSGlobalContextRef context = frame->globalContext();
+    JSObjectRef windowObject = JSContextGetGlobalObject(context);
+
     JSValueRef exception = 0;
 
     ::gLayoutTestController->makeWindowObject(context, windowObject, &exception);
@@ -310,8 +351,6 @@ HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didClearWindowObject(
     JSValueRef eventSender = makeEventSender(context);
     JSObjectSetProperty(context, windowObject, eventSenderStr, eventSender, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
     JSStringRelease(eventSenderStr);
-
-    return S_OK;
 }
 
 HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didFinishDocumentLoadForFrame( 
diff --git a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h
index 56325e2..0deeeca 100644
--- a/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h
+++ b/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h
@@ -141,7 +141,12 @@ public:
         /* [in] */ IWebView *sender,
         /* [in] */ IWebSecurityOrigin *origin);
 
-protected:
+    virtual HRESULT STDMETHODCALLTYPE didClearWindowObjectForFrameInScriptWorld(IWebView*, IWebFrame*, IWebScriptWorld*);
+
+private:
+    void didClearWindowObjectForFrameInIsolatedWorld(IWebFrame*, IWebScriptWorld*);
+    void didClearWindowObjectForFrameInStandardWorld(IWebFrame*);
+
     void locationChangeDone(IWebError*, IWebFrame*);
 
     ULONG m_refCount;
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index d6d8421..0320b42 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -955,6 +955,24 @@ void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef scrip
     inspectorPrivate->evaluateInFrontend(callId, bstrT(script).GetBSTR());
 }
 
+typedef HashMap<unsigned, COMPtr<IWebScriptWorld> > WorldMap;
+static WorldMap& worldMap()
+{
+    static WorldMap& map = *new WorldMap;
+    return map;
+}
+
+unsigned worldIDForWorld(IWebScriptWorld* world)
+{
+    WorldMap::const_iterator end = worldMap().end();
+    for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) {
+        if (it->second == world)
+            return it->first;
+    }
+
+    return 0;
+}
+
 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
 {
     COMPtr<IWebFramePrivate> framePrivate(Query, frame);
@@ -968,9 +986,7 @@ void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObj
         if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world))))
             return;
     } else {
-        typedef HashMap<unsigned, COMPtr<IWebScriptWorld> > WorldMap;
-        static WorldMap& worldMap = *new WorldMap;
-        COMPtr<IWebScriptWorld>& worldSlot = worldMap.add(worldID, 0).first->second;
+        COMPtr<IWebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
         if (!worldSlot && FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(worldSlot), reinterpret_cast<void**>(&worldSlot))))
             return;
         world = worldSlot;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list