summaryrefslogtreecommitdiffstats
path: root/toolkit/components/crashes
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/crashes
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/crashes')
-rw-r--r--toolkit/components/crashes/moz.build5
-rw-r--r--toolkit/components/crashes/tests/xpcshell/.eslintrc.js7
-rw-r--r--toolkit/components/crashes/tests/xpcshell/test_crash_manager.js494
-rw-r--r--toolkit/components/crashes/tests/xpcshell/test_crash_service.js31
-rw-r--r--toolkit/components/crashes/tests/xpcshell/test_crash_store.js587
-rw-r--r--toolkit/components/crashes/tests/xpcshell/xpcshell.ini8
6 files changed, 0 insertions, 1132 deletions
diff --git a/toolkit/components/crashes/moz.build b/toolkit/components/crashes/moz.build
index 5a36a3cd3..6efad5964 100644
--- a/toolkit/components/crashes/moz.build
+++ b/toolkit/components/crashes/moz.build
@@ -19,13 +19,8 @@ TESTING_JS_MODULES += [
'CrashManagerTest.jsm',
]
-XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
-
XPIDL_MODULE = 'toolkit_crashservice'
XPIDL_SOURCES += [
'nsICrashService.idl',
]
-
-with Files('**'):
- BUG_COMPONENT = ('Toolkit', 'Breakpad Integration')
diff --git a/toolkit/components/crashes/tests/xpcshell/.eslintrc.js b/toolkit/components/crashes/tests/xpcshell/.eslintrc.js
deleted file mode 100644
index d35787cd2..000000000
--- a/toolkit/components/crashes/tests/xpcshell/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = {
- "extends": [
- "../../../../../testing/xpcshell/xpcshell.eslintrc.js"
- ]
-};
diff --git a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
deleted file mode 100644
index 9844e78c4..000000000
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
+++ /dev/null
@@ -1,494 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-var bsp = Cu.import("resource://gre/modules/CrashManager.jsm", this);
-Cu.import("resource://gre/modules/Promise.jsm", this);
-Cu.import("resource://gre/modules/Task.jsm", this);
-Cu.import("resource://gre/modules/osfile.jsm", this);
-Cu.import("resource://gre/modules/TelemetryEnvironment.jsm", this);
-
-Cu.import("resource://testing-common/CrashManagerTest.jsm", this);
-Cu.import("resource://testing-common/TelemetryArchiveTesting.jsm", this);
-
-const DUMMY_DATE = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);
-DUMMY_DATE.setMilliseconds(0);
-
-const DUMMY_DATE_2 = new Date(Date.now() - 20 * 24 * 60 * 60 * 1000);
-DUMMY_DATE_2.setMilliseconds(0);
-
-function run_test() {
- do_get_profile();
- configureLogging();
- TelemetryArchiveTesting.setup();
- run_next_test();
-}
-
-add_task(function* test_constructor_ok() {
- let m = new CrashManager({
- pendingDumpsDir: "/foo",
- submittedDumpsDir: "/bar",
- eventsDirs: [],
- storeDir: "/baz",
- });
- Assert.ok(m, "CrashManager can be created.");
-});
-
-add_task(function* test_constructor_invalid() {
- Assert.throws(() => {
- new CrashManager({foo: true});
- });
-});
-
-add_task(function* test_get_manager() {
- let m = yield getManager();
- Assert.ok(m, "CrashManager obtained.");
-
- yield m.createDummyDump(true);
- yield m.createDummyDump(false);
-});
-
-// Unsubmitted dump files on disk are detected properly.
-add_task(function* test_pending_dumps() {
- let m = yield getManager();
- let now = Date.now();
- let ids = [];
- const COUNT = 5;
-
- for (let i = 0; i < COUNT; i++) {
- ids.push(yield m.createDummyDump(false, new Date(now - i * 86400000)));
- }
- yield m.createIgnoredDumpFile("ignored", false);
-
- let entries = yield m.pendingDumps();
- Assert.equal(entries.length, COUNT, "proper number detected.");
-
- for (let entry of entries) {
- Assert.equal(typeof(entry), "object", "entry is an object");
- Assert.ok("id" in entry, "id in entry");
- Assert.ok("path" in entry, "path in entry");
- Assert.ok("date" in entry, "date in entry");
- Assert.notEqual(ids.indexOf(entry.id), -1, "ID is known");
- }
-
- for (let i = 0; i < COUNT; i++) {
- Assert.equal(entries[i].id, ids[COUNT-i-1], "Entries sorted by mtime");
- }
-});
-
-// Submitted dump files on disk are detected properly.
-add_task(function* test_submitted_dumps() {
- let m = yield getManager();
- let COUNT = 5;
-
- for (let i = 0; i < COUNT; i++) {
- yield m.createDummyDump(true);
- }
- yield m.createIgnoredDumpFile("ignored", true);
-
- let entries = yield m.submittedDumps();
- Assert.equal(entries.length, COUNT, "proper number detected.");
-
- let hrID = yield m.createDummyDump(true, new Date(), true);
- entries = yield m.submittedDumps();
- Assert.equal(entries.length, COUNT + 1, "hr- in filename detected.");
-
- let gotIDs = new Set(entries.map(e => e.id));
- Assert.ok(gotIDs.has(hrID));
-});
-
-// The store should expire after inactivity.
-add_task(function* test_store_expires() {
- let m = yield getManager();
-
- Object.defineProperty(m, "STORE_EXPIRATION_MS", {
- value: 250,
- });
-
- let store = yield m._getStore();
- Assert.ok(store);
- Assert.equal(store, m._store);
-
- yield sleep(300);
- Assert.ok(!m._store, "Store has gone away.");
-});
-
-// Ensure discovery of unprocessed events files works.
-add_task(function* test_unprocessed_events_files() {
- let m = yield getManager();
- yield m.createEventsFile("1", "test.1", new Date(), "foo", 0);
- yield m.createEventsFile("2", "test.1", new Date(), "bar", 0);
- yield m.createEventsFile("1", "test.1", new Date(), "baz", 1);
-
- let paths = yield m._getUnprocessedEventsFiles();
- Assert.equal(paths.length, 3);
-});
-
-// Ensure only 1 aggregateEventsFiles() is allowed at a time.
-add_task(function* test_aggregate_events_locking() {
- let m = yield getManager();
-
- let p1 = m.aggregateEventsFiles();
- let p2 = m.aggregateEventsFiles();
-
- Assert.strictEqual(p1, p2, "Same promise should be returned.");
-});
-
-// Malformed events files should be deleted.
-add_task(function* test_malformed_files_deleted() {
- let m = yield getManager();
-
- yield m.createEventsFile("1", "crash.main.1", new Date(), "foo\nbar");
-
- let count = yield m.aggregateEventsFiles();
- Assert.equal(count, 1);
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 0);
-
- count = yield m.aggregateEventsFiles();
- Assert.equal(count, 0);
-});
-
-// Unknown event types should be ignored.
-add_task(function* test_aggregate_ignore_unknown_events() {
- let m = yield getManager();
-
- yield m.createEventsFile("1", "crash.main.2", DUMMY_DATE, "id1");
- yield m.createEventsFile("2", "foobar.1", new Date(), "dummy");
-
- let count = yield m.aggregateEventsFiles();
- Assert.equal(count, 2);
-
- count = yield m.aggregateEventsFiles();
- Assert.equal(count, 1);
-
- count = yield m.aggregateEventsFiles();
- Assert.equal(count, 1);
-});
-
-add_task(function* test_prune_old() {
- let m = yield getManager();
- let oldDate = new Date(Date.now() - 86400000);
- let newDate = new Date(Date.now() - 10000);
- yield m.createEventsFile("1", "crash.main.2", oldDate, "id1");
- yield m.addCrash(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_CRASH, "id2", newDate);
-
- yield m.aggregateEventsFiles();
-
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 2);
-
- yield m.pruneOldCrashes(new Date(oldDate.getTime() + 10000));
-
- crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 1, "Old crash has been pruned.");
-
- let c = crashes[0];
- Assert.equal(c.id, "id2", "Proper crash was pruned.");
-
- // We can't test exact boundary conditions because dates from filesystem
- // don't have same guarantees as JS dates.
- yield m.pruneOldCrashes(new Date(newDate.getTime() + 5000));
- crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 0);
-});
-
-add_task(function* test_schedule_maintenance() {
- let m = yield getManager();
- yield m.createEventsFile("1", "crash.main.2", DUMMY_DATE, "id1");
-
- let oldDate = new Date(Date.now() - m.PURGE_OLDER_THAN_DAYS * 2 * 24 * 60 * 60 * 1000);
- yield m.createEventsFile("2", "crash.main.2", oldDate, "id2");
-
- yield m.scheduleMaintenance(25);
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 1);
- Assert.equal(crashes[0].id, "id1");
-});
-
-add_task(function* test_main_crash_event_file() {
- let ac = new TelemetryArchiveTesting.Checker();
- yield ac.promiseInit();
- let theEnvironment = TelemetryEnvironment.currentEnvironment;
- let sessionId = "be66af2f-2ee5-4330-ae95-44462dfbdf0c";
- let stackTraces = { status: "OK" };
-
- // To test proper escaping, add data to the environment with an embedded
- // double-quote
- theEnvironment.testValue = "MyValue\"";
-
- let m = yield getManager();
- const fileContent = "id1\nk1=v1\nk2=v2\n" +
- "TelemetryEnvironment=" + JSON.stringify(theEnvironment) + "\n" +
- "TelemetrySessionId=" + sessionId + "\n" +
- "StackTraces=" + JSON.stringify(stackTraces) + "\n";
-
- yield m.createEventsFile("1", "crash.main.2", DUMMY_DATE, fileContent);
- let count = yield m.aggregateEventsFiles();
- Assert.equal(count, 1);
-
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 1);
- Assert.equal(crashes[0].id, "id1");
- Assert.equal(crashes[0].type, "main-crash");
- Assert.equal(crashes[0].metadata.k1, "v1");
- Assert.equal(crashes[0].metadata.k2, "v2");
- Assert.ok(crashes[0].metadata.TelemetryEnvironment);
- Assert.equal(Object.getOwnPropertyNames(crashes[0].metadata).length, 5);
- Assert.equal(crashes[0].metadata.TelemetrySessionId, sessionId);
- Assert.ok(crashes[0].metadata.StackTraces);
- Assert.deepEqual(crashes[0].crashDate, DUMMY_DATE);
-
- let found = yield ac.promiseFindPing("crash", [
- [["payload", "hasCrashEnvironment"], true],
- [["payload", "metadata", "k1"], "v1"],
- [["payload", "crashId"], "1"],
- [["payload", "stackTraces", "status"], "OK"],
- [["payload", "sessionId"], sessionId],
- ]);
- Assert.ok(found, "Telemetry ping submitted for found crash");
- Assert.deepEqual(found.environment, theEnvironment, "The saved environment should be present");
-
- count = yield m.aggregateEventsFiles();
- Assert.equal(count, 0);
-});
-
-add_task(function* test_main_crash_event_file_noenv() {
- let ac = new TelemetryArchiveTesting.Checker();
- yield ac.promiseInit();
-
- let m = yield getManager();
- yield m.createEventsFile("1", "crash.main.2", DUMMY_DATE, "id1\nk1=v3\nk2=v2");
- let count = yield m.aggregateEventsFiles();
- Assert.equal(count, 1);
-
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 1);
- Assert.equal(crashes[0].id, "id1");
- Assert.equal(crashes[0].type, "main-crash");
- Assert.deepEqual(crashes[0].metadata, { k1: "v3", k2: "v2"});
- Assert.deepEqual(crashes[0].crashDate, DUMMY_DATE);
-
- let found = yield ac.promiseFindPing("crash", [
- [["payload", "hasCrashEnvironment"], false],
- [["payload", "metadata", "k1"], "v3"],
- ]);
- Assert.ok(found, "Telemetry ping submitted for found crash");
- Assert.ok(found.environment, "There is an environment");
-
- count = yield m.aggregateEventsFiles();
- Assert.equal(count, 0);
-});
-
-add_task(function* test_crash_submission_event_file() {
- let m = yield getManager();
- yield m.createEventsFile("1", "crash.main.2", DUMMY_DATE, "crash1");
- yield m.createEventsFile("1-submission", "crash.submission.1", DUMMY_DATE_2,
- "crash1\nfalse\n");
-
- // The line below has been intentionally commented out to make sure that
- // the crash record is created when one does not exist.
- // yield m.createEventsFile("2", "crash.main.1", DUMMY_DATE, "crash2");
- yield m.createEventsFile("2-submission", "crash.submission.1", DUMMY_DATE_2,
- "crash2\ntrue\nbp-2");
- let count = yield m.aggregateEventsFiles();
- Assert.equal(count, 3);
-
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 2);
-
- let map = new Map(crashes.map(crash => [crash.id, crash]));
-
- let crash1 = map.get("crash1");
- Assert.ok(!!crash1);
- Assert.equal(crash1.remoteID, null);
- let crash2 = map.get("crash2");
- Assert.ok(!!crash2);
- Assert.equal(crash2.remoteID, "bp-2");
-
- Assert.equal(crash1.submissions.size, 1);
- let submission = crash1.submissions.values().next().value;
- Assert.equal(submission.result, m.SUBMISSION_RESULT_FAILED);
- Assert.equal(submission.requestDate.getTime(), DUMMY_DATE_2.getTime());
- Assert.equal(submission.responseDate.getTime(), DUMMY_DATE_2.getTime());
-
- Assert.equal(crash2.submissions.size, 1);
- submission = crash2.submissions.values().next().value;
- Assert.equal(submission.result, m.SUBMISSION_RESULT_OK);
- Assert.equal(submission.requestDate.getTime(), DUMMY_DATE_2.getTime());
- Assert.equal(submission.responseDate.getTime(), DUMMY_DATE_2.getTime());
-
- count = yield m.aggregateEventsFiles();
- Assert.equal(count, 0);
-});
-
-add_task(function* test_multiline_crash_id_rejected() {
- let m = yield getManager();
- yield m.createEventsFile("1", "crash.main.1", DUMMY_DATE, "id1\nid2");
- yield m.aggregateEventsFiles();
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 0);
-});
-
-// Main process crashes should be remembered beyond the high water mark.
-add_task(function* test_high_water_mark() {
- let m = yield getManager();
-
- let store = yield m._getStore();
-
- for (let i = 0; i < store.HIGH_WATER_DAILY_THRESHOLD + 1; i++) {
- yield m.createEventsFile("m" + i, "crash.main.2", DUMMY_DATE, "m" + i);
- }
-
- let count = yield m.aggregateEventsFiles();
- Assert.equal(count, bsp.CrashStore.prototype.HIGH_WATER_DAILY_THRESHOLD + 1);
-
- // Need to fetch again in case the first one was garbage collected.
- store = yield m._getStore();
-
- Assert.equal(store.crashesCount, store.HIGH_WATER_DAILY_THRESHOLD + 1);
-});
-
-add_task(function* test_addCrash() {
- let m = yield getManager();
-
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 0);
-
- yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
- "main-crash", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_HANG,
- "main-hang", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_CRASH,
- "content-crash", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG,
- "content-hang", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_CRASH,
- "plugin-crash", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_HANG,
- "plugin-hang", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_GMPLUGIN, m.CRASH_TYPE_CRASH,
- "gmplugin-crash", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_GPU, m.CRASH_TYPE_CRASH,
- "gpu-crash", DUMMY_DATE);
-
- yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
- "changing-item", DUMMY_DATE);
- yield m.addCrash(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG,
- "changing-item", DUMMY_DATE_2);
-
- crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 9);
-
- let map = new Map(crashes.map(crash => [crash.id, crash]));
-
- let crash = map.get("main-crash");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_MAIN + "-" + m.CRASH_TYPE_CRASH);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH));
-
- crash = map.get("main-hang");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_MAIN + "-" + m.CRASH_TYPE_HANG);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_HANG));
-
- crash = map.get("content-crash");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_CRASH);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_CRASH));
-
- crash = map.get("content-hang");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_HANG);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG));
-
- crash = map.get("plugin-crash");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_PLUGIN + "-" + m.CRASH_TYPE_CRASH);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_CRASH));
-
- crash = map.get("plugin-hang");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_PLUGIN + "-" + m.CRASH_TYPE_HANG);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_PLUGIN, m.CRASH_TYPE_HANG));
-
- crash = map.get("gmplugin-crash");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_GMPLUGIN + "-" + m.CRASH_TYPE_CRASH);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_GMPLUGIN, m.CRASH_TYPE_CRASH));
-
- crash = map.get("gpu-crash");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE);
- Assert.equal(crash.type, m.PROCESS_TYPE_GPU+ "-" + m.CRASH_TYPE_CRASH);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_GPU, m.CRASH_TYPE_CRASH));
-
- crash = map.get("changing-item");
- Assert.ok(!!crash);
- Assert.equal(crash.crashDate, DUMMY_DATE_2);
- Assert.equal(crash.type, m.PROCESS_TYPE_CONTENT + "-" + m.CRASH_TYPE_HANG);
- Assert.ok(crash.isOfType(m.PROCESS_TYPE_CONTENT, m.CRASH_TYPE_HANG));
-});
-
-add_task(function* test_generateSubmissionID() {
- let m = yield getManager();
-
- const SUBMISSION_ID_REGEX =
- /^(sub-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
- let id = m.generateSubmissionID();
- Assert.ok(SUBMISSION_ID_REGEX.test(id));
-});
-
-add_task(function* test_addSubmissionAttemptAndResult() {
- let m = yield getManager();
-
- let crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 0);
-
- yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
- "main-crash", DUMMY_DATE);
- yield m.addSubmissionAttempt("main-crash", "submission", DUMMY_DATE);
- yield m.addSubmissionResult("main-crash", "submission", DUMMY_DATE_2,
- m.SUBMISSION_RESULT_OK);
-
- crashes = yield m.getCrashes();
- Assert.equal(crashes.length, 1);
-
- let submissions = crashes[0].submissions;
- Assert.ok(!!submissions);
-
- let submission = submissions.get("submission");
- Assert.ok(!!submission);
- Assert.equal(submission.requestDate.getTime(), DUMMY_DATE.getTime());
- Assert.equal(submission.responseDate.getTime(), DUMMY_DATE_2.getTime());
- Assert.equal(submission.result, m.SUBMISSION_RESULT_OK);
-});
-
-add_task(function* test_setCrashClassifications() {
- let m = yield getManager();
-
- yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
- "main-crash", DUMMY_DATE);
- yield m.setCrashClassifications("main-crash", ["a"]);
- let classifications = (yield m.getCrashes())[0].classifications;
- Assert.ok(classifications.indexOf("a") != -1);
-});
-
-add_task(function* test_setRemoteCrashID() {
- let m = yield getManager();
-
- yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
- "main-crash", DUMMY_DATE);
- yield m.setRemoteCrashID("main-crash", "bp-1");
- Assert.equal((yield m.getCrashes())[0].remoteID, "bp-1");
-});
diff --git a/toolkit/components/crashes/tests/xpcshell/test_crash_service.js b/toolkit/components/crashes/tests/xpcshell/test_crash_service.js
deleted file mode 100644
index c207057e0..000000000
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_service.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-Cu.import("resource://gre/modules/Services.jsm", this);
-Cu.import("resource://testing-common/AppData.jsm", this);
-var bsp = Cu.import("resource://gre/modules/CrashManager.jsm", this);
-
-function run_test() {
- run_next_test();
-}
-
-add_task(function* test_instantiation() {
- Assert.ok(!bsp.gCrashManager, "CrashManager global instance not initially defined.");
-
- do_get_profile();
- yield makeFakeAppDir();
-
- // Fake profile creation.
- Cc["@mozilla.org/crashservice;1"]
- .getService(Ci.nsIObserver)
- .observe(null, "profile-after-change", null);
-
- Assert.ok(bsp.gCrashManager, "Profile creation makes it available.");
- Assert.ok(Services.crashmanager, "CrashManager available via Services.");
- Assert.strictEqual(bsp.gCrashManager, Services.crashmanager,
- "The objects are the same.");
-});
diff --git a/toolkit/components/crashes/tests/xpcshell/test_crash_store.js b/toolkit/components/crashes/tests/xpcshell/test_crash_store.js
deleted file mode 100644
index 12b180e91..000000000
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_store.js
+++ /dev/null
@@ -1,587 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/*
- * This file tests the CrashStore type in CrashManager.jsm.
- */
-
-"use strict";
-
-var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-var bsp = Cu.import("resource://gre/modules/CrashManager.jsm", this);
-Cu.import("resource://gre/modules/osfile.jsm", this);
-Cu.import("resource://gre/modules/Task.jsm", this);
-
-const DUMMY_DATE = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);
-DUMMY_DATE.setMilliseconds(0);
-
-const DUMMY_DATE_2 = new Date(Date.now() - 5 * 24 * 60 * 60 * 1000);
-DUMMY_DATE_2.setMilliseconds(0);
-
-const {
- PROCESS_TYPE_MAIN,
- PROCESS_TYPE_CONTENT,
- PROCESS_TYPE_PLUGIN,
- PROCESS_TYPE_GMPLUGIN,
- PROCESS_TYPE_GPU,
- CRASH_TYPE_CRASH,
- CRASH_TYPE_HANG,
- SUBMISSION_RESULT_OK,
- SUBMISSION_RESULT_FAILED,
-} = CrashManager.prototype;
-
-const CrashStore = bsp.CrashStore;
-
-var STORE_DIR_COUNT = 0;
-
-function getStore() {
- return Task.spawn(function* () {
- let storeDir = do_get_tempdir().path;
- storeDir = OS.Path.join(storeDir, "store-" + STORE_DIR_COUNT++);
-
- yield OS.File.makeDir(storeDir, {unixMode: OS.Constants.libc.S_IRWXU});
-
- let s = new CrashStore(storeDir);
- yield s.load();
-
- return s;
- });
-}
-
-function run_test() {
- run_next_test();
-}
-
-add_task(function* test_constructor() {
- let s = new CrashStore("/some/path");
- Assert.ok(s instanceof CrashStore);
-});
-
-add_task(function* test_add_crash() {
- let s = yield getStore();
-
- Assert.equal(s.crashesCount, 0);
- let d = new Date(Date.now() - 5000);
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", d));
-
- Assert.equal(s.crashesCount, 1);
-
- let crashes = s.crashes;
- Assert.equal(crashes.length, 1);
- let c = crashes[0];
-
- Assert.equal(c.id, "id1", "ID set properly.");
- Assert.equal(c.crashDate.getTime(), d.getTime(), "Date set.");
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-});
-
-add_task(function* test_reset() {
- let s = yield getStore();
-
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", DUMMY_DATE));
- Assert.equal(s.crashes.length, 1);
- s.reset();
- Assert.equal(s.crashes.length, 0);
-});
-
-add_task(function* test_save_load() {
- let s = yield getStore();
-
- yield s.save();
-
- let d1 = new Date();
- let d2 = new Date(d1.getTime() - 10000);
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", d1));
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", d2));
- Assert.ok(s.addSubmissionAttempt("id1", "sub1", d1));
- Assert.ok(s.addSubmissionResult("id1", "sub1", d2, SUBMISSION_RESULT_OK));
- Assert.ok(s.setRemoteCrashID("id1", "bp-1"));
-
- yield s.save();
-
- yield s.load();
- Assert.ok(!s.corruptDate);
- let crashes = s.crashes;
-
- Assert.equal(crashes.length, 2);
- let c = s.getCrash("id1");
- Assert.equal(c.crashDate.getTime(), d1.getTime());
- Assert.equal(c.remoteID, "bp-1");
-
- Assert.ok(!!c.submissions);
- let submission = c.submissions.get("sub1");
- Assert.ok(!!submission);
- Assert.equal(submission.requestDate.getTime(), d1.getTime());
- Assert.equal(submission.responseDate.getTime(), d2.getTime());
- Assert.equal(submission.result, SUBMISSION_RESULT_OK);
-});
-
-add_task(function* test_corrupt_json() {
- let s = yield getStore();
-
- let buffer = new TextEncoder().encode("{bad: json-file");
- yield OS.File.writeAtomic(s._storePath, buffer, {compression: "lz4"});
-
- yield s.load();
- Assert.ok(s.corruptDate, "Corrupt date is defined.");
-
- let date = s.corruptDate;
- yield s.save();
- s._data = null;
- yield s.load();
- Assert.ok(s.corruptDate);
- Assert.equal(date.getTime(), s.corruptDate.getTime());
-});
-
-add_task(function* test_add_main_crash() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH);
- Assert.ok(c.isOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- // Duplicate.
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id3", new Date(),
- { OOMAllocationSize: 1048576 })
- );
- Assert.equal(s.crashesCount, 3);
- Assert.deepEqual(s.crashes[2].metadata, { OOMAllocationSize: 1048576 });
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 3);
-});
-
-add_task(function* test_add_main_hang() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG);
- Assert.ok(c.isOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_content_crash() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH);
- Assert.ok(c.isOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_content_hang() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG);
- Assert.ok(c.isOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_plugin_crash() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_CRASH);
- Assert.ok(c.isOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_plugin_hang() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_HANG);
- Assert.ok(c.isOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_gmplugin_crash() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_GMPLUGIN + "-" + CRASH_TYPE_CRASH);
- Assert.ok(c.isOfType(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_gpu_crash() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 1);
-
- let c = s.crashes[0];
- Assert.ok(c.crashDate);
- Assert.equal(c.type, PROCESS_TYPE_GPU + "-" + CRASH_TYPE_CRASH);
- Assert.ok(c.isOfType(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH));
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "id2", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "id1", new Date())
- );
- Assert.equal(s.crashesCount, 2);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2);
-});
-
-add_task(function* test_add_mixed_types() {
- let s = yield getStore();
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mcrash", new Date()) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mhang", new Date()) &&
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "ccrash", new Date()) &&
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "chang", new Date()) &&
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pcrash", new Date()) &&
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "phang", new Date()) &&
- s.addCrash(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH, "gmpcrash", new Date()) &&
- s.addCrash(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH, "gpucrash", new Date())
- );
-
- Assert.equal(s.crashesCount, 8);
-
- yield s.save();
-
- s._data.crashes.clear();
- Assert.equal(s.crashesCount, 0);
-
- yield s.load();
-
- Assert.equal(s.crashesCount, 8);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_GMPLUGIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 1);
- crashes = s.getCrashesOfType(PROCESS_TYPE_GPU, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 1);
-});
-
-// Crashes added beyond the high water mark behave properly.
-add_task(function* test_high_water() {
- let s = yield getStore();
-
- let d1 = new Date(2014, 0, 1, 0, 0, 0);
- let d2 = new Date(2014, 0, 2, 0, 0, 0);
-
- let i = 0;
- for (; i < s.HIGH_WATER_DAILY_THRESHOLD; i++) {
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc2" + i, d2) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh2" + i, d2) &&
-
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc2" + i, d2) &&
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch2" + i, d2) &&
-
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc2" + i, d2) &&
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph2" + i, d2)
- );
- }
-
- Assert.ok(
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "mc2" + i, d2) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh1" + i, d1) &&
- s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG, "mh2" + i, d2)
- );
-
- Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc1" + i, d1));
- Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH, "cc2" + i, d2));
- Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch1" + i, d1));
- Assert.ok(!s.addCrash(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG, "ch2" + i, d2));
-
- Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc1" + i, d1));
- Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH, "pc2" + i, d2));
- Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph1" + i, d1));
- Assert.ok(!s.addCrash(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG, "ph2" + i, d2));
-
- // We preserve main process crashes and hangs. Content and plugin crashes and
- // hangs beyond should be discarded.
- Assert.equal(s.crashesCount, 12 * s.HIGH_WATER_DAILY_THRESHOLD + 4);
-
- let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
- crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD + 2);
-
- crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
- crashes = s.getCrashesOfType(PROCESS_TYPE_CONTENT, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
-
- crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_CRASH);
- Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
- crashes = s.getCrashesOfType(PROCESS_TYPE_PLUGIN, CRASH_TYPE_HANG);
- Assert.equal(crashes.length, 2 * s.HIGH_WATER_DAILY_THRESHOLD);
-
- // But raw counts should be preserved.
- let day1 = bsp.dateToDays(d1);
- let day2 = bsp.dateToDays(d2);
- Assert.ok(s._countsByDay.has(day1));
- Assert.ok(s._countsByDay.has(day2));
-
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
-
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
-
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_CRASH),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_HANG),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
-
- yield s.save();
- yield s.load();
-
- Assert.ok(s._countsByDay.has(day1));
- Assert.ok(s._countsByDay.has(day2));
-
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_CRASH),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_MAIN + "-" + CRASH_TYPE_HANG),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
-
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_CRASH),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_CONTENT + "-" + CRASH_TYPE_HANG),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
-
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_CRASH),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
- Assert.equal(s._countsByDay.get(day1).
- get(PROCESS_TYPE_PLUGIN + "-" + CRASH_TYPE_HANG),
- s.HIGH_WATER_DAILY_THRESHOLD + 1);
-});
-
-add_task(function* test_addSubmission() {
- let s = yield getStore();
-
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1",
- DUMMY_DATE));
-
- Assert.ok(s.addSubmissionAttempt("crash1", "sub1", DUMMY_DATE));
-
- let crash = s.getCrash("crash1");
- let submission = crash.submissions.get("sub1");
- Assert.ok(!!submission);
- Assert.equal(submission.requestDate.getTime(), DUMMY_DATE.getTime());
- Assert.equal(submission.responseDate, null);
- Assert.equal(submission.result, null);
-
- Assert.ok(s.addSubmissionResult("crash1", "sub1", DUMMY_DATE_2,
- SUBMISSION_RESULT_FAILED));
-
- crash = s.getCrash("crash1");
- Assert.equal(crash.submissions.size, 1);
- submission = crash.submissions.get("sub1");
- Assert.ok(!!submission);
- Assert.equal(submission.requestDate.getTime(), DUMMY_DATE.getTime());
- Assert.equal(submission.responseDate.getTime(), DUMMY_DATE_2.getTime());
- Assert.equal(submission.result, SUBMISSION_RESULT_FAILED);
-
- Assert.ok(s.addSubmissionAttempt("crash1", "sub2", DUMMY_DATE));
- Assert.ok(s.addSubmissionResult("crash1", "sub2", DUMMY_DATE_2,
- SUBMISSION_RESULT_OK));
-
- Assert.equal(crash.submissions.size, 2);
- submission = crash.submissions.get("sub2");
- Assert.ok(!!submission);
- Assert.equal(submission.result, SUBMISSION_RESULT_OK);
-});
-
-add_task(function* test_setCrashClassification() {
- let s = yield getStore();
-
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1",
- new Date()));
- let classifications = s.crashes[0].classifications;
- Assert.ok(!!classifications);
- Assert.equal(classifications.length, 0);
-
- Assert.ok(s.setCrashClassifications("crash1", ["foo", "bar"]));
- classifications = s.crashes[0].classifications;
- Assert.equal(classifications.length, 2);
- Assert.ok(classifications.indexOf("foo") != -1);
- Assert.ok(classifications.indexOf("bar") != -1);
-});
-
-add_task(function* test_setRemoteCrashID() {
- let s = yield getStore();
-
- Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1",
- new Date()));
- Assert.equal(s.crashes[0].remoteID, null);
- Assert.ok(s.setRemoteCrashID("crash1", "bp-1"));
- Assert.equal(s.crashes[0].remoteID, "bp-1");
-});
-
diff --git a/toolkit/components/crashes/tests/xpcshell/xpcshell.ini b/toolkit/components/crashes/tests/xpcshell/xpcshell.ini
deleted file mode 100644
index 5cb8a69d5..000000000
--- a/toolkit/components/crashes/tests/xpcshell/xpcshell.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[DEFAULT]
-head =
-tail =
-skip-if = toolkit == 'android'
-
-[test_crash_manager.js]
-[test_crash_service.js]
-[test_crash_store.js]