Title: [145533] trunk
Revision
145533
Author
[email protected]
Date
2013-03-12 05:29:03 -0700 (Tue, 12 Mar 2013)

Log Message

Web Inspector: SourceFrames are leaking on reload.
https://bugs.webkit.org/show_bug.cgi?id=111961

Reviewed by Alexander Pavlov.

Source/WebCore:

Added dispose method on UISourceCodeFrame.
Scripts panel now calls dispose when SourceFrame is removed and _javascript_SourceFrame
could remove breakpoint manager listeners in it.
TabbedEditorContainer does not call viewForFile other than in appendFileTab methods to
avoid recreating SourceFrame for uiSourceCode when it was already removed.

Test: inspector/debugger/breakpoint-manager-listeners-count.html

* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.dispose):
* inspector/front-end/ScriptsPanel.js:
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer.prototype._addScrollAndSelectionListeners):
(WebInspector.TabbedEditorContainer.prototype._removeScrollAndSelectionListeners):
(WebInspector.TabbedEditorContainer.prototype._tabClosed):
* inspector/front-end/UISourceCodeFrame.js:
(WebInspector.UISourceCodeFrame.prototype.dispose):

LayoutTests:

* inspector/debugger/breakpoint-manager-listeners-count-expected.txt: Added.
* inspector/debugger/breakpoint-manager-listeners-count.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (145532 => 145533)


--- trunk/LayoutTests/ChangeLog	2013-03-12 12:27:31 UTC (rev 145532)
+++ trunk/LayoutTests/ChangeLog	2013-03-12 12:29:03 UTC (rev 145533)
@@ -1,3 +1,13 @@
+2013-03-12  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: SourceFrames are leaking on reload.
+        https://bugs.webkit.org/show_bug.cgi?id=111961
+
+        Reviewed by Alexander Pavlov.
+
+        * inspector/debugger/breakpoint-manager-listeners-count-expected.txt: Added.
+        * inspector/debugger/breakpoint-manager-listeners-count.html: Added.
+
 2013-03-12  Krzysztof Czech  <[email protected]>
 
         Unreviewed EFL gardening.

Added: trunk/LayoutTests/inspector/debugger/breakpoint-manager-listeners-count-expected.txt (0 => 145533)


--- trunk/LayoutTests/inspector/debugger/breakpoint-manager-listeners-count-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager-listeners-count-expected.txt	2013-03-12 12:29:03 UTC (rev 145533)
@@ -0,0 +1,12 @@
+Tests that scripts panel does not create too many source frames.
+
+Debugger was enabled.
+
+Running: testSourceFramesCount
+Page reloaded.
+Number of breakpoint-added event listeners is 3
+Dumping SourceFrames listening for breakpoint-added event:
+    script1.js
+    script2.js
+Debugger was disabled.
+

Added: trunk/LayoutTests/inspector/debugger/breakpoint-manager-listeners-count.html (0 => 145533)


--- trunk/LayoutTests/inspector/debugger/breakpoint-manager-listeners-count.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager-listeners-count.html	2013-03-12 12:29:03 UTC (rev 145533)
@@ -0,0 +1,58 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+function test()
+{
+    setTimeout(InspectorTest.completeTest.bind(InspectorTest), 1000);
+    InspectorTest.runDebuggerTestSuite([
+        function testSourceFramesCount(next)
+        {
+            var panel = WebInspector.panels.scripts;
+            var sourceFrameCount = 0;
+
+            InspectorTest.showScriptSource("script1.js", didShowScriptSources);
+
+            function didShowScriptSources()
+            {
+                InspectorTest.reloadPage(didReload);
+            }
+
+            function didReload()
+            {
+                InspectorTest.showScriptSource("script2.js", didShowScriptSourceAgain);
+            }
+
+            function didShowScriptSourceAgain()
+            {
+                var listeners = WebInspector.breakpointManager._listeners["breakpoint-added"];
+                // There should be 3 breakpoint-added event listeners:
+                //  - BreakpointsSidebarPane
+                //  - 2 shown tabs
+                InspectorTest.addResult("Number of breakpoint-added event listeners is " + listeners.length);
+
+                function dumpListener(listener)
+                {
+                    if (!(listener.thisObject instanceof WebInspector.SourceFrame))
+                        return;
+                    var sourceFrame = listener.thisObject;
+                    InspectorTest.addResult("    " + sourceFrame._uiSourceCode.name());
+                }
+
+                InspectorTest.addResult("Dumping SourceFrames listening for breakpoint-added event:");
+                listeners.map(dumpListener);
+
+                next();
+            }
+        }
+    ]);
+};
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests that scripts panel does not create too many source frames.</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (145532 => 145533)


--- trunk/Source/WebCore/ChangeLog	2013-03-12 12:27:31 UTC (rev 145532)
+++ trunk/Source/WebCore/ChangeLog	2013-03-12 12:29:03 UTC (rev 145533)
@@ -1,3 +1,28 @@
+2013-03-12  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: SourceFrames are leaking on reload.
+        https://bugs.webkit.org/show_bug.cgi?id=111961
+
+        Reviewed by Alexander Pavlov.
+
+        Added dispose method on UISourceCodeFrame.
+        Scripts panel now calls dispose when SourceFrame is removed and _javascript_SourceFrame
+        could remove breakpoint manager listeners in it.
+        TabbedEditorContainer does not call viewForFile other than in appendFileTab methods to 
+        avoid recreating SourceFrame for uiSourceCode when it was already removed.
+
+        Test: inspector/debugger/breakpoint-manager-listeners-count.html
+
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.dispose):
+        * inspector/front-end/ScriptsPanel.js:
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer.prototype._addScrollAndSelectionListeners):
+        (WebInspector.TabbedEditorContainer.prototype._removeScrollAndSelectionListeners):
+        (WebInspector.TabbedEditorContainer.prototype._tabClosed):
+        * inspector/front-end/UISourceCodeFrame.js:
+        (WebInspector.UISourceCodeFrame.prototype.dispose):
+
 2013-03-12  Alexander Pavlov  <[email protected]>
 
         Web Inspector: [Elements] Unable to undo "Edit as HTML" changes in the editor

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (145532 => 145533)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2013-03-12 12:27:31 UTC (rev 145532)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2013-03-12 12:29:03 UTC (rev 145533)
@@ -586,5 +586,12 @@
         WebInspector.debuggerModel.continueToLocation(rawLocation);
     },
 
+    dispose: function()
+    {
+        this._breakpointManager.removeEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this);
+        this._breakpointManager.removeEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpointRemoved, this);
+        WebInspector.UISourceCodeFrame.prototype.dispose.call(this);
+    },
+
     __proto__: WebInspector.UISourceCodeFrame.prototype
 }

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (145532 => 145533)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2013-03-12 12:27:31 UTC (rev 145532)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2013-03-12 12:29:03 UTC (rev 145533)
@@ -493,7 +493,7 @@
         if (!sourceFrame)
             return;
         this._sourceFramesByUISourceCode.remove(uiSourceCode);
-        sourceFrame.detach();
+        sourceFrame.dispose();
     },
 
     _clearCurrentExecutionLine: function()

Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (145532 => 145533)


--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2013-03-12 12:27:31 UTC (rev 145532)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2013-03-12 12:29:03 UTC (rev 145533)
@@ -110,19 +110,18 @@
 
     _addScrollAndSelectionListeners: function()
     {
-        console.assert(this._currentFile);
-        var sourceFrame = this._delegate.viewForFile(this._currentFile);
-        sourceFrame.addEventListener(WebInspector.SourceFrame.Events.ScrollChanged, this._scrollChanged, this);
-        sourceFrame.addEventListener(WebInspector.SourceFrame.Events.SelectionChanged, this._selectionChanged, this);
+        if (!this._currentView)
+            return;
+        this._currentView.addEventListener(WebInspector.SourceFrame.Events.ScrollChanged, this._scrollChanged, this);
+        this._currentView.addEventListener(WebInspector.SourceFrame.Events.SelectionChanged, this._selectionChanged, this);
     },
 
     _removeScrollAndSelectionListeners: function()
     {
-        if (!this._currentFile)
+        if (!this._currentView)
             return;
-        var sourceFrame = this._delegate.viewForFile(this._currentFile);
-        sourceFrame.removeEventListener(WebInspector.SourceFrame.Events.ScrollChanged, this._scrollChanged, this);
-        sourceFrame.removeEventListener(WebInspector.SourceFrame.Events.SelectionChanged, this._selectionChanged, this);
+        this._currentView.removeEventListener(WebInspector.SourceFrame.Events.ScrollChanged, this._scrollChanged, this);
+        this._currentView.removeEventListener(WebInspector.SourceFrame.Events.SelectionChanged, this._selectionChanged, this);
     },
 
     _scrollChanged: function(event)
@@ -156,6 +155,7 @@
         if (userGesture)
             this._editorSelectedByUserAction();
         
+        this._currentView = this.visibleView;
         this._addScrollAndSelectionListeners();
         
         this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.EditorSelected, this._currentFile);
@@ -308,6 +308,7 @@
         var uiSourceCode = this._files[tabId];
         if (this._currentFile === uiSourceCode) {
             this._removeScrollAndSelectionListeners();
+            delete this._currentView;
             delete this._currentFile;
         }
         this._tabIds.remove(uiSourceCode);

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js (145532 => 145533)


--- trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js	2013-03-12 12:27:31 UTC (rev 145532)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js	2013-03-12 12:29:03 UTC (rev 145533)
@@ -156,5 +156,10 @@
         contextMenu.appendSeparator();
     },
 
+    dispose: function()
+    {
+        this.detach();
+    },
+
     __proto__: WebInspector.SourceFrame.prototype
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to