Web Inspector: REGRESSION (Tabs): Issues reloading a resource with breakpoints
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2015 23:18:14 +0000 (23:18 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 May 2015 23:18:14 +0000 (23:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144650

Fix a number of issues with Debugger tab and navigation/reloading:
- Close old content views in the Debugger tab when main frame navigates.
- Prune old resource tree elements before attempting to restore a cookie that might match an old resource.
- Allow breakpoint selections to be restored from a saved cookie.
- Fix an assert when closing a content view that isn't the current index, but is the current view.
- Avoid calling closed() multiple times when a ContentView is in the back/forward list more than once.
- Make restoreStateFromCookie properly set and use the causedByNavigation argument for a longer restore delay.
- Create a new cookie object per tab instead of it being cumulative from the previous cookie.

Reviewed by Brian Burg.

* UserInterface/Base/Main.js:
(WebInspector._mainResourceDidChange): Delay calling _restoreCookieForOpenTabs to give time for sidebars
and tabs to respond to the main resource change.
(WebInspector._restoreCookieForOpenTabs): Rename causedByReload to causedByNavigation. Nothing special about
reload since we restore on all navigation.

* UserInterface/Views/ContentView.js:
(WebInspector.ContentView): Support Breakpoint as a represented object, which happens during a cookie restore.
(WebInspector.ContentView.isViewable): Ditto.

* UserInterface/Views/ContentViewContainer.js:
(WebInspector.ContentViewContainer.prototype.closeAllContentViews): Disassociate if the view is current and not just
the current entry index. This matches other close functions. This fixes an assert in _disassociateFromContentView.
(WebInspector.ContentViewContainer.prototype._disassociateFromContentView): Don't disassociate multiple times. This
avoids calling the closed() function on a view more than once.

* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel.prototype.saveStateToCookie):
(WebInspector.DebuggerSidebarPanel.prototype._mainResourceDidChange): Renamed from _mainResourceChanged.
Close all content views if this is the main frame. Also prune all old resources. Doing this now avoids a flash
of having old and new resources in the tree caused by the default delay in NavigationSidebarPanel's _checkForOldResources.

* UserInterface/Views/NavigationSidebarPanel.js:
(WebInspector.NavigationSidebarPanel): Set _autoPruneOldTopLevelResourceTreeElements for later.
(WebInspector.NavigationSidebarPanel.prototype.get contentTreeOutlineToAutoPrune): Deleted.
(WebInspector.NavigationSidebarPanel.prototype.showDefaultContentView): Fix typo.
(WebInspector.NavigationSidebarPanel.prototype.showDefaultContentViewForTreeElement): Fix whitespace.
(WebInspector.NavigationSidebarPanel.prototype.pruneOldResourceTreeElements): Added. Broken out from
_checkForOldResources.delayedWork so it can be called manually. Also check all visible tree outlines.
(WebInspector.NavigationSidebarPanel.prototype._treeElementAddedOrChanged): Pass treeElement in an array.
(WebInspector.NavigationSidebarPanel.prototype._checkForOldResourcesIfNeeded): Added.
(WebInspector.NavigationSidebarPanel.prototype._checkForOldResources): Call pruneOldResourceTreeElements on a delay.
(WebInspector.NavigationSidebarPanel.prototype._checkForOldResources.delayedWork): Deleted.
(WebInspector.NavigationSidebarPanel.prototype._checkOutlinesForPendingViewStateCookie): Call _checkForOldResourcesIfNeeded.
(WebInspector.NavigationSidebarPanel.prototype._checkElementsForPendingViewStateCookie): Remove array folding code.

* UserInterface/Views/TabContentView.js:
(WebInspector.TabContentView.prototype.restoreStateFromCookie): Rename causedByReload to causedByNavigation.
(WebInspector.TabContentView.prototype.saveStateToCookie): Don't allow the cookie to build on the old cookie.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/ContentView.js
Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js
Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/TabContentView.js

index 794827e..217a669 100644 (file)
@@ -1,5 +1,61 @@
 2015-05-11  Timothy Hatcher  <timothy@apple.com>
 
+        Web Inspector: REGRESSION (Tabs): Issues reloading a resource with breakpoints
+        https://bugs.webkit.org/show_bug.cgi?id=144650
+
+        Fix a number of issues with Debugger tab and navigation/reloading:
+        - Close old content views in the Debugger tab when main frame navigates.
+        - Prune old resource tree elements before attempting to restore a cookie that might match an old resource.
+        - Allow breakpoint selections to be restored from a saved cookie.
+        - Fix an assert when closing a content view that isn't the current index, but is the current view.
+        - Avoid calling closed() multiple times when a ContentView is in the back/forward list more than once.
+        - Make restoreStateFromCookie properly set and use the causedByNavigation argument for a longer restore delay.
+        - Create a new cookie object per tab instead of it being cumulative from the previous cookie.
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector._mainResourceDidChange): Delay calling _restoreCookieForOpenTabs to give time for sidebars
+        and tabs to respond to the main resource change.
+        (WebInspector._restoreCookieForOpenTabs): Rename causedByReload to causedByNavigation. Nothing special about
+        reload since we restore on all navigation.
+
+        * UserInterface/Views/ContentView.js:
+        (WebInspector.ContentView): Support Breakpoint as a represented object, which happens during a cookie restore.
+        (WebInspector.ContentView.isViewable): Ditto.
+
+        * UserInterface/Views/ContentViewContainer.js:
+        (WebInspector.ContentViewContainer.prototype.closeAllContentViews): Disassociate if the view is current and not just
+        the current entry index. This matches other close functions. This fixes an assert in _disassociateFromContentView.
+        (WebInspector.ContentViewContainer.prototype._disassociateFromContentView): Don't disassociate multiple times. This
+        avoids calling the closed() function on a view more than once.
+
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WebInspector.DebuggerSidebarPanel.prototype.saveStateToCookie):
+        (WebInspector.DebuggerSidebarPanel.prototype._mainResourceDidChange): Renamed from _mainResourceChanged.
+        Close all content views if this is the main frame. Also prune all old resources. Doing this now avoids a flash
+        of having old and new resources in the tree caused by the default delay in NavigationSidebarPanel's _checkForOldResources.
+
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WebInspector.NavigationSidebarPanel): Set _autoPruneOldTopLevelResourceTreeElements for later.
+        (WebInspector.NavigationSidebarPanel.prototype.get contentTreeOutlineToAutoPrune): Deleted.
+        (WebInspector.NavigationSidebarPanel.prototype.showDefaultContentView): Fix typo.
+        (WebInspector.NavigationSidebarPanel.prototype.showDefaultContentViewForTreeElement): Fix whitespace.
+        (WebInspector.NavigationSidebarPanel.prototype.pruneOldResourceTreeElements): Added. Broken out from
+        _checkForOldResources.delayedWork so it can be called manually. Also check all visible tree outlines.
+        (WebInspector.NavigationSidebarPanel.prototype._treeElementAddedOrChanged): Pass treeElement in an array.
+        (WebInspector.NavigationSidebarPanel.prototype._checkForOldResourcesIfNeeded): Added.
+        (WebInspector.NavigationSidebarPanel.prototype._checkForOldResources): Call pruneOldResourceTreeElements on a delay.
+        (WebInspector.NavigationSidebarPanel.prototype._checkForOldResources.delayedWork): Deleted.
+        (WebInspector.NavigationSidebarPanel.prototype._checkOutlinesForPendingViewStateCookie): Call _checkForOldResourcesIfNeeded.
+        (WebInspector.NavigationSidebarPanel.prototype._checkElementsForPendingViewStateCookie): Remove array folding code.
+
+        * UserInterface/Views/TabContentView.js:
+        (WebInspector.TabContentView.prototype.restoreStateFromCookie): Rename causedByReload to causedByNavigation.
+        (WebInspector.TabContentView.prototype.saveStateToCookie): Don't allow the cookie to build on the old cookie.
+
+2015-05-11  Timothy Hatcher  <timothy@apple.com>
+
         Web Inspector: NavigationSidebarPanel leaks some event listeners
         https://bugs.webkit.org/show_bug.cgi?id=144523
 
index 9c6d730..e893efd 100644 (file)
@@ -1125,7 +1125,9 @@ WebInspector._mainResourceDidChange = function(event)
 
     this._inProvisionalLoad = false;
 
-    this._restoreCookieForOpenTabs();
+    // Run cookie restoration after we are sure all of the Tabs and NavigationSidebarPanels
+    // have updated with respect to the main resource change.
+    setTimeout(this._restoreCookieForOpenTabs.bind(this, true));
 
     this._updateDownloadToolbarButton();
 
@@ -1142,13 +1144,13 @@ WebInspector._provisionalLoadStarted = function(event)
     this._inProvisionalLoad = true;
 };
 
-WebInspector._restoreCookieForOpenTabs = function(causedByReload)
+WebInspector._restoreCookieForOpenTabs = function(causedByNavigation)
 {
     for (var tabBarItem of this.tabBar.tabBarItems) {
         var tabContentView = tabBarItem.representedObject;
         if (!(tabContentView instanceof WebInspector.TabContentView))
             continue;
-        tabContentView.restoreStateFromCookie(causedByReload);
+        tabContentView.restoreStateFromCookie(causedByNavigation);
     }
 };
 
index 5993bfc..1a4acd0 100644 (file)
@@ -57,6 +57,11 @@ WebInspector.ContentView = function(representedObject, extraArguments)
                 return new WebInspector.RenderingFrameTimelineView(representedObject, extraArguments);
         }
 
+        if (representedObject instanceof WebInspector.Breakpoint) {
+            if (representedObject.sourceCodeLocation)
+                return new WebInspector.ContentView(representedObject.sourceCodeLocation.displaySourceCode, extraArguments);
+        }
+
         if (representedObject instanceof WebInspector.DOMStorageObject)
             return new WebInspector.DOMStorageContentView(representedObject, extraArguments);
 
@@ -147,6 +152,8 @@ WebInspector.ContentView.isViewable = function(representedObject)
         return true;
     if (representedObject instanceof WebInspector.Timeline)
         return true;
+    if (representedObject instanceof WebInspector.Breakpoint)
+        return representedObject.sourceCodeLocation;
     if (representedObject instanceof WebInspector.DOMStorageObject)
         return true;
     if (representedObject instanceof WebInspector.CookieStorageObject)
index eb3b5f3..3b5d0ad 100644 (file)
@@ -279,7 +279,7 @@ WebInspector.ContentViewContainer.prototype = {
             return;
         }
 
-        var oldCurrentContentView = this.currentContentView;
+        var visibleContentView = this.currentContentView;
 
         var backForwardListDidChange = false;
         // Hide and disassociate with all the content views that are instances of the constructor.
@@ -288,7 +288,7 @@ WebInspector.ContentViewContainer.prototype = {
             if (!(entry.contentView instanceof constructor))
                 continue;
 
-            if (entry.contentView === oldCurrentContentView)
+            if (entry.contentView === visibleContentView)
                 this._hideEntry(entry);
 
             if (this._currentIndex >= i) {
@@ -307,7 +307,7 @@ WebInspector.ContentViewContainer.prototype = {
         var currentEntry = this.currentBackForwardEntry;
         console.assert(currentEntry || (!currentEntry && this._currentIndex === -1));
 
-        if (currentEntry && currentEntry.contentView !== oldCurrentContentView || backForwardListDidChange) {
+        if (currentEntry && currentEntry.contentView !== visibleContentView || backForwardListDidChange) {
             this._showEntry(currentEntry, true);
             this.dispatchEventToListeners(WebInspector.ContentViewContainer.Event.CurrentContentViewDidChange);
         }
@@ -335,7 +335,7 @@ WebInspector.ContentViewContainer.prototype = {
             return;
         }
 
-        var oldCurrentContentView = this.currentContentView;
+        var visibleContentView = this.currentContentView;
 
         var backForwardListDidChange = false;
         // Hide and disassociate with all the content views that are the same as contentViewToClose.
@@ -344,7 +344,7 @@ WebInspector.ContentViewContainer.prototype = {
             if (entry.contentView !== contentViewToClose)
                 continue;
 
-            if (entry.contentView === oldCurrentContentView)
+            if (entry.contentView === visibleContentView)
                 this._hideEntry(entry);
 
             if (this._currentIndex >= i) {
@@ -363,7 +363,7 @@ WebInspector.ContentViewContainer.prototype = {
         var currentEntry = this.currentBackForwardEntry;
         console.assert(currentEntry || (!currentEntry && this._currentIndex === -1));
 
-        if (currentEntry && currentEntry.contentView !== oldCurrentContentView || backForwardListDidChange) {
+        if (currentEntry && currentEntry.contentView !== visibleContentView || backForwardListDidChange) {
             this._showEntry(currentEntry, true);
             this.dispatchEventToListeners(WebInspector.ContentViewContainer.Event.CurrentContentViewDidChange);
         }
@@ -376,10 +376,12 @@ WebInspector.ContentViewContainer.prototype = {
             return;
         }
 
+        var visibleContentView = this.currentContentView;
+
         // Hide and disassociate with all the content views.
         for (var i = 0; i < this._backForwardList.length; ++i) {
             var entry = this._backForwardList[i];
-            if (i === this._currentIndex)
+            if (entry.contentView === visibleContentView)
                 this._hideEntry(entry);
             this._disassociateFromContentView(entry.contentView);
         }
@@ -450,6 +452,9 @@ WebInspector.ContentViewContainer.prototype = {
     {
         console.assert(!contentView.visible);
 
+        if (!contentView._parentContainer)
+            return;
+
         contentView._parentContainer = null;
 
         var representedObject = contentView.representedObject;
index cc05a67..4cf0ddb 100644 (file)
@@ -31,7 +31,7 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
 
         this.contentBrowser = contentBrowser;
 
-        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceChanged, this);
+        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
         WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasAdded, this._resourceAdded, this);
 
         WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.BreakpointsEnabledDidChange, this._breakpointsEnabledDidChange, this);
@@ -227,11 +227,15 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
 
         var representedObject = selectedTreeElement.representedObject;
 
-        if (representedObject === WebInspector.debuggerManager.allExceptionsBreakpoint)
+        if (representedObject === WebInspector.debuggerManager.allExceptionsBreakpoint) {
             cookie[WebInspector.DebuggerSidebarPanel.SelectedAllExceptionsCookieKey] = true;
+            return;
+        }
 
-        if (representedObject === WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint)
+        if (representedObject === WebInspector.debuggerManager.allUncaughtExceptionsBreakpoint) {
             cookie[WebInspector.DebuggerSidebarPanel.SelectedAllUncaughtExceptionsCookieKey] = true;
+            return;
+        }
 
         super.saveStateToCookie(cookie);
     }
@@ -378,8 +382,16 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         this._addIssuesForSourceCode(resource);
     }
 
-    _mainResourceChanged(event)
+    _mainResourceDidChange(event)
     {
+        if (event.target.isMainFrame()) {
+            // Aggressively prune resources now so the old resources are removed before
+            // the new main resource is added below. This avoids a visual flash when the
+            // prune normally happens on a later event loop cycle.
+            this.pruneStaleResourceTreeElements();
+            this.contentBrowser.contentViewContainer.closeAllContentViews();
+        }
+
         var resource = event.target.mainResource;
         this._addTreeElementForSourceCodeToContentTreeOutline(resource);
         this._addBreakpointsForSourceCode(resource);
index 3535e49..9acee9f 100644 (file)
@@ -25,7 +25,7 @@
 
 WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebInspector.SidebarPanel
 {
-    constructor(identifier, displayName, autoPruneOldTopLevelResourceTreeElements, wantsTopOverflowShadow, element, role, label)
+    constructor(identifier, displayName, shouldAutoPruneStaleTopLevelResourceTreeElements, wantsTopOverflowShadow, element, role, label)
     {
         super(identifier, displayName, element, role, label || displayName);
 
@@ -68,10 +68,12 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         this._generateStyleRulesIfNeeded();
         this._generateDisclosureTrianglesIfNeeded();
 
-        if (autoPruneOldTopLevelResourceTreeElements) {
-            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._checkForOldResources, this);
-            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasRemoved, this._checkForOldResources, this);
-            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasRemoved, this._checkForOldResources, this);
+        this._shouldAutoPruneStaleTopLevelResourceTreeElements = shouldAutoPruneStaleTopLevelResourceTreeElements || false;
+
+        if (this._shouldAutoPruneStaleTopLevelResourceTreeElements) {
+            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._checkForStaleResources, this);
+            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasRemoved, this._checkForStaleResources, this);
+            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasRemoved, this._checkForStaleResources, this);
         }
     }
 
@@ -121,11 +123,6 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         this._updateFilter();
     }
 
-    get contentTreeOutlineToAutoPrune()
-    {
-        return this._contentTreeOutline;
-    }
-
     get visibleContentTreeOutlines()
     {
         return this._visibleContentTreeOutlines;
@@ -186,7 +183,7 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
 
     showDefaultContentView()
     {
-        // Implemneted by subclasses if needed to show a content view when no existing tree element is selected.
+        // Implemented by subclasses if needed to show a content view when no existing tree element is selected.
     }
 
     showDefaultContentViewForTreeElement(treeElement)
@@ -195,6 +192,7 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         console.assert(treeElement.representedObject);
         if (!treeElement || !treeElement.representedObject)
             return;
+
         this.contentBrowser.showContentViewForRepresentedObject(treeElement.representedObject);
         treeElement.revealAndSelect(true, false, true, true);
     }
@@ -417,6 +415,31 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         this._updateContentOverflowShadowVisibility();
     }
 
+    // Protected
+
+    pruneStaleResourceTreeElements()
+    {
+        if (this._checkForStaleResourcesTimeoutIdentifier) {
+            clearTimeout(this._checkForStaleResourcesTimeoutIdentifier);
+            this._checkForStaleResourcesTimeoutIdentifier = undefined;
+        }
+
+        for (var contentTreeOutline of this._visibleContentTreeOutlines) {
+            // Check all the ResourceTreeElements at the top level to make sure their Resource still has a parentFrame in the frame hierarchy.
+            // If the parentFrame is no longer in the frame hierarchy we know it was removed due to a navigation or some other page change and
+            // we should remove the issues for that resource.
+            for (var i = contentTreeOutline.children.length - 1; i >= 0; --i) {
+                var treeElement = contentTreeOutline.children[i];
+                if (!(treeElement instanceof WebInspector.ResourceTreeElement))
+                    continue;
+
+                var resource = treeElement.resource;
+                if (!resource.parentFrame || resource.parentFrame.isDetached())
+                    contentTreeOutline.removeChildAtIndex(i, true, true);
+            }
+        }
+    }
+
     // Private
     
     _updateContentOverflowShadowVisibilitySoon()
@@ -531,7 +554,7 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         this._updateContentOverflowShadowVisibilitySoon();
 
         if (this.selected)
-            this._checkElementsForPendingViewStateCookie(treeElement);
+            this._checkElementsForPendingViewStateCookie([treeElement]);
 
         this.treeElementAddedOrChanged(treeElement);
     }
@@ -588,36 +611,22 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         generateColoredImagesForCSS("Images/DisclosureTriangleSmallClosed.svg", specifications, 13, 13, WebInspector.NavigationSidebarPanel.DisclosureTriangleClosedCanvasIdentifier);
     }
 
-    _checkForOldResources(event)
+    _checkForStaleResourcesIfNeeded()
     {
-        if (this._checkForOldResourcesTimeoutIdentifier)
+        if (!this._checkForStaleResourcesTimeoutIdentifier || !this._shouldAutoPruneStaleTopLevelResourceTreeElements)
             return;
+        this.pruneStaleResourceTreeElements();
+    }
 
-        function delayedWork()
-        {
-            delete this._checkForOldResourcesTimeoutIdentifier;
-
-            var contentTreeOutline = this.contentTreeOutlineToAutoPrune;
-
-            // Check all the ResourceTreeElements at the top level to make sure their Resource still has a parentFrame in the frame hierarchy.
-            // If the parentFrame is no longer in the frame hierarchy we know it was removed due to a navigation or some other page change and
-            // we should remove the issues for that resource.
-            for (var i = contentTreeOutline.children.length - 1; i >= 0; --i) {
-                var treeElement = contentTreeOutline.children[i];
-                if (!(treeElement instanceof WebInspector.ResourceTreeElement))
-                    continue;
-
-                var resource = treeElement.resource;
-                if (!resource.parentFrame || resource.parentFrame.isDetached())
-                    contentTreeOutline.removeChildAtIndex(i, true, true);
-            }
+    _checkForStaleResources(event)
+    {
+        console.assert(this._shouldAutoPruneStaleTopLevelResourceTreeElements);
 
-            if (typeof this._updateEmptyContentPlaceholder === "function")
-                this._updateEmptyContentPlaceholder();
-        }
+        if (this._checkForStaleResourcesTimeoutIdentifier)
+            return;
 
-        // Check on a delay to coalesce multiple calls to _checkForOldResources.
-        this._checkForOldResourcesTimeoutIdentifier = setTimeout(delayedWork.bind(this), 0);
+        // Check on a delay to coalesce multiple calls to _checkForStaleResources.
+        this._checkForStaleResourcesTimeoutIdentifier = setTimeout(this.pruneStaleResourceTreeElements.bind(this));
     }
 
     _isTreeElementWithoutRepresentedObject(treeElement)
@@ -633,6 +642,8 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
         if (!this._pendingViewStateCookie)
             return;
 
+        this._checkForStaleResourcesIfNeeded();
+
         var visibleTreeElements = [];
         this._visibleContentTreeOutlines.forEach(function(outline) {
             var currentTreeElement = outline.hasChildren ? outline.children[0] : null;
@@ -678,9 +689,6 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
             });
         }
 
-        if (!(treeElements instanceof Array))
-            treeElements = [treeElements];
-
         var matchedElement = null;
         treeElements.some(function(element) {
             if (treeElementMatchesCookie.call(this, element)) {
index 2d8df17..02207b9 100644 (file)
@@ -107,15 +107,15 @@ WebInspector.TabContentView.prototype = {
         return false;
     },
 
-    restoreStateFromCookie: function(causedByReload)
+    restoreStateFromCookie: function(causedByNavigation)
     {
         if (!this.navigationSidebarPanel)
             return;
 
-        var matchTypeOnlyDelayForReload = 2000;
+        var matchTypeOnlyDelayForNavigation = 2000;
         var matchTypeOnlyDelayForReopen = 1000;
 
-        var relaxMatchDelay = causedByReload ? matchTypeOnlyDelayForReload : matchTypeOnlyDelayForReopen;
+        var relaxMatchDelay = causedByNavigation ? matchTypeOnlyDelayForNavigation : matchTypeOnlyDelayForReopen;
         this.navigationSidebarPanel.restoreStateFromCookie(this._cookieSetting.value || {}, relaxMatchDelay);
     },
 
@@ -124,7 +124,7 @@ WebInspector.TabContentView.prototype = {
         if (!this.navigationSidebarPanel)
             return;
 
-        var cookie = this._cookieSetting.value || {};
+        var cookie = {};
         this.navigationSidebarPanel.saveStateToCookie(cookie);
         this._cookieSetting.value = cookie;
     },