Title: [141393] trunk
Revision
141393
Author
yu...@chromium.org
Date
2013-01-31 02:52:41 -0800 (Thu, 31 Jan 2013)

Log Message

Web Inspector: test that nodes from the same detached DOM tree will get into one group in heap snapshot
https://bugs.webkit.org/show_bug.cgi?id=108202

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Test: inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html

* inspector/front-end/JSHeapSnapshot.js:
(WebInspector.JSHeapSnapshotNode.prototype.className): removed unnecessary i18n.

LayoutTests:

Test that JS wrappers for all DOM nodes from the same detached DOM tree will get into
single "Detached DOM Tree" entry in the JS heap snapshot.

* http/tests/inspector-protocol/resources/InspectorTest.js:
(InspectorTest.importScript):
* inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt: Added.
* inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html: Added. I started
with writing simplified version of WebInspector.JSHeapSnapshot just for tests
but it soon it became clear that we would need to reimplement too much functionality
of WebInspector.JSHeapSnapshot so I decided not to reinvent the wheel and just import
original heap snapshot model.
* inspector-protocol/heap-profiler/resources/heap-snapshot-common.js: Added.
(InspectorTest.takeHeapSnapshot):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141392 => 141393)


--- trunk/LayoutTests/ChangeLog	2013-01-31 10:02:04 UTC (rev 141392)
+++ trunk/LayoutTests/ChangeLog	2013-01-31 10:52:41 UTC (rev 141393)
@@ -1,3 +1,24 @@
+2013-01-30  Yury Semikhatsky  <yu...@chromium.org>
+
+        Web Inspector: test that nodes from the same detached DOM tree will get into one group in heap snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=108202
+
+        Reviewed by Vsevolod Vlasov.
+
+        Test that JS wrappers for all DOM nodes from the same detached DOM tree will get into
+        single "Detached DOM Tree" entry in the JS heap snapshot.
+
+        * http/tests/inspector-protocol/resources/InspectorTest.js:
+        (InspectorTest.importScript):
+        * inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt: Added.
+        * inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html: Added. I started
+        with writing simplified version of WebInspector.JSHeapSnapshot just for tests
+        but it soon it became clear that we would need to reimplement too much functionality
+        of WebInspector.JSHeapSnapshot so I decided not to reinvent the wheel and just import
+        original heap snapshot model.
+        * inspector-protocol/heap-profiler/resources/heap-snapshot-common.js: Added.
+        (InspectorTest.takeHeapSnapshot):
+
 2013-01-31  Yury Semikhatsky  <yu...@chromium.org>
 
         Layout Test inspector-protocol/take-heap-snapshot.html crashes in the Debug mode

Modified: trunk/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js (141392 => 141393)


--- trunk/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js	2013-01-31 10:02:04 UTC (rev 141392)
+++ trunk/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js	2013-01-31 10:52:41 UTC (rev 141393)
@@ -89,6 +89,18 @@
     this.sendCommand("Runtime.evaluate", { "_expression_": "closeTest();"} );
 }
 
+
+/**
+ * @param {string} scriptName
+ */
+InspectorTest.importScript = function(scriptName)
+{
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", scriptName, false);
+    xhr.send(null);
+    window.eval(xhr.responseText);
+}
+
 window.addEventListener("message", function(event) {
     try {
         eval(event.data);

Added: trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt (0 => 141393)


--- trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt	2013-01-31 10:52:41 UTC (rev 141393)
@@ -0,0 +1,7 @@
+Test that all nodes from the detached DOM tree will get into one group in the heap snapshot. Bug 107819.
+
+ SUCCESS: found (Detached DOM trees)
+SUCCESS: found Detached DOM tree / 4 entries
+SUCCESS: found 3 DIVs in Detached DOM tree / 4 entries
+SUCCESS: didGetHeapSnapshot
+
Property changes on: trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html (0 => 141393)


--- trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html	2013-01-31 10:52:41 UTC (rev 141393)
@@ -0,0 +1,83 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function createDetachedDomTreeAndRunTest()
+{
+    window.retaining_wrapper = document.createElement("div");
+    var t = document.createElement("div");
+    retaining_wrapper.appendChild(t);
+    t.appendChild(document.createElement("div"));
+
+    runTest();
+}
+
+function test()
+{
+    InspectorTest.importScript("../../../../inspector-protocol/heap-profiler/resources/heap-snapshot-common.js");
+
+    function checkHeapSnapshot(snapshot) {
+        var node;
+        for (var it = snapshot._allNodes(); it.hasNext(); it.next()) {
+            if (it.node.name() === "(Detached DOM trees)") {
+                node = it.node;
+                break;
+            }
+        }
+        if (node)
+            InspectorTest.log("SUCCESS: found " + node.name());
+        else
+            return fail("cannot find detached DOM trees root");
+
+        var detachedDOMTreeRE = /^Detached DOM tree/;
+        var detachedDomTreeFound = false;
+        for (var iter = node.edges(); iter.hasNext(); iter.next()) {
+            var node = iter.edge.node();
+            if (detachedDOMTreeRE.test(node.className())) {
+                if ("Detached DOM tree / 4 entries" === node.name()) {
+                    if (detachedDomTreeFound)
+                        return fail("second " + node.name());
+                    detachedDomTreeFound = true;
+                    InspectorTest.log("SUCCESS: found " + node.name());
+                    checkDetachedDOMTreeNodes(node);
+                } else
+                    return fail("unexpected detached DOM tree: " + node.name());
+            }
+        }
+    }
+
+    function checkDetachedDOMTreeNodes(treeNode)
+    {
+        var divCount = 0;
+        for (var iter = treeNode.edges(); iter.hasNext(); iter.next()) {
+            var node = iter.edge.node();
+            if (node.name() === "HTMLDivElement")
+                ++divCount;
+            else
+                return fail("unexpected DOM wrapper: " + node.name());
+        }
+        if (divCount === 3)
+            InspectorTest.log("SUCCESS: found " + divCount + " DIVs in " + treeNode.name());
+        else
+            return fail("unexpected DIV count: " + divCount);
+
+    }
+
+    function fail(message) {
+        InspectorTest.log("FAIL: " + message);
+        InspectorTest.completeTest();
+    }
+
+    InspectorTest.takeHeapSnapshot(checkHeapSnapshot);
+}
+</script>
+</head>
+<body _onload_="createDetachedDomTreeAndRunTest()">
+<p>Test that all nodes from the detached DOM tree will get into one group in the heap snapshot. <a href="" 107819.</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js (0 => 141393)


--- trunk/LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js	2013-01-31 10:52:41 UTC (rev 141393)
@@ -0,0 +1,39 @@
+// This script is supposed to be evaluated in dummy inspector front-end which is loaded from
+// ../../../http/tests/inspector-protocol/resources/protocol-test.html and the relative paths
+// below are relative to that location.
+
+if (!window.WebInspector)
+    window.WebInspector = {};
+InspectorTest.importScript("../../../../../Source/WebCore/inspector/front-end/HeapSnapshot.js");
+InspectorTest.importScript("../../../../../Source/WebCore/inspector/front-end/JSHeapSnapshot.js");
+
+InspectorTest.takeHeapSnapshot = function(callback)
+{
+    InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messageObject)
+    {
+        var profileId = messageObject["params"]["header"]["uid"];
+        InspectorTest.sendCommand("Profiler.getHeapSnapshot", { "uid": profileId }, didGetHeapSnapshot);
+
+        function didGetHeapSnapshot(messageObject)
+        {
+            InspectorTest.log("SUCCESS: didGetHeapSnapshot");
+            InspectorTest.completeTest();
+        }
+    }
+
+    var chunks = [];
+    InspectorTest.eventHandler["Profiler.addHeapSnapshotChunk"] = function(messageObject)
+    {
+        chunks.push(messageObject["params"]["chunk"]);
+    }
+
+    InspectorTest.eventHandler["Profiler.finishHeapSnapshot"] = function(messageObject)
+    {
+        var serializedSnapshot = chunks.join("");
+        var parsed = JSON.parse(serializedSnapshot);
+        var snapshot = new WebInspector.JSHeapSnapshot(parsed);
+        callback(snapshot);
+    }
+
+    InspectorTest.sendCommand("Profiler.takeHeapSnapshot", {});
+}
Property changes on: trunk/LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (141392 => 141393)


--- trunk/Source/WebCore/ChangeLog	2013-01-31 10:02:04 UTC (rev 141392)
+++ trunk/Source/WebCore/ChangeLog	2013-01-31 10:52:41 UTC (rev 141393)
@@ -1,3 +1,15 @@
+2013-01-30  Yury Semikhatsky  <yu...@chromium.org>
+
+        Web Inspector: test that nodes from the same detached DOM tree will get into one group in heap snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=108202
+
+        Reviewed by Vsevolod Vlasov.
+
+        Test: inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html
+
+        * inspector/front-end/JSHeapSnapshot.js:
+        (WebInspector.JSHeapSnapshotNode.prototype.className): removed unnecessary i18n.
+
 2013-01-31  Kentaro Hara  <hara...@chromium.org>
 
         [V8] Trace not only major DOM GCs but also minor DOM GCs

Modified: trunk/Source/WebCore/inspector/front-end/JSHeapSnapshot.js (141392 => 141393)


--- trunk/Source/WebCore/inspector/front-end/JSHeapSnapshot.js	2013-01-31 10:02:04 UTC (rev 141392)
+++ trunk/Source/WebCore/inspector/front-end/JSHeapSnapshot.js	2013-01-31 10:52:41 UTC (rev 141393)
@@ -322,12 +322,12 @@
         var type = this.type();
         switch (type) {
         case "hidden":
-            return WebInspector.UIString("(system)");
+            return "(system)";
         case "object":
         case "native":
             return this.name();
         case "code":
-            return WebInspector.UIString("(compiled code)");
+            return "(compiled code)";
         default:
             return "(" + type + ")";
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to