diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/performance/test/browser_perf-tree-view-02.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/performance/test/browser_perf-tree-view-02.js')
-rw-r--r-- | devtools/client/performance/test/browser_perf-tree-view-02.js | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/devtools/client/performance/test/browser_perf-tree-view-02.js b/devtools/client/performance/test/browser_perf-tree-view-02.js new file mode 100644 index 000000000..bb325ba90 --- /dev/null +++ b/devtools/client/performance/test/browser_perf-tree-view-02.js @@ -0,0 +1,148 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +/** + * Tests if the profiler's tree view implementation works properly and + * creates the correct column structure after expanding some of the nodes. + * Also tests that demangling works. + */ + +const { ThreadNode } = require("devtools/client/performance/modules/logic/tree-model"); +const { CallView } = require("devtools/client/performance/modules/widgets/tree-view"); +const { synthesizeProfile } = require("devtools/client/performance/test/helpers/synth-utils"); + +const MANGLED_FN = "__Z3FooIiEvv"; +const UNMANGLED_FN = "void Foo<int>()"; + +add_task(function () { + // Create a profile and mangle a function inside the string table. + let profile = synthesizeProfile(); + + profile.threads[0].stringTable[1] = + profile.threads[0].stringTable[1].replace("A (", `${MANGLED_FN} (`); + + let threadNode = new ThreadNode(profile.threads[0], { startTime: 0, endTime: 20 }); + + // Don't display the synthesized (root) and the real (root) node twice. + threadNode.calls = threadNode.calls[0].calls; + + let treeRoot = new CallView({ frame: threadNode }); + let container = document.createElement("vbox"); + treeRoot.autoExpandDepth = 0; + treeRoot.attachTo(container); + + let $$ = node => container.querySelectorAll(node); + let $fun = (node, ancestor) => (ancestor || container).querySelector( + ".call-tree-cell[type=function] > " + node); + let $$fun = (node, ancestor) => (ancestor || container).querySelectorAll( + ".call-tree-cell[type=function] > " + node); + let $$dur = i => container.querySelectorAll(".call-tree-cell[type=duration]")[i]; + let $$per = i => container.querySelectorAll(".call-tree-cell[type=percentage]")[i]; + let $$sam = i => container.querySelectorAll(".call-tree-cell[type=samples]")[i]; + + is(container.childNodes.length, 1, + "The container node should have one child available."); + is(container.childNodes[0].className, "call-tree-item", + "The root node in the tree has the correct class name."); + + is($$dur(0).textContent.trim(), "20 ms", + "The root's duration cell displays the correct value."); + is($$per(0).textContent.trim(), "100%", + "The root's percentage cell displays the correct value."); + is($$sam(0).textContent.trim(), "0", + "The root's samples cell displays the correct value."); + is($$fun(".call-tree-name")[0].textContent.trim(), "(root)", + "The root's function cell displays the correct name."); + is($$fun(".call-tree-url")[0], null, + "The root's function cell displays no url."); + is($$fun(".call-tree-line")[0], null, + "The root's function cell displays no line."); + is($$fun(".call-tree-host")[0], null, + "The root's function cell displays no host."); + is($$fun(".call-tree-category")[0], null, + "The root's function cell displays no category."); + + treeRoot.expand(); + + is(container.childNodes.length, 2, + "The container node should have two children available."); + is(container.childNodes[0].className, "call-tree-item", + "The root node in the tree has the correct class name."); + is(container.childNodes[1].className, "call-tree-item", + "The .A node in the tree has the correct class name."); + + // Test demangling in the profiler tree. + is($$dur(1).textContent.trim(), "20 ms", + "The .A node's duration cell displays the correct value."); + is($$per(1).textContent.trim(), "100%", + "The .A node's percentage cell displays the correct value."); + is($$sam(1).textContent.trim(), "0", + "The .A node's samples cell displays the correct value."); + + is($fun(".call-tree-name", $$(".call-tree-item")[1]).textContent.trim(), UNMANGLED_FN, + "The .A node's function cell displays the correct name."); + is($fun(".call-tree-url", $$(".call-tree-item")[1]).textContent.trim(), "baz", + "The .A node's function cell displays the correct url."); + is($fun(".call-tree-line", $$(".call-tree-item")[1]).textContent.trim(), ":12", + "The .A node's function cell displays the correct line."); + is($fun(".call-tree-host", $$(".call-tree-item")[1]).textContent.trim(), "foo", + "The .A node's function cell displays the correct host."); + is($fun(".call-tree-category", $$(".call-tree-item")[1]).textContent.trim(), "Gecko", + "The .A node's function cell displays the correct category."); + + ok($$(".call-tree-item")[1].getAttribute("tooltiptext").includes(MANGLED_FN), + "The .A node's row's tooltip contains the original mangled name."); + + let A = treeRoot.getChild(); + A.expand(); + + is(container.childNodes.length, 4, + "The container node should have four children available."); + is(container.childNodes[0].className, "call-tree-item", + "The root node in the tree has the correct class name."); + is(container.childNodes[1].className, "call-tree-item", + "The .A node in the tree has the correct class name."); + is(container.childNodes[2].className, "call-tree-item", + "The .B node in the tree has the correct class name."); + is(container.childNodes[3].className, "call-tree-item", + "The .E node in the tree has the correct class name."); + + is($$dur(2).textContent.trim(), "15 ms", + "The .A.B node's duration cell displays the correct value."); + is($$per(2).textContent.trim(), "75%", + "The .A.B node's percentage cell displays the correct value."); + is($$sam(2).textContent.trim(), "0", + "The .A.B node's samples cell displays the correct value."); + is($fun(".call-tree-name", $$(".call-tree-item")[2]).textContent.trim(), "B", + "The .A.B node's function cell displays the correct name."); + is($fun(".call-tree-url", $$(".call-tree-item")[2]).textContent.trim(), "baz", + "The .A.B node's function cell displays the correct url."); + ok($fun(".call-tree-url", $$(".call-tree-item")[2]).getAttribute("tooltiptext").includes("http://foo/bar/baz"), + "The .A.B node's function cell displays the correct url tooltiptext."); + is($fun(".call-tree-line", $$(".call-tree-item")[2]).textContent.trim(), ":34", + "The .A.B node's function cell displays the correct line."); + is($fun(".call-tree-host", $$(".call-tree-item")[2]).textContent.trim(), "foo", + "The .A.B node's function cell displays the correct host."); + is($fun(".call-tree-category", $$(".call-tree-item")[2]).textContent.trim(), "Styles", + "The .A.B node's function cell displays the correct category."); + + is($$dur(3).textContent.trim(), "5 ms", + "The .A.E node's duration cell displays the correct value."); + is($$per(3).textContent.trim(), "25%", + "The .A.E node's percentage cell displays the correct value."); + is($$sam(3).textContent.trim(), "0", + "The .A.E node's samples cell displays the correct value."); + is($fun(".call-tree-name", $$(".call-tree-item")[3]).textContent.trim(), "E", + "The .A.E node's function cell displays the correct name."); + is($fun(".call-tree-url", $$(".call-tree-item")[3]).textContent.trim(), "baz", + "The .A.E node's function cell displays the correct url."); + ok($fun(".call-tree-url", $$(".call-tree-item")[3]).getAttribute("tooltiptext").includes("http://foo/bar/baz"), + "The .A.E node's function cell displays the correct url tooltiptext."); + is($fun(".call-tree-line", $$(".call-tree-item")[3]).textContent.trim(), ":90", + "The .A.E node's function cell displays the correct line."); + is($fun(".call-tree-host", $$(".call-tree-item")[3]).textContent.trim(), "foo", + "The .A.E node's function cell displays the correct host."); + is($fun(".call-tree-category", $$(".call-tree-item")[3]).textContent.trim(), "GC", + "The .A.E node's function cell displays the correct category."); +}); |