Title: [143923] trunk
Revision
143923
Author
[email protected]
Date
2013-02-25 07:22:39 -0800 (Mon, 25 Feb 2013)

Log Message

Web Inspector: Remove CPU profile from a group causes exception
https://bugs.webkit.org/show_bug.cgi?id=110466

Patch by Alexei Filippov <[email protected]> on 2013-02-25
Reviewed by Yury Semikhatsky.

WebInspector.ProfilesPanel._removeProfileHandle did not handle
profile removal from a group. The fix takes care of this case.

Test: inspector/profiler/cpu-profiler-profile-removal.html

Source/WebCore:

* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype.addProfileHeader):
(WebInspector.ProfilesPanel.prototype._removeProfileHeader):

LayoutTests:

* inspector/profiler/cpu-profiler-profile-removal-expected.txt: Added.
* inspector/profiler/cpu-profiler-profile-removal.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (143922 => 143923)


--- trunk/LayoutTests/ChangeLog	2013-02-25 15:15:06 UTC (rev 143922)
+++ trunk/LayoutTests/ChangeLog	2013-02-25 15:22:39 UTC (rev 143923)
@@ -1,3 +1,18 @@
+2013-02-25  Alexei Filippov  <[email protected]>
+
+        Web Inspector: Remove CPU profile from a group causes exception
+        https://bugs.webkit.org/show_bug.cgi?id=110466
+
+        Reviewed by Yury Semikhatsky.
+
+        WebInspector.ProfilesPanel._removeProfileHandle did not handle
+        profile removal from a group. The fix takes care of this case.
+
+        Test: inspector/profiler/cpu-profiler-profile-removal.html
+
+        * inspector/profiler/cpu-profiler-profile-removal-expected.txt: Added.
+        * inspector/profiler/cpu-profiler-profile-removal.html: Added.
+
 2013-02-25  Mike West  <[email protected]>
 
         XSSAuditor tests shouldn't depend on IFrames's load order.

Added: trunk/LayoutTests/inspector/profiler/cpu-profiler-profile-removal-expected.txt (0 => 143923)


--- trunk/LayoutTests/inspector/profiler/cpu-profiler-profile-removal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/profiler/cpu-profiler-profile-removal-expected.txt	2013-02-25 15:22:39 UTC (rev 143923)
@@ -0,0 +1,7 @@
+Tests that CPU profile removal from a group works. Bug 110466
+
+Profiler was enabled.
+Profile groups after removal:
+
+Profiler was disabled.
+

Added: trunk/LayoutTests/inspector/profiler/cpu-profiler-profile-removal.html (0 => 143923)


--- trunk/LayoutTests/inspector/profiler/cpu-profiler-profile-removal.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/profiler/cpu-profiler-profile-removal.html	2013-02-25 15:22:39 UTC (rev 143923)
@@ -0,0 +1,46 @@
+<html>
+<head>
+  <script src=""
+  <script src=""
+<script>
+
+function pageFunction() {
+    console.profile("p1");
+    console.profileEnd("p1");
+    console.profile("p1");
+    console.profileEnd("p1");
+    console.profile("p2");
+    console.profileEnd("p2");
+}
+
+function test()
+{
+    InspectorTest.startProfilerTest(function() {
+        function viewLoaded(view) {
+            var profiles = WebInspector.panels.profiles;
+            var type = profiles.getProfileType("CPU");
+            while (type.getProfiles().length !== 0)
+                profiles._removeProfileHeader(type.getProfiles()[0]);
+            InspectorTest.addResult("Profile groups after removal:");
+            for (var key in profiles._profileGroups)
+                InspectorTest.addResult(key + ": " + profiles._profileGroups[key].length);
+            InspectorTest.assertEquals(0, type.treeElement.children.length, "All children has been removed");
+            InspectorTest.completeProfilerTest();
+        }
+        WebInspector.showPanel("profiles");
+        InspectorTest.evaluateInConsole("pageFunction()", function() {});
+        InspectorTest.showProfileWhenAdded("p2");
+        InspectorTest.waitUntilProfileViewIsShown("p2", viewLoaded);
+    });
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>
+Tests that CPU profile removal from a group works.
+
+<a href="" 110466</a>
+</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (143922 => 143923)


--- trunk/Source/WebCore/ChangeLog	2013-02-25 15:15:06 UTC (rev 143922)
+++ trunk/Source/WebCore/ChangeLog	2013-02-25 15:22:39 UTC (rev 143923)
@@ -1,3 +1,19 @@
+2013-02-25  Alexei Filippov  <[email protected]>
+
+        Web Inspector: Remove CPU profile from a group causes exception
+        https://bugs.webkit.org/show_bug.cgi?id=110466
+
+        Reviewed by Yury Semikhatsky.
+
+        WebInspector.ProfilesPanel._removeProfileHandle did not handle
+        profile removal from a group. The fix takes care of this case.
+
+        Test: inspector/profiler/cpu-profiler-profile-removal.html
+
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.addProfileHeader):
+        (WebInspector.ProfilesPanel.prototype._removeProfileHeader):
+
 2013-02-23  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: Native Memory Instrumentation: replace String with const char* in MemoryObjectInfo

Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (143922 => 143923)


--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js	2013-02-25 15:15:06 UTC (rev 143922)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js	2013-02-25 15:22:39 UTC (rev 143923)
@@ -640,7 +640,7 @@
         var small = false;
         var alternateTitle;
 
-        if (!WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(profile.title)) {
+        if (!WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(profile.title) && !profile.isTemporary) {
             var profileTitleKey = this._makeTitleKey(profile.title, typeId);
             if (!(profileTitleKey in this._profileGroups))
                 this._profileGroups[profileTitleKey] = [];
@@ -704,12 +704,20 @@
         var profileTitleKey = this._makeTitleKey(profile.title, profile.profileType().id);
         var group = this._profileGroups[profileTitleKey];
         if (group) {
-            var index = group.indexOf(profile);
-            sidebarParent = group._profilesTreeElement || sidebarParent;
-            if (index !== -1)
-                group.splice(index, 1);
+            group.splice(group.indexOf(profile), 1);
+            if (group.length === 1) {
+                // Move the last profile out of its group and remove the group.
+                var index = sidebarParent.children.indexOf(group._profilesTreeElement);
+                sidebarParent.insertChild(group[0]._profilesTreeElement, index);
+                group[0]._profilesTreeElement.small = false;
+                group[0]._profilesTreeElement.mainTitle = group[0].title;
+                sidebarParent.removeChild(group._profilesTreeElement);
+            }
+            if (group.length !== 0)
+                sidebarParent = group._profilesTreeElement;
+            else
+                delete this._profileGroups[profileTitleKey];
         }
-
         sidebarParent.removeChild(profile._profilesTreeElement);
 
         // No other item will be selected if there aren't any other profiles, so
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to