Web Inspector: test that nodes from the same detached DOM tree will get into one...
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 10:52:41 +0000 (10:52 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 10:52:41 +0000 (10:52 +0000)
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):

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js
LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html [new file with mode: 0644]
LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/JSHeapSnapshot.js

index 195ab1c..3033799 100644 (file)
@@ -1,3 +1,24 @@
+2013-01-30  Yury Semikhatsky  <yurys@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  <yurys@chromium.org>
 
         Layout Test inspector-protocol/take-heap-snapshot.html crashes in the Debug mode
index 6d292db..de9a97e 100644 (file)
@@ -89,6 +89,18 @@ InspectorTest.completeTest = function()
     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);
diff --git a/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt b/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree-expected.txt
new file mode 100644 (file)
index 0000000..b112d12
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html b/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html
new file mode 100644 (file)
index 0000000..ba09067
--- /dev/null
@@ -0,0 +1,83 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<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="https://bugs.webkit.org/show_bug.cgi?id=107819">Bug 107819.</p>
+</body>
+</html>
diff --git a/LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js b/LayoutTests/inspector-protocol/heap-profiler/resources/heap-snapshot-common.js
new file mode 100644 (file)
index 0000000..7b3b9f1
--- /dev/null
@@ -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", {});
+}
index e6408a8..b667af3 100644 (file)
@@ -1,3 +1,15 @@
+2013-01-30  Yury Semikhatsky  <yurys@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  <haraken@chromium.org>
 
         [V8] Trace not only major DOM GCs but also minor DOM GCs
index cd3b119..72c167f 100644 (file)
@@ -322,12 +322,12 @@ WebInspector.JSHeapSnapshotNode.prototype = {
         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 + ")";
         }