mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
99
devtools/client/performance/test/helpers/synth-utils.js
Normal file
99
devtools/client/performance/test/helpers/synth-utils.js
Normal file
|
|
@ -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 };
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue