1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 export var CrashReports = {
9 getReports: function CrashReports_getReports() {
13 // Ignore any non http/https urls
14 if (!/^https?:/i.test(Services.prefs.getCharPref("breakpad.reportURL"))) {
19 if (this.submittedDir.exists() && this.submittedDir.isDirectory()) {
20 let entries = this.submittedDir.directoryEntries;
21 while (entries.hasMoreElements()) {
22 let file = entries.nextFile;
23 let leaf = file.leafName;
24 if (leaf.startsWith("bp-") && leaf.endsWith(".txt")) {
26 id: leaf.slice(0, -4),
27 date: file.lastModifiedTime,
35 if (this.pendingDir.exists() && this.pendingDir.isDirectory()) {
37 /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
38 let entries = this.pendingDir.directoryEntries;
39 while (entries.hasMoreElements()) {
40 let file = entries.nextFile;
41 let leaf = file.leafName;
42 let id = leaf.slice(0, -4);
43 if (leaf.endsWith(".dmp") && uuidRegex.test(id)) {
46 date: file.lastModifiedTime,
54 // Sort reports descending by date
55 return reports.sort((a, b) => b.date - a.date);
59 function CrashReports_pendingDir() {
60 let pendingDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
61 pendingDir.append("Crash Reports");
62 pendingDir.append("pending");
66 function CrashReports_reportsDir() {
67 let reportsDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
68 reportsDir.append("Crash Reports");
72 function CrashReports_submittedDir() {
73 let submittedDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
74 submittedDir.append("Crash Reports");
75 submittedDir.append("submitted");
79 CrashReports.pendingDir = CrashReports_pendingDir();
80 CrashReports.reportsDir = CrashReports_reportsDir();
81 CrashReports.submittedDir = CrashReports_submittedDir();