Changeset 50973 in webkit


Ignore:
Timestamp:
Nov 13, 2009 3:49:05 PM (14 years ago)
Author:
Adam Roben
Message:

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.

Location:
trunk
Files:
2 added
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r50969 r50973  
     12009-11-04  Adam Roben  <aroben@apple.com>
     2
     3        Test that delegates can modify global objects in isolated worlds
     4
     5        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     6        window objects in isolated worlds are cleared
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * http/tests/security/isolatedWorld/didClearWindowObject-expected.txt: Added.
     11        * http/tests/security/isolatedWorld/didClearWindowObject.html: Added.
     12        Tests that the global object in the normal world does not have a
     13        __worldID property, and that the global object in isolated worlds has
     14        a __worldID property whose value is equal to the world's ID.
     15
    1162009-11-13  Dumitru Daniliuc  <dumi@chromium.org>
    217
  • trunk/WebCore/ChangeLog

    r50972 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Tell FrameLoaderClient when window objects in isolated worlds are
     4        cleared
     5
     6        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     7        window objects in isolated worlds are cleared
     8
     9        Test: http/tests/security/isolatedWorld/didClearWindowObject.html
     10
     11        Reviewed by Dave Hyatt.
     12
     13        * bindings/js/JSDOMBinding.h:
     14        (WebCore::WebCoreJSClientData::getAllWorlds): Added. Copies all the
     15        worlds in m_worldSet to the passed-in Vector.
     16
     17        * bindings/js/ScriptController.cpp:
     18        (WebCore::ScriptController::getAllWorlds): Added. Calls through to
     19        WebCoreJSClientData.
     20        (WebCore::ScriptController::initScript): Changed to call
     21        FrameLoader::dispatchDidClearWindowObjectInWorld.
     22
     23        * bindings/js/ScriptController.h: Added getAllWorlds.
     24
     25        * loader/EmptyClients.h:
     26        (WebCore::EmptyFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
     27        Updated for FrameLoaderClient change.
     28
     29        * loader/FrameLoader.cpp:
     30        (WebCore::FrameLoader::receivedFirstData):
     31        (WebCore::FrameLoader::begin):
     32        Changed to call dispatchDidClearWindowObjectsInAllWorlds.
     33
     34        (WebCore::FrameLoader::dispatchDidClearWindowObjectsInAllWorlds):
     35        Added. Retrieves all the worlds, then calls through to
     36        dispatchDidClearWindowObjectInWorld for each one.
     37        (WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld): Replaces
     38        dispatchWindowObjectAvailable. Calls up to the client, then, if the
     39        world is the mainThreadNormalWorld(), tells the Inspector about it,
     40        too.
     41
     42        * loader/FrameLoader.h: Replaced dispatchWindowObjectAvailable with
     43        dispatchDidClearWindowObjectInWorld. Added
     44        dispatchDidClearWindowObjectsInAllWorlds.
     45
     46        * loader/FrameLoaderClient.h: Replaced windowObjectCleared with
     47        dispatchDidClearWindowObjectForWorld.
     48
    1492009-11-13  Vitaly Repeshko  <vitalyr@chromium.org>
    250
  • trunk/WebCore/bindings/js/JSDOMBinding.h

    r50850 r50973  
    198198        DOMWrapperWorld* normalWorld() { return &m_normalWorld; }
    199199
     200        void getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
     201        {
     202            copyToVector(m_worldSet, worlds);
     203        }
     204
    200205        void rememberWorld(DOMWrapperWorld* world)
    201206        {
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r50907 r50973  
    4646
    4747using namespace JSC;
     48using namespace std;
    4849
    4950namespace WebCore {
     
    171172}
    172173
     174void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
     175{
     176    static_cast<WebCoreJSClientData*>(JSDOMWindow::commonJSGlobalData()->clientData)->getAllWorlds(worlds);
     177}
     178
    173179void ScriptController::clearWindowShell()
    174180{
     
    217223    {
    218224        EnterDOMWrapperWorld worldEntry(*JSDOMWindow::commonJSGlobalData(), world);
    219         m_frame->loader()->dispatchWindowObjectAvailable();
     225        m_frame->loader()->dispatchDidClearWindowObjectInWorld(world);
    220226    }
    221227
  • trunk/WebCore/bindings/js/ScriptController.h

    r50907 r50973  
    8787        return windowShell(world)->window();
    8888    }
     89
     90    static void getAllWorlds(Vector<DOMWrapperWorld*>&);
    8991
    9092    ScriptValue executeScript(const ScriptSourceCode&);
  • trunk/WebCore/loader/EmptyClients.h

    r50351 r50973  
    294294
    295295    virtual void redirectDataToPlugin(Widget*) { }
    296     virtual void windowObjectCleared() { }
     296    virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) { }
    297297    virtual void documentElementAvailable() { }
    298298    virtual void didPerformFirstNavigation() const { }
  • trunk/WebCore/loader/FrameLoader.cpp

    r50784 r50973  
    741741
    742742    dispatchDidCommitLoad();
    743     dispatchWindowObjectAvailable();
     743    dispatchDidClearWindowObjectsInAllWorlds();
    744744   
    745745    if (m_documentLoader) {
     
    830830
    831831    if (dispatch)
    832         dispatchWindowObjectAvailable();
     832        dispatchDidClearWindowObjectsInAllWorlds();
    833833   
    834834    updateFirstPartyForCookies();
     
    38693869}
    38703870
    3871 void FrameLoader::dispatchWindowObjectAvailable()
    3872 {
    3873     // FIXME: should this be isolated-worlds-aware?
    3874     if (!m_frame->script()->isEnabled() || !m_frame->script()->existingWindowShell(mainThreadNormalWorld()))
    3875         return;
    3876 
    3877     m_client->windowObjectCleared();
     3871void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
     3872{
     3873    if (!m_frame->script()->isEnabled())
     3874        return;
     3875
     3876    Vector<DOMWrapperWorld*> worlds;
     3877    ScriptController::getAllWorlds(worlds);
     3878    for (size_t i = 0; i < worlds.size(); ++i)
     3879        dispatchDidClearWindowObjectInWorld(worlds[i]);
     3880}
     3881
     3882void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     3883{
     3884    if (!m_frame->script()->isEnabled() || !m_frame->script()->existingWindowShell(world))
     3885        return;
     3886
     3887    m_client->dispatchDidClearWindowObjectInWorld(world);
    38783888
    38793889#if ENABLE(INSPECTOR)
     3890    if (world != mainThreadNormalWorld())
     3891        return;
     3892
    38803893    if (Page* page = m_frame->page()) {
    38813894        if (InspectorController* inspector = page->inspectorController())
  • trunk/WebCore/loader/FrameLoader.h

    r50225 r50973  
    5151class CachedPage;
    5252class CachedResource;
     53class DOMWrapperWorld;
    5354class Document;
    5455class DocumentLoader;
     
    247248    PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const HashMap<String, String>& args);
    248249
    249     void dispatchWindowObjectAvailable();
     250    void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
    250251    void dispatchDocumentElementAvailable();
    251252
     
    395396
    396397    void dispatchDidCommitLoad();
     398    void dispatchDidClearWindowObjectsInAllWorlds();
    397399
    398400    void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
  • trunk/WebCore/loader/FrameLoaderClient.h

    r50625 r50973  
    4848    class CachedFrame;
    4949    class Color;
     50    class DOMWrapperWorld;
    5051    class DocumentLoader;
    5152    class Element;
     
    223224        virtual String overrideMediaType() const = 0;
    224225
    225         virtual void windowObjectCleared() = 0;
     226        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) = 0;
    226227        virtual void documentElementAvailable() = 0;
    227228        virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
  • trunk/WebKit/ChangeLog

    r50907 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Add WebFrameLoadDelegatePrivat.h to WebKit.xcodeproj
     4
     5        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     6        window objects in isolated worlds are cleared
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebKit.xcodeproj/project.pbxproj: Added
     11        WebFrameLoadDelegatePrivate.h, which already existed.
     12
    1132009-11-12  Adam Roben  <aroben@apple.com>
    214
  • trunk/WebKit/WebKit.xcodeproj/project.pbxproj

    r50907 r50973  
    337337                C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */; };
    338338                C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */; };
     339                C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    339340                DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; };
    340341                DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; };
     
    628629                C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptWorld.mm; sourceTree = "<group>"; };
    629630                C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorldInternal.h; sourceTree = "<group>"; };
     631                C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFrameLoadDelegatePrivate.h; sourceTree = "<group>"; };
    630632                DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTypesInternal.h; sourceTree = "<group>"; };
    631633                DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    11101112                                930D02BD06275F710076701E /* WebFrameInternal.h */,
    11111113                                5152FAE5033FC52200CA2ACD /* WebFrameLoadDelegate.h */,
     1114                                C0B88E8A10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h */,
    11121115                                9CF0E249021361B00ECA16EA /* WebFramePrivate.h */,
    11131116                                51A8B52E04282B5900CA2D3A /* WebFrameView.h */,
     
    15251528                                C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
    15261529                                C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */,
     1530                                C0B88E8B10A08F3D00FBB3F5 /* WebFrameLoadDelegatePrivate.h in Headers */,
    15271531                        );
    15281532                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit/gtk/ChangeLog

    r50923 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Update for changes to FrameLoaderClient
     4
     5        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     6        window objects in isolated worlds are cleared
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     11        (WebKit::FrameLoaderClient::dispatchDidClearWindowObjectInWorld):
     12        * WebCoreSupport/FrameLoaderClientGtk.h:
     13        Replaced windowObjectCleared with this function. Does nothing if the
     14        passed-in world is not the mainThreadNormalWorld().
     15
    1162009-11-12  Shinichiro Hamaji  <hamaji@chromium.org>
    217
  • trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r50793 r50973  
    501501}
    502502
    503 void FrameLoaderClient::windowObjectCleared()
    504 {
     503void FrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     504{
     505    if (world != mainThreadNormalWorld())
     506        return;
     507
    505508    // Is this obsolete now?
    506509    g_signal_emit_by_name(m_frame, "cleared");
  • trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h

    r48032 r50973  
    115115        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);
    116116        virtual WebCore::String overrideMediaType() const;
    117         virtual void windowObjectCleared();
     117        virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
    118118        virtual void documentElementAvailable();
    119119        virtual void didPerformFirstNavigation() const;
  • trunk/WebKit/haiku/ChangeLog

    r50351 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Update for changes to FrameLoaderClient
     4
     5        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     6        window objects in isolated worlds are cleared
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebCoreSupport/FrameLoaderClientHaiku.cpp:
     11        (WebCore::FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld):
     12        * WebCoreSupport/FrameLoaderClientHaiku.h:
     13        Replaced windowObjectCleared with this function. Does nothing if the
     14        passed-in world is not the mainThreadNormalWorld().
     15
    1162009-10-30  Evan Stade  <estade@chromium.org>
    217
  • trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp

    r49284 r50973  
    4343#include "PlatformString.h"
    4444#include "ResourceRequest.h"
     45#include "ScriptController.h"
    4546#include "WebView.h"
    4647
     
    760761}
    761762
    762 void FrameLoaderClientHaiku::windowObjectCleared()
    763 {
     763void FrameLoaderClientHaiku::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     764{
     765    if (world != mainThreadNormalWorld())
     766        return;
     767
    764768    if (m_webView) {
    765769        BMessage message(JAVASCRIPT_WINDOW_OBJECT_CLEARED);
  • trunk/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h

    r46494 r50973  
    229229        virtual String overrideMediaType() const;
    230230
    231         virtual void windowObjectCleared();
     231        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
    232232        virtual void documentElementAvailable();
    233233
  • trunk/WebKit/mac/ChangeLog

    r50943 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Tell the WebFrameLoadDelegate when window objects in isolated worlds
     4        are cleared
     5
     6        Fixes <http://webkit.org/b/31124>.
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebCoreSupport/WebFrameLoaderClient.h:
     11        * WebCoreSupport/WebFrameLoaderClient.mm:
     12        (WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
     13        Replaced windowObjectCleared with this function. If the delegate
     14        implements it, call
     15        -webView:didClearWindowObjectForFrame:inScriptWorld:. Otherwise, if
     16        the passed-in world is the mainThreadNormalWorld(), call
     17        -webView:didClearWindowObject:forFrame:.
     18
     19        * WebView/WebDelegateImplementationCaching.h: Added a new entry in the
     20        frame load delegate implementation cache for the new delegate method.
     21
     22        * WebView/WebFrameLoadDelegatePrivate.h:
     23        * WebView/WebScriptWorld.mm:
     24        (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in
     25        existence.
     26        (-[WebScriptWorld initWithWorld:]): Add ourselves to allWorlds().
     27        (-[WebScriptWorld dealloc]): Remove ourselves from allWorlds().
     28        (+[WebScriptWorld findOrCreateWorld:]): Returns the existing
     29        WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't
     30        already exist.
     31
     32        * WebView/WebScriptWorldInternal.h: Declared +findOrCreateWorld:.
     33
     34        * WebView/WebView.mm:
     35        (-[WebView _cacheFrameLoadDelegateImplementations]): Cache the
     36        implementation of the new frame load delegate method.
     37
    1382009-11-13  Adam Roben  <aroben@apple.com>
    239
  • trunk/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h

    r49320 r50973  
    192192    virtual WebCore::String overrideMediaType() const;
    193193   
    194     virtual void windowObjectCleared();
     194    virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
    195195    virtual void documentElementAvailable();
    196196    virtual void didPerformFirstNavigation() const;
  • trunk/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r49413 r50973  
    7070#import "WebPreferences.h"
    7171#import "WebResourceLoadDelegate.h"
     72#import "WebScriptWorldInternal.h"
    7273#import "WebSecurityOriginInternal.h"
    7374#import "WebUIDelegate.h"
     
    129130using namespace WebCore;
    130131using namespace HTMLNames;
     132using namespace std;
    131133
    132134#if ENABLE(MAC_JAVA_BRIDGE)
     
    16901692}
    16911693
    1692 void WebFrameLoaderClient::windowObjectCleared()
    1693 {
     1694void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     1695{
     1696    WebView *webView = getWebView(m_webFrame.get());
     1697    WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     1698
     1699    if (implementations->didClearWindowObjectForFrameInScriptWorldFunc) {
     1700        CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameInScriptWorldFunc,
     1701            webView, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:), m_webFrame.get(), [WebScriptWorld findOrCreateWorld:world]);
     1702        return;
     1703    }
     1704
     1705    if (world != mainThreadNormalWorld())
     1706        return;
     1707
    16941708    Frame *frame = core(m_webFrame.get());
    16951709    ScriptController *script = frame->script();
    1696     WebView *webView = getWebView(m_webFrame.get());
    1697     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
     1710
    16981711    if (implementations->didClearWindowObjectForFrameFunc) {
    16991712        CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameFunc, webView, @selector(webView:didClearWindowObject:forFrame:),
  • trunk/WebKit/mac/WebView/WebDelegateImplementationCaching.h

    r49369 r50973  
    5050struct WebFrameLoadDelegateImplementationCache {
    5151    IMP didClearWindowObjectForFrameFunc;
     52    IMP didClearWindowObjectForFrameInScriptWorldFunc;
    5253    IMP didClearInspectorWindowObjectForFrameFunc;
    5354    IMP windowScriptObjectAvailableFunc;
  • trunk/WebKit/mac/WebView/WebFrameLoadDelegatePrivate.h

    r48051 r50973  
    2929#import <WebKit/WebFrameLoadDelegate.h>
    3030
     31@class WebScriptWorld;
    3132@class WebSecurityOrigin;
    3233
     
    3738- (void)webView:(WebView *)webView didRunInsecureContent:(WebSecurityOrigin *)origin;
    3839
     40- (void)webView:(WebView *)webView didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world;
     41
    3942@end
  • trunk/WebKit/mac/WebView/WebScriptWorld.mm

    r50907 r50973  
    4141@end
    4242
     43typedef HashMap<DOMWrapperWorld*, WebScriptWorld*> WorldMap;
     44static WorldMap& allWorlds()
     45{
     46    static WorldMap& map = *new WorldMap;
     47    return map;
     48}
     49
    4350@implementation WebScriptWorld
    4451
     
    5663    _private->world = world;
    5764
     65    ASSERT_ARG(world, !allWorlds().contains(_private->world.get()));
     66    allWorlds().add(_private->world.get(), self);
     67
    5868    return self;
    5969}
     
    6676- (void)dealloc
    6777{
     78    ASSERT(allWorlds().contains(_private->world.get()));
     79    allWorlds().remove(_private->world.get());
     80
    6881    [_private release];
    6982    _private = nil;
     
    8295}
    8396
     97@end
     98
     99@implementation WebScriptWorld (WebInternal)
     100
    84101DOMWrapperWorld* core(WebScriptWorld *world)
    85102{
     
    87104}
    88105
     106+ (WebScriptWorld *)findOrCreateWorld:(DOMWrapperWorld*) world
     107{
     108    ASSERT_ARG(world, world);
     109
     110    if (world == mainThreadNormalWorld())
     111        return [self standardWorld];
     112
     113    if (WebScriptWorld *existingWorld = allWorlds().get(world))
     114        return existingWorld;
     115
     116    return [[[self alloc] initWithWorld:world] autorelease];
     117}
     118
    89119@end
  • trunk/WebKit/mac/WebView/WebScriptWorldInternal.h

    r50907 r50973  
    3030
    3131WebCore::DOMWrapperWorld* core(WebScriptWorld *);
     32
     33@interface WebScriptWorld (WebInternal)
     34+ (WebScriptWorld *)findOrCreateWorld:(WebCore::DOMWrapperWorld*)world;
     35@end
  • trunk/WebKit/mac/WebView/WebView.mm

    r50930 r50973  
    13501350    cache->didChangeLocationWithinPageForFrameFunc = getMethod(delegate, @selector(webView:didChangeLocationWithinPageForFrame:));
    13511351    cache->didClearWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearWindowObject:forFrame:));
     1352    cache->didClearWindowObjectForFrameInScriptWorldFunc = getMethod(delegate, @selector(webView:didClearWindowObjectForFrame:inScriptWorld:));
    13521353    cache->didClearInspectorWindowObjectForFrameFunc = getMethod(delegate, @selector(webView:didClearInspectorWindowObject:forFrame:));
    13531354    cache->didCommitLoadForFrameFunc = getMethod(delegate, @selector(webView:didCommitLoadForFrame:));
  • trunk/WebKit/qt/ChangeLog

    r50940 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Update for changes to FrameLoaderClient
     4
     5        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     6        window objects in isolated worlds are cleared
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebCoreSupport/FrameLoaderClientQt.cpp:
     11        (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld):
     12        * WebCoreSupport/FrameLoaderClientQt.h:
     13        Replaced windowObjectCleared with this function. Does nothing if the
     14        passed-in world is not the mainThreadNormalWorld().
     15
    1162009-11-13  Andras Becsi  <becsi.andras@stud.u-szeged.hu>
    217
  • trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

    r50818 r50973  
    5454#include "ResourceHandleInternal.h"
    5555#include "ResourceHandle.h"
     56#include "ScriptController.h"
     57#include "ScriptString.h"
    5658#include "Settings.h"
    57 #include "ScriptString.h"
    5859#include "QWebPageClient.h"
    5960
     
    601602}
    602603
    603 void FrameLoaderClientQt::windowObjectCleared()
    604 {
     604void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     605{
     606    if (world != mainThreadNormalWorld())
     607        return;
     608
    605609    if (dumpFrameLoaderCallbacks)
    606610        printf("%s - didClearWindowObjectForFrame\n", qPrintable(drtDescriptionSuitableForTestResult(m_frame)));
  • trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h

    r48870 r50973  
    198198        virtual String overrideMediaType() const;
    199199
    200         virtual void windowObjectCleared();
     200        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
    201201        virtual void documentElementAvailable();
    202202        virtual void didPerformFirstNavigation() const;
  • trunk/WebKit/win/ChangeLog

    r50945 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Tell the WebFrameLoadDelegate when window objects in isolated worlds
     4        are cleared
     5
     6        Fixes <http://webkit.org/b/31124>.
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * Interfaces/IWebFrameLoadDelegatePrivate2.idl: Added
     11        didClearWindowObjectForFrameInScriptWorld.
     12
     13        * WebFrame.cpp:
     14        (WebFrame::dispatchDidClearWindowObjectInWorld):
     15        * WebFrame.h:
     16        Replaced windowObjectCleared with this function. If the delegate
     17        implements IWebFrameLoadDelegatePrivate2, call
     18        didClearWindowObjectForFrameInScriptWorld. Otherwise, if the passed-in
     19        world is the mainThreadNormalWorld(), call
     20        didClearWindowObjectForFrame.
     21
     22        * WebScriptWorld.cpp:
     23        (allWorlds): Added. Returns a HashMap of all the WebScriptWorlds in
     24        existence.
     25        (WebScriptWorld::WebScriptWorld): Add ourselves to allWorlds().
     26        (WebScriptWorld::~WebScriptWorld): Remove ourselves from allWorlds().
     27        (WebScriptWorld::standardWorld): Added this non-COM getter for the
     28        standard world, which the COM getter now calls through to.
     29        (WebScriptWorld::findOrCreateWorld): Added. Returns the existing
     30        WebScriptWorld for this DOMWrapperWorld, or a new one if one doesn't
     31        already exist.
     32
     33        * WebScriptWorld.h: Added new standardWorld overload, made one
     34        overload of createInstance private, and added findOrCreateWorld.
     35
    1362009-11-13  Adam Roben  <aroben@apple.com>
    237
  • trunk/WebKit/win/Interfaces/IWebFrameLoadDelegatePrivate2.idl

    r48053 r50973  
    3232
    3333interface IWebFrame;
     34interface IWebScriptWorld;
     35interface IWebSecurityOrigin;
    3436interface IWebView;
    35 interface IWebSecurityOrigin;
    3637
    3738[
     
    4647
    4748    HRESULT didRunInsecureContent([in] IWebView* sender, [in] IWebSecurityOrigin* origin);
     49
     50    HRESULT didClearWindowObjectForFrameInScriptWorld([in] IWebView* webView, [in] IWebFrame* frame, [in] IWebScriptWorld*);
    4851}
  • trunk/WebKit/win/WebFrame.cpp

    r50943 r50973  
    120120using namespace WebCore;
    121121using namespace HTMLNames;
     122using namespace std;
    122123
    123124using JSC::JSGlobalObject;
     
    17171718}
    17181719
    1719 void WebFrame::windowObjectCleared()
     1720void WebFrame::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
    17201721{
    17211722    Frame* coreFrame = core(this);
     
    17271728
    17281729    COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
    1729     if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate))) {
    1730         JSContextRef context = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
    1731         JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld()));
    1732         ASSERT(windowObject);
    1733 
    1734         if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this)))
    1735             frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject);
    1736     }
     1730    if (FAILED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
     1731        return;
     1732
     1733    COMPtr<IWebFrameLoadDelegatePrivate2> delegatePrivate(Query, frameLoadDelegate);
     1734    if (delegatePrivate) {
     1735        delegatePrivate->didClearWindowObjectForFrameInScriptWorld(d->webView, this, WebScriptWorld::findOrCreateWorld(world).get());
     1736        return;
     1737    }
     1738
     1739    if (world != mainThreadNormalWorld())
     1740        return;
     1741
     1742    JSContextRef context = toRef(coreFrame->script()->globalObject(world)->globalExec());
     1743    JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(world));
     1744    ASSERT(windowObject);
     1745
     1746    if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this)))
     1747        frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject);
    17371748}
    17381749
  • trunk/WebKit/win/WebFrame.h

    r50943 r50973  
    313313    virtual WebCore::String overrideMediaType() const;
    314314
    315     virtual void windowObjectCleared();
     315    virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
    316316    virtual void documentElementAvailable();
    317317    virtual void didPerformFirstNavigation() const;
  • trunk/WebKit/win/WebScriptWorld.cpp

    r50907 r50973  
    3232using namespace WebCore;
    3333
     34typedef HashMap<DOMWrapperWorld*, WebScriptWorld*> WorldMap;
     35static WorldMap& allWorlds()
     36{
     37    static WorldMap& map = *new WorldMap;
     38    return map;
     39}
     40
    3441inline WebScriptWorld::WebScriptWorld(PassRefPtr<DOMWrapperWorld> world)
    3542    : m_refCount(0)
     
    3744{
    3845    ASSERT_ARG(world, m_world);
     46
     47    ASSERT_ARG(world, !allWorlds().contains(m_world.get()));
     48    allWorlds().add(m_world.get(), this);
    3949
    4050    ++gClassCount;
     
    4454WebScriptWorld::~WebScriptWorld()
    4555{
     56    ASSERT(allWorlds().contains(m_world.get()));
     57    allWorlds().remove(m_world.get());
     58
    4659    --gClassCount;
    4760    gClassNameCount.remove("WebScriptWorld");
     61}
     62
     63WebScriptWorld* WebScriptWorld::standardWorld()
     64{
     65    static WebScriptWorld* standardWorld = createInstance(mainThreadNormalWorld()).releaseRef();
     66    return standardWorld;
    4867}
    4968
     
    5675{
    5776    return new WebScriptWorld(world);
     77}
     78
     79COMPtr<WebScriptWorld> WebScriptWorld::findOrCreateWorld(DOMWrapperWorld* world)
     80{
     81    if (world == mainThreadNormalWorld())
     82        return standardWorld();
     83
     84    if (WebScriptWorld* existingWorld = allWorlds().get(world))
     85        return existingWorld;
     86
     87    return createInstance(world);
    5888}
    5989
     
    95125        return E_POINTER;
    96126
    97     static WebScriptWorld* standardWorld = createInstance(mainThreadNormalWorld()).releaseRef();
    98 
    99     *outWorld = standardWorld;
    100     standardWorld->AddRef();
     127    *outWorld = standardWorld();
     128    (*outWorld)->AddRef();
    101129    return S_OK;
    102130}
  • trunk/WebKit/win/WebScriptWorld.h

    r50907 r50973  
    3434class WebScriptWorld : public Noncopyable, public IWebScriptWorld {
    3535public:
     36    static WebScriptWorld* standardWorld();
    3637    static COMPtr<WebScriptWorld> createInstance();
    37     static COMPtr<WebScriptWorld> createInstance(PassRefPtr<WebCore::DOMWrapperWorld>);
     38
     39    static COMPtr<WebScriptWorld> findOrCreateWorld(WebCore::DOMWrapperWorld*);
    3840
    3941    virtual ULONG STDMETHODCALLTYPE AddRef();
     
    4345
    4446private:
     47    static COMPtr<WebScriptWorld> createInstance(PassRefPtr<WebCore::DOMWrapperWorld>);
     48
    4549    WebScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>);
    4650    ~WebScriptWorld();
  • trunk/WebKit/wx/ChangeLog

    r50777 r50973  
     12009-11-13  Adam Roben  <aroben@apple.com>
     2
     3        Update for changes to FrameLoaderClient
     4
     5        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     6        window objects in isolated worlds are cleared
     7
     8        Reviewed by Dave Hyatt.
     9
     10        * WebKitSupport/FrameLoaderClientWx.cpp:
     11        (WebCore::FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld):
     12        * WebKitSupport/FrameLoaderClientWx.h:
     13        Replaced windowObjectCleared with this function. Does nothing if the
     14        passed-in world is not the mainThreadNormalWorld().
     15
    1162009-11-10  Robin Dunn  <robin@alldunn.com>
    217
  • trunk/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp

    r49981 r50973  
    832832}
    833833
    834 void FrameLoaderClientWx::windowObjectCleared()
    835 {
     834void FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     835{
     836    if (world != mainThreadNormalWorld())
     837        return;
     838
    836839    if (m_webView) {
    837840        wxWebViewWindowObjectClearedEvent wkEvent(m_webView);
  • trunk/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h

    r48032 r50973  
    203203        virtual String overrideMediaType() const;
    204204
    205         virtual void windowObjectCleared();
     205        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
    206206        virtual void documentElementAvailable();
    207207       
  • trunk/WebKitTools/ChangeLog

    r50965 r50973  
    1616        * DumpRenderTree/qt/DumpRenderTree.cpp:
    1717        (WebCore::DumpRenderTree::resetToConsistentStateBeforeTesting):
     18
     192009-11-13  Adam Roben  <aroben@apple.com>
     20
     21        Add support for
     22        http/tests/security/isolatedWorld/didClearWindowObject.html
     23
     24        Fixes <http://webkit.org/b/31124> Tell the WebFrameLoadDelegate when
     25        window objects in isolated worlds are cleared
     26
     27        Reviewed by Dave Hyatt.
     28
     29        * DumpRenderTree/mac/DumpRenderTreeMac.h: Declared worldIDForWorld.
     30
     31        * DumpRenderTree/mac/FrameLoadDelegate.mm:
     32        (-[FrameLoadDelegate didClearWindowObjectInStandardWorldForFrame:]):
     33        Added. Moved code here from -webView:didClearWindowObject:forFrame:.
     34        (-[FrameLoadDelegate didClearWindowObjectForFrame:inIsolatedWorld:]):
     35        Added. Sets a __worldID property on the global object whose value is
     36        the ID of this world.
     37        (-[FrameLoadDelegate webView:didClearWindowObjectForFrame:inScriptWorld:]):
     38        Respond to this new delegate callback by calling through to one of the
     39        above new methods.
     40        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     41        (worldMap): Added. Returns a HashMap containing all the worlds we've
     42        created.
     43        (worldIDForWorld): Added. Returns the ID for this world, or 0 if we
     44        haven't kept track of this world.
     45        (LayoutTestController::evaluateScriptInIsolatedWorld): Use worldMap()
     46        instead of declaring our own.
     47
     48        * DumpRenderTree/win/DumpRenderTreeWin.h: Declared worldIDForWorld.
     49
     50        * DumpRenderTree/win/FrameLoadDelegate.cpp:
     51        (FrameLoadDelegate::didClearWindowObject): Moved code from hear to
     52        didClearWindowObjectForFrameInStandardWorld.
     53        (FrameLoadDelegate::didClearWindowObjectForFrameInScriptWorld):
     54        Respond to this new delegate callback by calling through to one of the
     55        below new methods.
     56        (FrameLoadDelegate::didClearWindowObjectForFrameInIsolatedWorld):
     57        Added. Sets a __worldID property on the gobal object whose value is
     58        the ID of this world.
     59        (FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld):
     60        Added. Moved code here from didClearWindowObject.
     61
     62        * DumpRenderTree/win/FrameLoadDelegate.h: Added the
     63        didClearWindowObjectForFrame* functions.
     64
     65        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
     66        (worldMap): Added. Returns a HashMap containing all the worlds we've
     67        created.
     68        (worldIDForWorld): Added. Returns the ID of this world, or 0 if we
     69        haven't kept track of this world.
     70        (LayoutTestController::evaluateScriptInIsolatedWorld): Use worldMap()
     71        instead of declaring our own.
    1872
    19732009-11-13  Adam Roben  <aroben@apple.com>
  • trunk/WebKitTools/DumpRenderTree/mac/DumpRenderTreeMac.h

    r42011 r50973  
    4343@class PolicyDelegate;
    4444@class WebFrame;
     45@class WebScriptWorld;
    4546@class WebView;
    4647
     
    6364void setPersistentUserStyleSheetLocation(CFStringRef);
    6465
     66unsigned worldIDForWorld(WebScriptWorld *);
     67
    6568#endif // DumpRenderTreeMac_h
  • trunk/WebKitTools/DumpRenderTree/mac/FrameLoadDelegate.mm

    r50783 r50973  
    4949#import <WebKit/WebKit.h>
    5050#import <WebKit/WebNSURLExtras.h>
     51#import <WebKit/WebScriptWorld.h>
    5152#import <WebKit/WebSecurityOriginPrivate.h>
    5253#import <wtf/Assertions.h>
     
    237238}
    238239
    239 - (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)obj forFrame:(WebFrame *)frame
    240 {
    241     ASSERT(obj == [frame windowObject]);
    242     ASSERT([obj JSObject] == JSContextGetGlobalObject([frame globalContext]));
    243 
     240- (void)didClearWindowObjectInStandardWorldForFrame:(WebFrame *)frame
     241{
    244242    // Make New-Style LayoutTestController
    245243    JSContextRef context = [frame globalContext];
     
    259257    // Make Old-Style controllers
    260258
    261     AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:sender];
     259    WebView *webView = [frame webView];
     260    WebScriptObject *obj = [frame windowObject];
     261    AppleScriptController *asc = [[AppleScriptController alloc] initWithWebView:webView];
    262262    [obj setValue:asc forKey:@"appleScriptController"];
    263263    [asc release];
     
    283283    [obj setValue:[PlainTextController sharedPlainTextController] forKey:@"plainText"];
    284284
    285     TextInputController *tic = [[TextInputController alloc] initWithWebView:sender];
     285    TextInputController *tic = [[TextInputController alloc] initWithWebView:webView];
    286286    [obj setValue:tic forKey:@"textInputController"];
    287287    [tic release];
     288}
     289
     290- (void)didClearWindowObjectForFrame:(WebFrame *)frame inIsolatedWorld:(WebScriptWorld *)world
     291{
     292    JSGlobalContextRef ctx = [frame _globalContextForScriptWorld:world];
     293    if (!ctx)
     294        return;
     295
     296    JSObjectRef globalObject = JSContextGetGlobalObject(ctx);
     297    if (!globalObject)
     298        return;
     299
     300    JSObjectSetProperty(ctx, globalObject, JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
     301}
     302
     303- (void)webView:(WebView *)sender didClearWindowObjectForFrame:(WebFrame *)frame inScriptWorld:(WebScriptWorld *)world
     304{
     305    if (world == [WebScriptWorld standardWorld])
     306        [self didClearWindowObjectInStandardWorldForFrame:frame];
     307    else
     308        [self didClearWindowObjectForFrame:frame inIsolatedWorld:world];
    288309}
    289310
  • trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r50943 r50973  
    533533}
    534534
     535typedef HashMap<unsigned, RetainPtr<WebScriptWorld> > WorldMap;
     536static WorldMap& worldMap()
     537{
     538    static WorldMap& map = *new WorldMap;
     539    return map;
     540}
     541
     542unsigned worldIDForWorld(WebScriptWorld *world)
     543{
     544    WorldMap::const_iterator end = worldMap().end();
     545    for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) {
     546        if (it->second == world)
     547            return it->first;
     548    }
     549
     550    return 0;
     551}
     552
    535553void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
    536554{
     
    544562        world = [WebScriptWorld world];
    545563    else {
    546         typedef HashMap<unsigned, RetainPtr<WebScriptWorld> > WorldMap;
    547         static WorldMap& worldMap = *new WorldMap;
    548         RetainPtr<WebScriptWorld>& worldSlot = worldMap.add(worldID, 0).first->second;
     564        RetainPtr<WebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
    549565        if (!worldSlot)
    550566            worldSlot.adoptNS([[WebScriptWorld alloc] init]);
  • trunk/WebKitTools/DumpRenderTree/win/DumpRenderTreeWin.h

    r47792 r50973  
    3131
    3232struct IWebFrame;
     33struct IWebScriptWorld;
    3334struct IWebView;
    3435struct PolicyDelegate;
     
    5657bool setAlwaysAcceptCookies(bool alwaysAcceptCookies);
    5758
     59unsigned worldIDForWorld(IWebScriptWorld*);
     60
    5861extern UINT_PTR waitToDumpWatchdog;
    5962
  • trunk/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.cpp

    r48420 r50973  
    290290}
    291291
    292 HRESULT STDMETHODCALLTYPE FrameLoadDelegate::didClearWindowObject(
    293     /* [in] */ IWebView*webView,
    294     /* [in] */ JSContextRef context,
    295     /* [in] */ JSObjectRef windowObject,
    296     /* [in] */ IWebFrame* frame)
    297 {
     292HRESULT FrameLoadDelegate::didClearWindowObject(IWebView*, JSContextRef, JSObjectRef, IWebFrame*)
     293{
     294    return E_NOTIMPL;
     295}
     296
     297HRESULT FrameLoadDelegate::didClearWindowObjectForFrameInScriptWorld(IWebView* webView, IWebFrame* frame, IWebScriptWorld* world)
     298{
     299    ASSERT_ARG(webView, webView);
     300    ASSERT_ARG(frame, frame);
     301    ASSERT_ARG(world, world);
     302    if (!webView || !frame || !world)
     303        return E_POINTER;
     304
     305    COMPtr<IWebScriptWorld> standardWorld;
     306    if (FAILED(world->standardWorld(&standardWorld)))
     307        return S_OK;
     308
     309    if (world == standardWorld)
     310        didClearWindowObjectForFrameInStandardWorld(frame);
     311    else
     312        didClearWindowObjectForFrameInIsolatedWorld(frame, world);
     313    return S_OK;
     314}
     315
     316void FrameLoadDelegate::didClearWindowObjectForFrameInIsolatedWorld(IWebFrame* frame, IWebScriptWorld* world)
     317{
     318    COMPtr<IWebFramePrivate> framePrivate(Query, frame);
     319    if (!framePrivate)
     320        return;
     321
     322    JSGlobalContextRef ctx = framePrivate->globalContextForScriptWorld(world);
     323    if (!ctx)
     324        return;
     325
     326    JSObjectRef globalObject = JSContextGetGlobalObject(ctx);
     327    if (!globalObject)
     328        return;
     329
     330    JSObjectSetProperty(ctx, globalObject, JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(ctx, worldIDForWorld(world)), kJSPropertyAttributeReadOnly, 0);
     331    return;
     332}
     333
     334void FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld(IWebFrame* frame)
     335{
     336    JSGlobalContextRef context = frame->globalContext();
     337    JSObjectRef windowObject = JSContextGetGlobalObject(context);
     338
    298339    JSValueRef exception = 0;
    299340
     
    311352    JSObjectSetProperty(context, windowObject, eventSenderStr, eventSender, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 0);
    312353    JSStringRelease(eventSenderStr);
    313 
    314     return S_OK;
    315354}
    316355
  • trunk/WebKitTools/DumpRenderTree/win/FrameLoadDelegate.h

    r48053 r50973  
    142142        /* [in] */ IWebSecurityOrigin *origin);
    143143
    144 protected:
     144    virtual HRESULT STDMETHODCALLTYPE didClearWindowObjectForFrameInScriptWorld(IWebView*, IWebFrame*, IWebScriptWorld*);
     145
     146private:
     147    void didClearWindowObjectForFrameInIsolatedWorld(IWebFrame*, IWebScriptWorld*);
     148    void didClearWindowObjectForFrameInStandardWorld(IWebFrame*);
     149
    145150    void locationChangeDone(IWebError*, IWebFrame*);
    146151
  • trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp

    r50943 r50973  
    956956}
    957957
     958typedef HashMap<unsigned, COMPtr<IWebScriptWorld> > WorldMap;
     959static WorldMap& worldMap()
     960{
     961    static WorldMap& map = *new WorldMap;
     962    return map;
     963}
     964
     965unsigned worldIDForWorld(IWebScriptWorld* world)
     966{
     967    WorldMap::const_iterator end = worldMap().end();
     968    for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it) {
     969        if (it->second == world)
     970            return it->first;
     971    }
     972
     973    return 0;
     974}
     975
    958976void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
    959977{
     
    969987            return;
    970988    } else {
    971         typedef HashMap<unsigned, COMPtr<IWebScriptWorld> > WorldMap;
    972         static WorldMap& worldMap = *new WorldMap;
    973         COMPtr<IWebScriptWorld>& worldSlot = worldMap.add(worldID, 0).first->second;
     989        COMPtr<IWebScriptWorld>& worldSlot = worldMap().add(worldID, 0).first->second;
    974990        if (!worldSlot && FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(worldSlot), reinterpret_cast<void**>(&worldSlot))))
    975991            return;
Note: See TracChangeset for help on using the changeset viewer.