try {
process.run(true, args, args.length);
} catch (ex) { // on Windows we exit with a -1 status when crashing.
} finally {
Services.env.set("CRASHES_EVENTS_DIR", "");
}
if (!canReturnZero) { // should exit with an error (should have crashed) Assert.notEqual(process.exitValue, 0);
}
await handleMinidump(callback);
}
function getMinidump() {
let en = do_get_tempdir().directoryEntries; while (en.hasMoreElements()) {
let f = en.nextFile; if (f.leafName.substr(-4) == ".dmp") { return f;
}
}
let exe = Services.dirsvc.get("GreBinD", Ci.nsIFile);
exe.appendRelativePath(exeName);
return exe;
}
function runMinidumpAnalyzer(dumpFile) {
let bin = getCrashReporterPath();
let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(bin);
let args = ["--analyze"];
args.push(dumpFile.path);
process.run(true/* blocking */, args, args.length);
}
async function handleMinidump(callback) { // find minidump
let minidump = getMinidump();
if (minidump == null) {
do_throw("No minidump found!");
}
let extrafile = minidump.clone();
extrafile.leafName = extrafile.leafName.slice(0, -4) + ".extra";
let memoryfile = minidump.clone();
memoryfile.leafName = memoryfile.leafName.slice(0, -4) + ".memory.json.gz";
let cleanup = async function () { for (let file of [minidump, extrafile, memoryfile]) { while (file.exists()) { try {
file.remove(false);
} catch (e) { // On Windows the file may be locked, wait briefly and try again
await new Promise(resolve => do_timeout(50, resolve));
}
}
}
};
// Just in case, don't let these files linger.
registerCleanupFunction(cleanup);
Assert.ok(extrafile.exists());
let extra = await IOUtils.readJSON(extrafile.path); // No matter how we crash, there should always be a crash id Assert.ok("CrashEventID" in extra);
if (callback) {
await callback(minidump, extra, extrafile, memoryfile);
}
await cleanup();
}
function spinEventLoop() { returnnew Promise(resolve => {
executeSoon(resolve);
});
}
// Get full path to application (not xpcshell)
let bin = Services.dirsvc.get("GreBinD", Ci.nsIFile); if (AppConstants.platform === "win") {
bin.append(AppConstants.MOZ_APP_NAME + ".exe");
} else {
bin.append(AppConstants.MOZ_APP_NAME);
}
// run `application --backgroundtask crash ...`.
let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(bin);
let args = ["--backgroundtask", "crash"];
args.push(crashType.toString());
// Sorted to be deterministic.
let sorted = Object.entries(crashExtras).sort((a, b) => a[0] < b[0]); for (let [key, value] of sorted) {
args.push(key);
args.push(value);
}
let crashD = do_get_tempdir();
crashD.append("crash-events"); if (!crashD.exists()) {
crashD.create(crashD.DIRECTORY_TYPE, 0o700);
}
let uri = protocolHandler.getSubstitution("testing-common"); Assert.ok(uri, "resource://testing-common is not substituted");
// The equivalent of _TESTING_MODULES_DIR in xpcshell.
Services.env.set("XPCSHELL_TESTING_MODULES_URI", uri.spec);
try {
process.run(true, args, args.length);
} catch (ex) { // on Windows we exit with a -1 status when crashing.
} finally {
Services.env.set("CRASHES_EVENTS_DIR", "");
Services.env.set("XPCSHELL_TESTING_MODULES_URI", "");
}
if (!canReturnZero) { // should exit with an error (should have crashed) Assert.notEqual(process.exitValue, 0);
}
await handleMinidump(callback);
}
// Import binary APIs via js-ctypes. var { CrashTestUtils } = ChromeUtils.importESModule( "resource://test/CrashTestUtils.sys.mjs"
);
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-08-26)
¤
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 und die Messung sind noch experimentell.