Make the Web Inspector's JavaScript debugger work with isolated worlds.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jan 2010 23:38:24 +0000 (23:38 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jan 2010 23:38:24 +0000 (23:38 +0000)
Console evaluation is not performed in the correct world yet, tracked
by bug http://webkit.org/b/33692.

http://webkit.org/b/33690

Reviewed by Adam Roben.

* bindings/js/ScriptCachedFrameData.cpp:
(WebCore::ScriptCachedFrameData::restore): Attach the debugger to
any window shell, not just for the debugger world.
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::clearWindowShell): Detach the debugger, and
reattach to all window shells, not just for the debugger world.
(WebCore::ScriptController::initScript): Attach the debugger to
any window shell, not just for the debugger world.
(WebCore::ScriptController::attachDebugger): Changed to loop through
all the window shells and call the new overloaded attachDebugger.
(WebCore::ScriptController::attachDebugger): Added. An overload that
takes a window shell to attach the debugger to. Has most of the
logic from the original attachDebugger.
* bindings/js/ScriptController.h: Added the new attachDebugger.

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

WebCore/ChangeLog
WebCore/bindings/js/ScriptCachedFrameData.cpp
WebCore/bindings/js/ScriptController.cpp
WebCore/bindings/js/ScriptController.h

index 1788ad6..29b12eb 100644 (file)
@@ -1,3 +1,28 @@
+2010-01-14  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector's JavaScript debugger work with isolated worlds.
+        Console evaluation is not performed in the correct world yet, tracked
+        by bug http://webkit.org/b/33692.
+
+        http://webkit.org/b/33690
+
+        Reviewed by Adam Roben.
+
+        * bindings/js/ScriptCachedFrameData.cpp:
+        (WebCore::ScriptCachedFrameData::restore): Attach the debugger to
+        any window shell, not just for the debugger world.
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::clearWindowShell): Detach the debugger, and
+        reattach to all window shells, not just for the debugger world.
+        (WebCore::ScriptController::initScript): Attach the debugger to
+        any window shell, not just for the debugger world.
+        (WebCore::ScriptController::attachDebugger): Changed to loop through
+        all the window shells and call the new overloaded attachDebugger.
+        (WebCore::ScriptController::attachDebugger): Added. An overload that
+        takes a window shell to attach the debugger to. Has most of the
+        logic from the original attachDebugger.
+        * bindings/js/ScriptController.h: Added the new attachDebugger.
+
 2010-01-14  Adam Roben  <aroben@apple.com>
 
         Make Cache::requestResource return 0 if the resource's load fails
 2010-01-14  Adam Roben  <aroben@apple.com>
 
         Make Cache::requestResource return 0 if the resource's load fails
index f2b64de..16f18d3 100644 (file)
@@ -73,8 +73,6 @@ ScriptCachedFrameData::~ScriptCachedFrameData()
 
 void ScriptCachedFrameData::restore(Frame* frame)
 {
 
 void ScriptCachedFrameData::restore(Frame* frame)
 {
-    Page* page = frame->page();
-
     JSLock lock(SilenceAssertionsOnly);
 
     ScriptController* scriptController = frame->script();
     JSLock lock(SilenceAssertionsOnly);
 
     ScriptController* scriptController = frame->script();
@@ -89,8 +87,9 @@ void ScriptCachedFrameData::restore(Frame* frame)
             windowShell->setWindow(window);
         else {
             windowShell->setWindow(frame->domWindow());
             windowShell->setWindow(window);
         else {
             windowShell->setWindow(frame->domWindow());
-            if (world == debuggerWorld()) {
-                scriptController->attachDebugger(page->debugger());
+
+            if (Page* page = frame->page()) {
+                scriptController->attachDebugger(windowShell, page->debugger());
                 windowShell->window()->setProfileGroup(page->group().identifier());
             }
         }
                 windowShell->window()->setProfileGroup(page->group().identifier());
             }
         }
index bfdcaaf..995d2d4 100644 (file)
@@ -183,19 +183,17 @@ void ScriptController::clearWindowShell()
 
     JSLock lock(SilenceAssertionsOnly);
 
 
     JSLock lock(SilenceAssertionsOnly);
 
-    // Clear the debugger from the current window before setting the new window.
-    DOMWrapperWorld* debugWorld = debuggerWorld();
-    attachDebugger(0);
-
     for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) {
     for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) {
-        DOMWrapperWorld* world = iter->first.get();
         JSDOMWindowShell* windowShell = iter->second;
         JSDOMWindowShell* windowShell = iter->second;
+
+        // Clear the debugger from the current window before setting the new window.
+        attachDebugger(windowShell, 0);
+
         windowShell->window()->willRemoveFromWindowShell();
         windowShell->setWindow(m_frame->domWindow());
 
         if (Page* page = m_frame->page()) {
         windowShell->window()->willRemoveFromWindowShell();
         windowShell->setWindow(m_frame->domWindow());
 
         if (Page* page = m_frame->page()) {
-            if (world == debugWorld)
-                attachDebugger(page->debugger());
+            attachDebugger(windowShell, page->debugger());
             windowShell->window()->setProfileGroup(page->group().identifier());
         }
     }
             windowShell->window()->setProfileGroup(page->group().identifier());
         }
     }
@@ -215,8 +213,7 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
     windowShell->window()->updateDocument();
 
     if (Page* page = m_frame->page()) {
     windowShell->window()->updateDocument();
 
     if (Page* page = m_frame->page()) {
-        if (world == debuggerWorld())
-            attachDebugger(page->debugger());
+        attachDebugger(windowShell, page->debugger());
         windowShell->window()->setProfileGroup(page->group().identifier());
     }
 
         windowShell->window()->setProfileGroup(page->group().identifier());
     }
 
@@ -293,8 +290,12 @@ bool ScriptController::anyPageIsProcessingUserGesture() const
 
 void ScriptController::attachDebugger(JSC::Debugger* debugger)
 {
 
 void ScriptController::attachDebugger(JSC::Debugger* debugger)
 {
-    // FIXME: Should be able to debug isolated worlds.
-    JSDOMWindowShell* shell = existingWindowShell(debuggerWorld());
+    for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
+        attachDebugger(iter->second, debugger);
+}
+
+void ScriptController::attachDebugger(JSDOMWindowShell* shell, JSC::Debugger* debugger)
+{
     if (!shell)
         return;
 
     if (!shell)
         return;
 
index 35ec028..f3e5adf 100644 (file)
@@ -112,7 +112,9 @@ public:
 
     bool canExecuteScripts();
 
 
     bool canExecuteScripts();
 
-    void attachDebugger(JSC::Debugger*);
+    // Debugger can be 0 to detach any existing Debugger.
+    void attachDebugger(JSC::Debugger*); // Attaches/detaches in all worlds/window shells.
+    void attachDebugger(JSDOMWindowShell*, JSC::Debugger*);
 
     void setPaused(bool b) { m_paused = b; }
     bool isPaused() const { return m_paused; }
 
     void setPaused(bool b) { m_paused = b; }
     bool isPaused() const { return m_paused; }