Web Inspector: test that references from DOM nodes to event listeners are presented...
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 11:25:30 +0000 (11:25 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 11:25:30 +0000 (11:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108322

Reviewed by Vsevolod Vlasov.

Test that links from DOM node wrappers to event listener functions are presented
in heap snapshots.

* inspector-protocol/heap-profiler/heap-snapshot-with-event-listener-expected.txt: Added.
* inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-event-listener-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html [new file with mode: 0644]

index 0b6433e..40bd53a 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-30  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: test that references from DOM nodes to event listeners are presented in heap snapshots
+        https://bugs.webkit.org/show_bug.cgi?id=108322
+
+        Reviewed by Vsevolod Vlasov.
+
+        Test that links from DOM node wrappers to event listener functions are presented
+        in heap snapshots.
+
+        * inspector-protocol/heap-profiler/heap-snapshot-with-event-listener-expected.txt: Added.
+        * inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html: Added.
+
 2013-01-31  Kent Tamura  <tkent@chromium.org>
 
         Click on a label element won't select input[type=date]
diff --git a/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-event-listener-expected.txt b/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-event-listener-expected.txt
new file mode 100644 (file)
index 0000000..c588792
--- /dev/null
@@ -0,0 +1,6 @@
+Test that all nodes from the detached DOM tree will get into one group in the heap snapshot. Bug 107819.
+
+ SUCCESS: found myEventListener
+SUCCESS: found link from HTMLBodyElement to HTMLBodyElement
+SUCCESS: didGetHeapSnapshot
+
diff --git a/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html b/LayoutTests/inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html
new file mode 100644 (file)
index 0000000..faec0fe
--- /dev/null
@@ -0,0 +1,70 @@
+<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 addEventListenerAndRunTest()
+{
+    function myEventListener(e) {
+        console.log("myEventListener");
+    }
+    document.body.addEventListener("click", myEventListener, true);
+
+    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.type() === "closure" && it.node.name() === "myEventListener") {
+                node = it.node;
+                break;
+            }
+        }
+        if (node)
+            InspectorTest.log("SUCCESS: found " + node.name());
+        else
+            return fail("cannot find detached DOM trees root");
+
+        var nativeRetainers = 0;
+        for (var iter = node.retainers(); iter.hasNext(); iter.next()) {
+            var node = iter.retainer.node();
+            var retainingEdge = iter.retainer;
+            if (retainingEdge.isInternal() && retainingEdge.name() === "native") {
+                if (++nativeRetainers === 1) {
+                    var retainerName = retainingEdge.node().name();
+                    if (retainerName === "HTMLBodyElement")
+                        InspectorTest.log("SUCCESS: found link from HTMLBodyElement to " + node.name());
+                    else
+                        return fail("unexpected retainer of " + node.name() + ": " + retainerName);
+                } else
+                    return fail("too many retainers of " + node.name());
+            } else if (!retainingEdge.isWeak())
+                return fail("unexpected retaining edge of " + node.name() + " type: " + retainingEdge.type() + ", name: " + retainingEdge.name());
+        }
+        if (!nativeRetainers)
+            return fail("cannot find HTMLBodyElement among retainers of " + node.name());
+    }
+
+    function fail(message) {
+        InspectorTest.log("FAIL: " + message);
+        InspectorTest.completeTest();
+    }
+
+    InspectorTest.takeHeapSnapshot(checkHeapSnapshot);
+}
+</script>
+</head>
+<body onload="addEventListenerAndRunTest()">
+<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>