forked from mirrors/gecko-dev
Bug 1823217 - Convert toolkit/components/crashes to ES modules. r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D172934
This commit is contained in:
parent
f2ae48a063
commit
b4d9434d7f
11 changed files with 37 additions and 75 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Ensures that content crashes are reported to the crash service
|
// Ensures that content crashes are reported to the crash service
|
||||||
// (nsICrashService and CrashManager.jsm).
|
// (nsICrashService and CrashManager.sys.mjs).
|
||||||
|
|
||||||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||||
SimpleTest.requestFlakyTimeout("untriaged");
|
SimpleTest.requestFlakyTimeout("untriaged");
|
||||||
|
|
|
||||||
|
|
@ -591,8 +591,8 @@ async function collectCrashInfo() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { getCrashManager } = ChromeUtils.import(
|
const { getCrashManager } = ChromeUtils.importESModule(
|
||||||
"resource://gre/modules/CrashManager.jsm"
|
"resource://gre/modules/CrashManager.sys.mjs"
|
||||||
);
|
);
|
||||||
const crashes = await getCrashManager().getCrashes();
|
const crashes = await getCrashManager().getCrashes();
|
||||||
CrashModuleSet = new Set(
|
CrashModuleSet = new Set(
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
"use strict";
|
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||||
|
import { PromiseUtils } from "resource://gre/modules/PromiseUtils.sys.mjs";
|
||||||
const { AppConstants } = ChromeUtils.importESModule(
|
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
|
||||||
"resource://gre/modules/AppConstants.sys.mjs"
|
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||||
);
|
|
||||||
const { PromiseUtils } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/PromiseUtils.sys.mjs"
|
|
||||||
);
|
|
||||||
const { setTimeout } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/Timer.sys.mjs"
|
|
||||||
);
|
|
||||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
|
||||||
);
|
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
|
|
@ -24,15 +14,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
TelemetryController: "resource://gre/modules/TelemetryController.sys.mjs",
|
TelemetryController: "resource://gre/modules/TelemetryController.sys.mjs",
|
||||||
});
|
});
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = [
|
|
||||||
"CrashManager",
|
|
||||||
"getCrashManager",
|
|
||||||
// The following are exported for tests only.
|
|
||||||
"CrashStore",
|
|
||||||
"dateToDays",
|
|
||||||
"getCrashManagerNoCreate",
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How long to wait after application startup before crash event files are
|
* How long to wait after application startup before crash event files are
|
||||||
* automatically aggregated.
|
* automatically aggregated.
|
||||||
|
|
@ -47,7 +28,7 @@ const MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000;
|
||||||
// Converts Date to days since UNIX epoch.
|
// Converts Date to days since UNIX epoch.
|
||||||
// This was copied from /services/metrics.storage.jsm. The implementation
|
// This was copied from /services/metrics.storage.jsm. The implementation
|
||||||
// does not account for leap seconds.
|
// does not account for leap seconds.
|
||||||
function dateToDays(date) {
|
export function dateToDays(date) {
|
||||||
return Math.floor(date.getTime() / MILLISECONDS_IN_DAY);
|
return Math.floor(date.getTime() / MILLISECONDS_IN_DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,7 +104,7 @@ function parseAndRemoveField(obj, field) {
|
||||||
* telemetryStoreSizeKey (string)
|
* telemetryStoreSizeKey (string)
|
||||||
* Telemetry histogram to report store size under.
|
* Telemetry histogram to report store size under.
|
||||||
*/
|
*/
|
||||||
var CrashManager = function(options) {
|
export var CrashManager = function(options) {
|
||||||
for (let k in options) {
|
for (let k in options) {
|
||||||
let value = options[k];
|
let value = options[k];
|
||||||
|
|
||||||
|
|
@ -1015,7 +996,7 @@ var gCrashManager;
|
||||||
* The telemetry histogram that should be used to store the size
|
* The telemetry histogram that should be used to store the size
|
||||||
* of the data file.
|
* of the data file.
|
||||||
*/
|
*/
|
||||||
function CrashStore(storeDir, telemetrySizeKey) {
|
export function CrashStore(storeDir, telemetrySizeKey) {
|
||||||
this._storeDir = storeDir;
|
this._storeDir = storeDir;
|
||||||
this._telemetrySizeKey = telemetrySizeKey;
|
this._telemetrySizeKey = telemetrySizeKey;
|
||||||
|
|
||||||
|
|
@ -1627,7 +1608,7 @@ XPCOMUtils.defineLazyGetter(CrashManager, "Singleton", function() {
|
||||||
return gCrashManager;
|
return gCrashManager;
|
||||||
});
|
});
|
||||||
|
|
||||||
function getCrashManager() {
|
export function getCrashManager() {
|
||||||
return CrashManager.Singleton;
|
return CrashManager.Singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1636,6 +1617,6 @@ function getCrashManager() {
|
||||||
*
|
*
|
||||||
* @returns {CrashManager}
|
* @returns {CrashManager}
|
||||||
*/
|
*/
|
||||||
function getCrashManagerNoCreate() {
|
export function getCrashManagerNoCreate() {
|
||||||
return gCrashManager;
|
return gCrashManager;
|
||||||
}
|
}
|
||||||
|
|
@ -4,26 +4,15 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file provides common and shared functionality to facilitate
|
* This file provides common and shared functionality to facilitate
|
||||||
* testing of the Crashes component (CrashManager.jsm).
|
* testing of the Crashes component (CrashManager.sys.mjs).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = [
|
|
||||||
"configureLogging",
|
|
||||||
"getManager",
|
|
||||||
"sleep",
|
|
||||||
"TestingCrashManager",
|
|
||||||
];
|
|
||||||
|
|
||||||
/* global OS */
|
/* global OS */
|
||||||
Cc["@mozilla.org/net/osfileconstantsservice;1"]
|
Cc["@mozilla.org/net/osfileconstantsservice;1"]
|
||||||
.getService(Ci.nsIOSFileConstantsService)
|
.getService(Ci.nsIOSFileConstantsService)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
const { CrashManager } = ChromeUtils.import(
|
import { CrashManager } from "resource://gre/modules/CrashManager.sys.mjs";
|
||||||
"resource://gre/modules/CrashManager.jsm"
|
|
||||||
);
|
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
|
|
@ -34,7 +23,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
|
||||||
var loggingConfigured = false;
|
var loggingConfigured = false;
|
||||||
|
|
||||||
var configureLogging = function() {
|
export var configureLogging = function() {
|
||||||
if (loggingConfigured) {
|
if (loggingConfigured) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +36,7 @@ var configureLogging = function() {
|
||||||
loggingConfigured = true;
|
loggingConfigured = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var sleep = function(wait) {
|
export var sleep = function(wait) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
lazy.setTimeout(() => {
|
lazy.setTimeout(() => {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
@ -55,7 +44,7 @@ var sleep = function(wait) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var TestingCrashManager = function(options) {
|
export var TestingCrashManager = function(options) {
|
||||||
CrashManager.call(this, options);
|
CrashManager.call(this, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -163,7 +152,7 @@ Object.setPrototypeOf(TestingCrashManager.prototype, CrashManager.prototype);
|
||||||
|
|
||||||
var DUMMY_DIR_COUNT = 0;
|
var DUMMY_DIR_COUNT = 0;
|
||||||
|
|
||||||
var getManager = function() {
|
export var getManager = function() {
|
||||||
return (async function() {
|
return (async function() {
|
||||||
const dirMode = OS.Constants.libc.S_IRWXU;
|
const dirMode = OS.Constants.libc.S_IRWXU;
|
||||||
let baseFile = PathUtils.profileDir;
|
let baseFile = PathUtils.profileDir;
|
||||||
|
|
@ -2,14 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
"use strict";
|
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||||
|
import { AsyncShutdown } from "resource://gre/modules/AsyncShutdown.sys.mjs";
|
||||||
const { AppConstants } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/AppConstants.sys.mjs"
|
|
||||||
);
|
|
||||||
const { AsyncShutdown } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/AsyncShutdown.sys.mjs"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set to true if the application is quitting
|
// Set to true if the application is quitting
|
||||||
var gQuitting = false;
|
var gQuitting = false;
|
||||||
|
|
@ -157,7 +151,7 @@ function processExtraFile(extraPath) {
|
||||||
*
|
*
|
||||||
* It is a service because some background activity will eventually occur.
|
* It is a service because some background activity will eventually occur.
|
||||||
*/
|
*/
|
||||||
function CrashService() {
|
export function CrashService() {
|
||||||
Services.obs.addObserver(this, "quit-application");
|
Services.obs.addObserver(this, "quit-application");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,5 +232,3 @@ CrashService.prototype = Object.freeze({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["CrashService"];
|
|
||||||
|
|
@ -8,7 +8,7 @@ Classes = [
|
||||||
{
|
{
|
||||||
'cid': '{92668367-1b17-4190-86b2-1061b2179744}',
|
'cid': '{92668367-1b17-4190-86b2-1061b2179744}',
|
||||||
'contract_ids': ['@mozilla.org/crashservice;1'],
|
'contract_ids': ['@mozilla.org/crashservice;1'],
|
||||||
'jsm': 'resource://gre/modules/CrashService.jsm',
|
'esModule': 'resource://gre/modules/CrashService.sys.mjs',
|
||||||
'constructor': 'CrashService',
|
'constructor': 'CrashService',
|
||||||
'categories': {'profile-after-change': 'CrashService'},
|
'categories': {'profile-after-change': 'CrashService'},
|
||||||
},
|
},
|
||||||
|
|
@ -16,7 +16,7 @@ Classes = [
|
||||||
'js_name': 'crashmanager',
|
'js_name': 'crashmanager',
|
||||||
'cid': '{c887b6a9-a5eb-4566-a440-bebaea3e54fd}',
|
'cid': '{c887b6a9-a5eb-4566-a440-bebaea3e54fd}',
|
||||||
'contract_ids': ['@mozilla.org/crashmanager;1'],
|
'contract_ids': ['@mozilla.org/crashmanager;1'],
|
||||||
'jsm': 'resource://gre/modules/CrashManager.jsm',
|
'esModule': 'resource://gre/modules/CrashManager.sys.mjs',
|
||||||
'constructor': 'getCrashManager',
|
'constructor': 'getCrashManager',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ From JavaScript, the service can be accessed via::
|
||||||
|
|
||||||
let crashManager = Services.crashmanager;
|
let crashManager = Services.crashmanager;
|
||||||
|
|
||||||
That will give you an instance of ``CrashManager`` from ``CrashManager.jsm``.
|
That will give you an instance of ``CrashManager`` from ``CrashManager.sys.mjs``.
|
||||||
From there, you can access and manipulate crash data.
|
From there, you can access and manipulate crash data.
|
||||||
|
|
||||||
The crash manager stores statistical information about crashes as well as
|
The crash manager stores statistical information about crashes as well as
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,15 @@ XPIDL_SOURCES += [
|
||||||
|
|
||||||
if CONFIG["MOZ_CRASHREPORTER"]:
|
if CONFIG["MOZ_CRASHREPORTER"]:
|
||||||
GeneratedFile(
|
GeneratedFile(
|
||||||
"CrashManager.jsm",
|
"CrashManager.sys.mjs",
|
||||||
script="gen_CrashManager.py",
|
script="gen_CrashManager.py",
|
||||||
entry_point="main",
|
entry_point="main",
|
||||||
inputs=["CrashManager.in.jsm"],
|
inputs=["CrashManager.in.sys.mjs"],
|
||||||
)
|
)
|
||||||
|
|
||||||
EXTRA_JS_MODULES += [
|
EXTRA_JS_MODULES += [
|
||||||
"!CrashManager.jsm",
|
"!CrashManager.sys.mjs",
|
||||||
"CrashService.jsm",
|
"CrashService.sys.mjs",
|
||||||
]
|
]
|
||||||
|
|
||||||
XPCOM_MANIFESTS += [
|
XPCOM_MANIFESTS += [
|
||||||
|
|
@ -35,7 +35,7 @@ if CONFIG["MOZ_CRASHREPORTER"]:
|
||||||
]
|
]
|
||||||
|
|
||||||
TESTING_JS_MODULES += [
|
TESTING_JS_MODULES += [
|
||||||
"CrashManagerTest.jsm",
|
"CrashManagerTest.sys.mjs",
|
||||||
]
|
]
|
||||||
|
|
||||||
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
|
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { CrashManager } = ChromeUtils.import(
|
const { CrashManager } = ChromeUtils.importESModule(
|
||||||
"resource://gre/modules/CrashManager.jsm"
|
"resource://gre/modules/CrashManager.sys.mjs"
|
||||||
);
|
);
|
||||||
const { TelemetryArchiveTesting } = ChromeUtils.importESModule(
|
const { TelemetryArchiveTesting } = ChromeUtils.importESModule(
|
||||||
"resource://testing-common/TelemetryArchiveTesting.sys.mjs"
|
"resource://testing-common/TelemetryArchiveTesting.sys.mjs"
|
||||||
);
|
);
|
||||||
const { configureLogging, getManager, sleep } = ChromeUtils.import(
|
const { configureLogging, getManager, sleep } = ChromeUtils.importESModule(
|
||||||
"resource://testing-common/CrashManagerTest.jsm"
|
"resource://testing-common/CrashManagerTest.sys.mjs"
|
||||||
);
|
);
|
||||||
const { TelemetryEnvironment } = ChromeUtils.importESModule(
|
const { TelemetryEnvironment } = ChromeUtils.importESModule(
|
||||||
"resource://gre/modules/TelemetryEnvironment.sys.mjs"
|
"resource://gre/modules/TelemetryEnvironment.sys.mjs"
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { getCrashManagerNoCreate } = ChromeUtils.import(
|
const { getCrashManagerNoCreate } = ChromeUtils.importESModule(
|
||||||
"resource://gre/modules/CrashManager.jsm"
|
"resource://gre/modules/CrashManager.sys.mjs"
|
||||||
);
|
);
|
||||||
const { makeFakeAppDir } = ChromeUtils.importESModule(
|
const { makeFakeAppDir } = ChromeUtils.importESModule(
|
||||||
"resource://testing-common/AppData.sys.mjs"
|
"resource://testing-common/AppData.sys.mjs"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { CrashManager, CrashStore, dateToDays } = ChromeUtils.import(
|
const { CrashManager, CrashStore, dateToDays } = ChromeUtils.importESModule(
|
||||||
"resource://gre/modules/CrashManager.jsm"
|
"resource://gre/modules/CrashManager.sys.mjs"
|
||||||
);
|
);
|
||||||
|
|
||||||
const DUMMY_DATE = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);
|
const DUMMY_DATE = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue