var { FileUtils } = ChromeUtils.importESModule( "resource://gre/modules/FileUtils.sys.mjs"
); var { expectState } = require("resource://devtools/server/actors/common.js"); var HeapSnapshotFileUtils = require("resource://devtools/shared/heapsnapshot/HeapSnapshotFileUtils.js"); var HeapAnalysesClient = require("resource://devtools/shared/heapsnapshot/HeapAnalysesClient.js"); var { addDebuggerToGlobal } = ChromeUtils.importESModule( "resource://gre/modules/jsdebugger.sys.mjs"
); var Store = require("resource://devtools/client/memory/store.js"); var { L10N } = require("resource://devtools/client/memory/utils.js"); var SYSTEM_PRINCIPAL = Cc["@mozilla.org/systemprincipal;1"].createInstance(
Ci.nsIPrincipal
);
var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0;
registerCleanupFunction(function () {
equal(
DevToolsUtils.assertionFailureCount,
EXPECTED_DTU_ASSERT_FAILURE_COUNT, "Should have had the expected number of DevToolsUtils.assert() failures."
);
});
function dumpn(msg) {
dump(`MEMORY-TEST: ${msg}\n`);
}
function initDebugger() { const global = new Cu.Sandbox(SYSTEM_PRINCIPAL, { freshZone: true });
addDebuggerToGlobal(global); returnnew global.Debugger();
}
function StubbedMemoryFront() { this.state = "detached"; this.dbg = initDebugger();
}
StubbedMemoryFront.prototype.attach = async function () { this.state = "attached";
};
StubbedMemoryFront.prototype.detach = async function () { this.state = "detached";
};
return (
snapshots.length === expected.length &&
expected.every((state, i) => { const census = getCensus(snapshots[i]); return (
state === "*" ||
(!census && !state) ||
(census && census.state === state)
);
})
);
};
info(`Waiting for snapshots' censuses to be of state: ${expected}`); return waitUntilState(store, predicate);
}
async function createTempFile() { const file = new FileUtils.File(
PathUtils.join(PathUtils.tempDir, "tmp.fxsnapshot")
);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE); const destPath = file.path; const stat = await IOUtils.stat(destPath); Assert.strictEqual(stat.size, 0, "new file is 0 bytes at start"); return destPath;
}
// This is a copy of the same method from shared-head.js as // xpcshell test aren't using shared-head.js /** * Wait for a specific action type to be dispatched. * * If the action is async and defines a `status` property, this helper will wait * for the status to reach either "error" or "done". * * @param {Object} store * Redux store where the action should be dispatched. * @param {String} actionType * The actionType to wait for. * @param {Number} repeat * Optional, number of time the action is expected to be dispatched. * Defaults to 1 * @return {Promise}
*/ function waitForDispatch(store, actionType, repeat = 1) {
let count = 0; returnnew Promise(resolve => {
store.dispatch({
type: "@@service/waitUntil",
predicate: action => { const isDone =
!action.status ||
action.status === "done" ||
action.status === "error";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.