Web Inspector: get rid of Panel::reset in the front-end.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Nov 2011 13:37:06 +0000 (13:37 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Nov 2011 13:37:06 +0000 (13:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72587

I'm slowly getting rid of the Inspector protocol domain. It currently
contains methods that did not find their home in the meaningful domains.
This change removes reset protocol method.

Reviewed by Yury Semikhatsky.

* inspector/Inspector.json:
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::didCommitLoad):
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::didClearMainFrameWindowObject):
* inspector/InspectorDebuggerAgent.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
* inspector/front-end/ApplicationCacheModel.js:
(WebInspector.ApplicationCacheModel.prototype._frameNavigated):
(WebInspector.ApplicationCacheModel.prototype._frameDetached):
* inspector/front-end/DebuggerModel.js:
(WebInspector.DebuggerModel.prototype._globalObjectCleared):
(WebInspector.DebuggerDispatcher.prototype.globalObjectCleared):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
* inspector/front-end/ExtensionServer.js:
(WebInspector.ExtensionServer):
(WebInspector.ExtensionServer.prototype._mainFrameNavigated):
* inspector/front-end/JavaScriptContextManager.js:
(WebInspector.JavaScriptContextManager.prototype._frameDetached):
(WebInspector.FrameEvaluationContext.prototype.get frameId):
* inspector/front-end/NetworkLog.js:
(WebInspector.NetworkLog):
(WebInspector.NetworkLog.prototype._mainFrameNavigated):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView):
(WebInspector.NetworkLogView.prototype._mainFrameNavigated):
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype._frameNavigated):
(WebInspector.ResourceTreeModel.prototype._frameDetached):
(WebInspector.ResourceTreeModel.prototype._clearChildFramesAndResources):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype._reset):
(WebInspector.ResourcesPanel.prototype._frameDetached):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._debuggerWasDisabled):
(WebInspector.ScriptsPanel.prototype._reset):
* inspector/front-end/WorkerManager.js:
(WebInspector.WorkerManager):
(WebInspector.WorkerManager.prototype._mainFrameNavigated):
* inspector/front-end/inspector.js:

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/front-end/ApplicationCacheModel.js
Source/WebCore/inspector/front-end/DebuggerModel.js
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/JavaScriptContextManager.js
Source/WebCore/inspector/front-end/NetworkLog.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Object.js
Source/WebCore/inspector/front-end/ResourceTreeModel.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/WorkerManager.js
Source/WebCore/inspector/front-end/inspector.js

index 2237a5e..4f73c66 100644 (file)
@@ -1,3 +1,59 @@
+2011-11-18  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: get rid of Panel::reset in the front-end.
+        https://bugs.webkit.org/show_bug.cgi?id=72587
+
+        I'm slowly getting rid of the Inspector protocol domain. It currently
+        contains methods that did not find their home in the meaningful domains.
+        This change removes reset protocol method.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/Inspector.json:
+        * inspector/InspectorAgent.cpp:
+        (WebCore::InspectorAgent::didCommitLoad):
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::didClearMainFrameWindowObject):
+        * inspector/InspectorDebuggerAgent.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):
+        (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+        * inspector/front-end/ApplicationCacheModel.js:
+        (WebInspector.ApplicationCacheModel.prototype._frameNavigated):
+        (WebInspector.ApplicationCacheModel.prototype._frameDetached):
+        * inspector/front-end/DebuggerModel.js:
+        (WebInspector.DebuggerModel.prototype._globalObjectCleared):
+        (WebInspector.DebuggerDispatcher.prototype.globalObjectCleared):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer):
+        (WebInspector.ExtensionServer.prototype._mainFrameNavigated):
+        * inspector/front-end/JavaScriptContextManager.js:
+        (WebInspector.JavaScriptContextManager.prototype._frameDetached):
+        (WebInspector.FrameEvaluationContext.prototype.get frameId):
+        * inspector/front-end/NetworkLog.js:
+        (WebInspector.NetworkLog):
+        (WebInspector.NetworkLog.prototype._mainFrameNavigated):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView):
+        (WebInspector.NetworkLogView.prototype._mainFrameNavigated):
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel.prototype._frameNavigated):
+        (WebInspector.ResourceTreeModel.prototype._frameDetached):
+        (WebInspector.ResourceTreeModel.prototype._clearChildFramesAndResources):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype._reset):
+        (WebInspector.ResourcesPanel.prototype._frameDetached):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._debuggerWasDisabled):
+        (WebInspector.ScriptsPanel.prototype._reset):
+        * inspector/front-end/WorkerManager.js:
+        (WebInspector.WorkerManager):
+        (WebInspector.WorkerManager.prototype._mainFrameNavigated):
+        * inspector/front-end/inspector.js:
+
 2011-06-20  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: introduce InspectorFrontendAPI for actions initiated from the application menu.
index a43f6c3..9e8a964 100644 (file)
@@ -17,9 +17,6 @@
                 "name": "disconnectFromBackend"
             },
             {
-                "name": "reset"
-            },
-            {
                 "name": "showPanel",
                 "parameters": [
                     { "name": "panel", "type": "string" }
                 "hidden": true
             },
             {
+                "name": "globalObjectCleared",
+                "description": "Called when global has been cleared and debugger client should reset its state. Happens upon navigation or reload."
+            },
+            {
                 "name": "scriptParsed",
                 "parameters": [
                     { "name": "scriptId", "$ref": "ScriptId", "description": "Identifier of the script parsed." },
index e33ec9b..7e1554c 100644 (file)
@@ -136,9 +136,6 @@ void InspectorAgent::clearFrontend()
 void InspectorAgent::didCommitLoad()
 {
     m_didCommitLoadFired = true;
-    if (m_frontend)
-        m_frontend->inspector()->reset();
-
     m_injectedScriptManager->discardInjectedScripts();
 #if ENABLE(WORKERS)
     m_workers.clear();
index e18205c..f725da8 100644 (file)
@@ -164,10 +164,12 @@ void InspectorDebuggerAgent::setBreakpointsActive(ErrorString*, bool active)
         scriptDebugServer().deactivateBreakpoints();
 }
 
-void InspectorDebuggerAgent::inspectedURLChanged(const String&)
+void InspectorDebuggerAgent::didClearMainFrameWindowObject()
 {
     m_scripts.clear();
     m_breakpointIdToDebugServerBreakpointIds.clear();
+    if (m_frontend)
+        m_frontend->globalObjectCleared();
 }
 
 static PassRefPtr<InspectorObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex)
index 2118a1e..fe8f42c 100644 (file)
@@ -72,7 +72,7 @@ public:
     void setFrontend(InspectorFrontend*);
     void clearFrontend();
 
-    void inspectedURLChanged(const String& url);
+    void didClearMainFrameWindowObject();
 
     // Part of the protocol.
     void setBreakpointsActive(ErrorString*, bool active);
index bd2b9e5..4cb8dc7 100644 (file)
@@ -93,10 +93,17 @@ static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window,
 
 void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents* instrumentingAgents, Frame* frame, DOMWrapperWorld* world)
 {
-    if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
+    InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent();
+    if (pageAgent)
         pageAgent->didClearWindowObjectInWorld(frame, world);
     if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
         inspectorAgent->didClearWindowObjectInWorld(frame, world);
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent()) {
+        if (pageAgent && world == mainThreadNormalWorld() && frame == pageAgent->mainFrame())
+            debuggerAgent->didClearMainFrameWindowObject();
+    }
+#endif
 }
 
 void InspectorInstrumentation::inspectedPageDestroyedImpl(InstrumentingAgents* instrumentingAgents)
@@ -638,13 +645,6 @@ void InspectorInstrumentation::didCommitLoadImpl(InstrumentingAgents* instrument
 
         if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
             resourceAgent->mainFrameNavigated(loader);
-
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-        if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents->inspectorDebuggerAgent()) {
-            KURL url = inspectorAgent->inspectedURLWithoutFragment();
-            debuggerAgent->inspectedURLChanged(url);
-        }
-#endif
 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
         if (InspectorProfilerAgent* profilerAgent = instrumentingAgents->inspectorProfilerAgent()) {
             profilerAgent->stopUserInitiatedProfiling(true);
index 6570fa3..a8090e1 100644 (file)
@@ -56,7 +56,7 @@ WebInspector.ApplicationCacheModel.EventTypes = {
 WebInspector.ApplicationCacheModel.prototype = {
     _frameNavigated: function(event)
     {
-        if (event.data.isMainFrame) {
+        if (event.data["isMainFrame"]) {
             this._mainFrameNavigated();
             return;
         }
@@ -68,8 +68,8 @@ WebInspector.ApplicationCacheModel.prototype = {
     
     _frameDetached: function(event)
     {
-        var frameId = event.data;
-        this._frameManifestRemoved(frameId);
+        var frame = event.data;
+        this._frameManifestRemoved(frame.id);
     },
     
     _mainFrameNavigated: function()
index cb35d9b..f6cf51e 100644 (file)
@@ -74,7 +74,7 @@ WebInspector.DebuggerModel.Events = {
     ParsedScriptSource: "parsed-script-source",
     FailedToParseScriptSource: "failed-to-parse-script-source",
     BreakpointResolved: "breakpoint-resolved",
-    Reset: "reset"
+    GlobalObjectCleared: "global-object-cleared"
 }
 
 WebInspector.DebuggerModel.BreakReason = {
@@ -218,11 +218,11 @@ WebInspector.DebuggerModel.prototype = {
         this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, {breakpointId: breakpointId, location: location});
     },
 
-    reset: function()
+    _globalObjectCleared: function()
     {
         this._debuggerPausedDetails = null;
         this._scripts = {};
-        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Reset);
+        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalObjectCleared);
     },
 
     /**
@@ -395,6 +395,11 @@ WebInspector.DebuggerDispatcher.prototype = {
         this._debuggerModel._debuggerWasDisabled();
     },
 
+    globalObjectCleared: function()
+    {
+        this._debuggerModel._globalObjectCleared();
+    },
+
     /**
      * @param {DebuggerAgent.ScriptId} scriptId
      * @param {string} sourceURL
index b53435e..b42558e 100644 (file)
@@ -47,7 +47,7 @@ WebInspector.DebuggerPresentationModel = function()
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._failedToParseScriptSource, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed, this._debuggerResumed, this);
-    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Reset, this._debuggerReset, this);
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
 
     WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);
     WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
@@ -65,6 +65,7 @@ WebInspector.DebuggerPresentationModel.Events = {
     BreakpointRemoved: "breakpoint-removed",
     DebuggerPaused: "debugger-paused",
     DebuggerResumed: "debugger-resumed",
+    DebuggerReset: "debugger-reset",
     CallFrameSelected: "call-frame-selected",
     ConsoleCommandEvaluatedInSelectedCallFrame: "console-command-evaluated-in-selected-call-frame",
     ExecutionLineChanged: "execution-line-changed"
@@ -658,6 +659,7 @@ WebInspector.DebuggerPresentationModel.prototype = {
         this._presentationCallFrames = [];
         this._selectedCallFrame = null;
         this._breakpointManager.debuggerReset();
+        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerReset);
     }
 }
 
index d10ab0a..e4f8ca3 100644 (file)
@@ -105,7 +105,7 @@ WebInspector.ExtensionServer.prototype = {
         this._postNotification("inspectedURLChanged", url);
     },
 
-    notifyInspectorReset: function()
+    _mainFrameNavigated: function(event)
     {
         this._postNotification("reset");
     },
@@ -548,6 +548,7 @@ WebInspector.ExtensionServer.prototype = {
 
         WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged,
             this._inspectedURLChanged, this);
+        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
         InspectorExtensionRegistry.getExtensionsAsync();
     },
 
index 8f6643c..37fbcba 100644 (file)
@@ -61,12 +61,12 @@ WebInspector.JavaScriptContextManager.prototype = {
 
     _frameDetached: function(event)
     {
-        var frameId = event.data;
-        var context = this._frameIdToContext[frameId];
+        var frame = event.data;
+        var context = this._frameIdToContext[frame.id];
         if (!context)
             return;
         this._consoleView.removeContext(context);
-        delete this._frameIdToContext[frameId];
+        delete this._frameIdToContext[frame.id];
     },
 }
 
@@ -95,7 +95,7 @@ WebInspector.FrameEvaluationContext.prototype =
 
     get frameId()
     {
-        return this._frame.id
+        return this._frame.id;
     },
 
     get url()
index 7438a6e..72881e7 100644 (file)
@@ -35,7 +35,7 @@ WebInspector.NetworkLog = function()
 {
     this._resources = [];
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this);
-    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
 }
 
 WebInspector.NetworkLog.prototype = {
@@ -47,10 +47,8 @@ WebInspector.NetworkLog.prototype = {
         return this._resources;
     },
 
-    _frameNavigated: function(event)
+    _mainFrameNavigated: function(event)
     {
-        if (!event.data.isMainFrame)
-            return;
         // Preserve resources from the new session.
         var oldResources = this._resources.splice(0, this._resources.length);
         for (var i = 0; i < oldResources.length; ++i) {
index 58d6a03..26ef4a0 100644 (file)
@@ -61,7 +61,7 @@ WebInspector.NetworkLogView = function()
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this);
     WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this);
 
-    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.OnLoad, this._onLoadEventFired, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.DOMContentLoaded, this._domContentLoadedEventFired, this);
 
@@ -794,11 +794,8 @@ WebInspector.NetworkLogView.prototype = {
         this._reset();
     },
 
-    _frameNavigated: function(event)
+    _mainFrameNavigated: function(event)
     {
-        if (!event.data.isMainFrame)
-            return;
-
         var loaderId = event.data.loaderId;
         // Main frame committed load.
         if (this._preserveLogToggle.toggled)
index 74e419b..e3dab8e 100644 (file)
@@ -37,6 +37,8 @@ WebInspector.Object.prototype = {
      */
     addEventListener: function(eventType, listener, thisObject)
     {
+        console.assert(listener);
+
         if (!this._listeners)
             this._listeners = {};
         if (!this._listeners[eventType])
@@ -51,6 +53,8 @@ WebInspector.Object.prototype = {
      */
     removeEventListener: function(eventType, listener, thisObject)
     {
+        console.assert(listener);
+
         if (!this._listeners || !this._listeners[eventType])
             return;
         var listeners = this._listeners[eventType];
index 397b309..ca2ac78 100644 (file)
@@ -54,6 +54,7 @@ WebInspector.ResourceTreeModel.EventTypes = {
     FrameAdded: "FrameAdded",
     FrameNavigated: "FrameNavigated",
     FrameDetached: "FrameDetached",
+    MainFrameNavigated: "MainFrameNavigated",
     ResourceAdded: "ResourceAdded",
     WillLoadCachedResources: "WillLoadCachedResources",
     CachedResourcesLoaded: "CachedResourcesLoaded",
@@ -151,6 +152,8 @@ WebInspector.ResourceTreeModel.prototype = {
         }
         // Dispatch frame navigated event to clients prior to filling it with the resources.
         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, { frame: frame, loaderId: loaderId, isMainFrame: isMainFrame });
+        if (isMainFrame)
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, { frame: frame, loaderId: loaderId });
 
         // Fill frame with retained resources (the ones loaded using new loader).
         var resourcesForFrame = this._resourcesByFrameId[frame.id];
@@ -186,7 +189,7 @@ WebInspector.ResourceTreeModel.prototype = {
             delete this._frameIds[frameId];
         }
 
-        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, frameId);
+        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, frame);
     },
 
     _onResourceStarted: function(event)
@@ -309,7 +312,7 @@ WebInspector.ResourceTreeModel.prototype = {
         this._clearResources(frameId, loaderToPreserveId);
         var subframes = this._subframes[frameId];
         for (var i = 0; subframes && i < subframes.length; ++ i) {
-            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, subframes[i].id);
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, subframes[i]);
             this._clearChildFramesAndResources(subframes[i].id, loaderToPreserveId);
         }
         delete this._subframes[frameId];
index b2e3e13..5200ed6 100644 (file)
@@ -142,7 +142,7 @@ WebInspector.ResourcesPanel.prototype = {
             this.showResource(WebInspector.mainResource);
     },
 
-    reset: function()
+    _reset: function()
     {
         this.resourcesListTreeElement.removeChildren();
         this._treeElementForFrameId = {};
@@ -189,7 +189,7 @@ WebInspector.ResourcesPanel.prototype = {
         WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
         WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
         WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._cachedResourcesLoaded, this);
-        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this.reset, this);
+        WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this._reset, this);
 
         function populateFrame(frameId)
         {
@@ -224,12 +224,17 @@ WebInspector.ResourcesPanel.prototype = {
 
     _frameDetached: function(event)
     {
-        var frameId = event.data;
-        var frameTreeElement = this._treeElementForFrameId[frameId];
+        var frame = event.data;
+        if (!frame.parentId) {
+            // Reset on main frame detach
+            this._reset();
+        }
+
+        var frameTreeElement = this._treeElementForFrameId[frame.id];
         if (!frameTreeElement)
             return;
 
-        delete this._treeElementForFrameId[frameId];
+        delete this._treeElementForFrameId[frame.id];
         if (frameTreeElement.parent)
             frameTreeElement.parent.removeChild(frameTreeElement);
     },
index 7c44ffc..053b815 100644 (file)
@@ -165,7 +165,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
 
     this._debuggerEnabled = Preferences.debuggerAlwaysEnabled;
 
-    this.reset();
+    this._reset(false);
 
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._debuggerWasEnabled, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._debuggerWasDisabled, this);
@@ -182,6 +182,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, this._callFrameSelected, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSelectedCallFrame, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ExecutionLineChanged, this._executionLineChanged, this);
+    this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerReset, this._reset.bind(this, false));
     
     var enableDebugger = Preferences.debuggerAlwaysEnabled || WebInspector.settings.debuggerEnabled.get();
     if (enableDebugger)
@@ -526,7 +527,7 @@ WebInspector.ScriptsPanel.prototype = {
             return;
 
         this._debuggerEnabled = true;
-        this.reset(true);
+        this._reset(true);
     },
 
     _debuggerWasDisabled: function()
@@ -535,10 +536,10 @@ WebInspector.ScriptsPanel.prototype = {
             return;
 
         this._debuggerEnabled = false;
-        this.reset(true);
+        this._reset(true);
     },
 
-    reset: function(preserveItems)
+    _reset: function(preserveItems)
     {
         this.visibleView = null;
 
index 61ec644..0562112 100644 (file)
@@ -67,6 +67,8 @@ WebInspector.WorkerManager.loadCompleted = function()
     {
         WebInspector.WorkerManager._calculateWorkerInspectorTitle();
     }
+
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, WebInspector.workerManager._mainFrameNavigated, WebInspector.workerManager);
 }
 
 WebInspector.WorkerManager._initializeDedicatedWorkerFrontend = function(workerId)
@@ -179,7 +181,7 @@ WebInspector.WorkerManager.prototype = {
             workerInspectorWindow.close();
     },
 
-    reset: function()
+    _mainFrameNavigated: function(event)
     {
         for (var workerId in this._workerIdToWindow)
             this.closeWorkerInspector(workerId);
index 32e4dcf..578c798 100644 (file)
@@ -671,24 +671,6 @@ WebInspector.startUserInitiatedDebugging = function()
     WebInspector.debuggerModel.enableDebugger();
 }
 
-WebInspector.reset = function()
-{
-    this.debuggerModel.reset();
-    for (var panelName in this.panels) {
-        var panel = this.panels[panelName];
-        if ("reset" in panel)
-            panel.reset();
-    }
-
-    this.domAgent.hideDOMNodeHighlight();
-
-    if (!WebInspector.settings.preserveConsoleLog.get())
-        this.console.clearMessages();
-    this.extensionServer.notifyInspectorReset();
-    if (this.workerManager)
-        this.workerManager.reset();
-}
-
 WebInspector.bringToFront = function()
 {
     InspectorFrontendHost.bringToFront();