summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/CrashSubmit.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/crashreporter/CrashSubmit.sys.mjs')
-rw-r--r--toolkit/crashreporter/CrashSubmit.sys.mjs93
1 files changed, 11 insertions, 82 deletions
diff --git a/toolkit/crashreporter/CrashSubmit.sys.mjs b/toolkit/crashreporter/CrashSubmit.sys.mjs
index 28647c5a83..72ff5dc30f 100644
--- a/toolkit/crashreporter/CrashSubmit.sys.mjs
+++ b/toolkit/crashreporter/CrashSubmit.sys.mjs
@@ -2,8 +2,6 @@
* 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/. */
-import { FileUtils } from "resource://gre/modules/FileUtils.sys.mjs";
-
const SUCCESS = "success";
const FAILED = "failed";
const SUBMITTING = "submitting";
@@ -13,81 +11,6 @@ const UUID_REGEX =
const SUBMISSION_REGEX =
/^bp-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
-// TODO: this is still synchronous; need an async INI parser to make it async
-function parseINIStrings(path) {
- let file = new FileUtils.File(path);
- let factory = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].getService(
- Ci.nsIINIParserFactory
- );
- let parser = factory.createINIParser(file);
- let obj = {};
- for (let key of parser.getKeys("Strings")) {
- obj[key] = parser.getString("Strings", key);
- }
- return obj;
-}
-
-// Since we're basically re-implementing (with async) part of the crashreporter
-// client here, we'll just steal the strings we need from crashreporter.ini
-async function getL10nStrings() {
- let path = PathUtils.join(
- Services.dirsvc.get("GreD", Ci.nsIFile).path,
- "crashreporter.ini"
- );
- let pathExists = await IOUtils.exists(path);
-
- if (!pathExists) {
- // we if we're on a mac
- let parentDir = PathUtils.parent(path);
- path = PathUtils.join(
- parentDir,
- "MacOS",
- "crashreporter.app",
- "Contents",
- "Resources",
- "crashreporter.ini"
- );
-
- let pathExists = await IOUtils.exists(path);
-
- if (!pathExists) {
- // This happens on Android where everything is in an APK.
- // Android users can't see the contents of the submitted files
- // anyway, so just hardcode some fallback strings.
- return {
- crashid: "Crash ID: %s",
- reporturl: "You can view details of this crash at %s",
- };
- }
- }
-
- let crstrings = parseINIStrings(path);
- let strings = {
- crashid: crstrings.CrashID,
- reporturl: crstrings.CrashDetailsURL,
- };
-
- path = PathUtils.join(
- Services.dirsvc.get("XCurProcD", Ci.nsIFile).path,
- "crashreporter-override.ini"
- );
- pathExists = await IOUtils.exists(path);
-
- if (pathExists) {
- crstrings = parseINIStrings(path);
-
- if ("CrashID" in crstrings) {
- strings.crashid = crstrings.CrashID;
- }
-
- if ("CrashDetailsURL" in crstrings) {
- strings.reporturl = crstrings.CrashDetailsURL;
- }
- }
-
- return strings;
-}
-
function getDir(name) {
let uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path;
return PathUtils.join(uAppDataPath, "Crash Reports", name);
@@ -109,11 +32,17 @@ function getPendingMinidump(id) {
}
async function writeSubmittedReportAsync(crashID, viewURL) {
- let strings = await getL10nStrings();
- let data = strings.crashid.replace("%s", crashID);
-
+ // Since we're basically re-implementing (with async) part of the
+ // crashreporter client here, we'll use the strings we need from the
+ // crashreporter fluent file.
+ const l10n = new Localization(["crashreporter/crashreporter.ftl"]);
+ let data = await l10n.formatValue("crashreporter-crash-identifier", {
+ id: crashID,
+ });
if (viewURL) {
- data += "\n" + strings.reporturl.replace("%s", viewURL);
+ data +=
+ "\n" +
+ (await l10n.formatValue("crashreporter-crash-details", { url: viewURL }));
}
await writeFileAsync("submitted", `${crashID}.txt`, data);
@@ -259,7 +188,7 @@ Submitter.prototype = {
let manager = Services.crashmanager;
let submissionID = manager.generateSubmissionID();
- xhr.addEventListener("readystatechange", evt => {
+ xhr.addEventListener("readystatechange", () => {
if (xhr.readyState == 4) {
let ret =
xhr.status === 200 ? this.parseResponse(xhr.responseText) : {};