summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance/test/helpers/synth-utils.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/performance/test/helpers/synth-utils.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/helpers/synth-utils.js')
-rw-r--r--devtools/client/performance/test/helpers/synth-utils.js99
1 files changed, 99 insertions, 0 deletions
diff --git a/devtools/client/performance/test/helpers/synth-utils.js b/devtools/client/performance/test/helpers/synth-utils.js
new file mode 100644
index 000000000..d4631a3f1
--- /dev/null
+++ b/devtools/client/performance/test/helpers/synth-utils.js
@@ -0,0 +1,99 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+/**
+ * Generates a generalized profile with some samples.
+ */
+exports.synthesizeProfile = () => {
+ const { CATEGORY_MASK } = require("devtools/client/performance/modules/categories");
+ const RecordingUtils = require("devtools/shared/performance/recording-utils");
+
+ return RecordingUtils.deflateProfile({
+ meta: { version: 2 },
+ threads: [{
+ samples: [{
+ time: 1,
+ frames: [
+ { category: CATEGORY_MASK("other"), location: "(root)" },
+ { category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
+ { category: CATEGORY_MASK("css"), location: "B (http://foo/bar/baz:34)" },
+ { category: CATEGORY_MASK("js"), location: "C (http://foo/bar/baz:56)" }
+ ]
+ }, {
+ time: 1 + 1,
+ frames: [
+ { category: CATEGORY_MASK("other"), location: "(root)" },
+ { category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
+ { category: CATEGORY_MASK("css"), location: "B (http://foo/bar/baz:34)" },
+ { category: CATEGORY_MASK("gc", 1), location: "D (http://foo/bar/baz:78:9)" }
+ ]
+ }, {
+ time: 1 + 1 + 2,
+ frames: [
+ { category: CATEGORY_MASK("other"), location: "(root)" },
+ { category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
+ { category: CATEGORY_MASK("css"), location: "B (http://foo/bar/baz:34)" },
+ { category: CATEGORY_MASK("gc", 1), location: "D (http://foo/bar/baz:78:9)" }
+ ]
+ }, {
+ time: 1 + 1 + 2 + 3,
+ frames: [
+ { category: CATEGORY_MASK("other"), location: "(root)" },
+ { category: CATEGORY_MASK("other"), location: "A (http://foo/bar/baz:12)" },
+ { category: CATEGORY_MASK("gc", 2), location: "E (http://foo/bar/baz:90)" },
+ { category: CATEGORY_MASK("network"), location: "F (http://foo/bar/baz:99)" }
+ ]
+ }]
+ }]
+ });
+};
+
+/**
+ * Generates a simple implementation for a tree class.
+ */
+exports.synthesizeCustomTreeClass = () => {
+ const { Cu } = require("chrome");
+ const { AbstractTreeItem } = Cu.import("resource://devtools/client/shared/widgets/AbstractTreeItem.jsm", {});
+ const { Heritage } = require("devtools/client/shared/widgets/view-helpers");
+
+ function MyCustomTreeItem(dataSrc, properties) {
+ AbstractTreeItem.call(this, properties);
+ this.itemDataSrc = dataSrc;
+ }
+
+ MyCustomTreeItem.prototype = Heritage.extend(AbstractTreeItem.prototype, {
+ _displaySelf: function (document, arrowNode) {
+ let node = document.createElement("hbox");
+ node.style.marginInlineStart = (this.level * 10) + "px";
+ node.appendChild(arrowNode);
+ node.appendChild(document.createTextNode(this.itemDataSrc.label));
+ return node;
+ },
+
+ _populateSelf: function (children) {
+ for (let childDataSrc of this.itemDataSrc.children) {
+ children.push(new MyCustomTreeItem(childDataSrc, {
+ parent: this,
+ level: this.level + 1
+ }));
+ }
+ }
+ });
+
+ const myDataSrc = {
+ label: "root",
+ children: [{
+ label: "foo",
+ children: []
+ }, {
+ label: "bar",
+ children: [{
+ label: "baz",
+ children: []
+ }]
+ }]
+ };
+
+ return { MyCustomTreeItem, myDataSrc };
+};