toolkit/crashreporter/test/unit/test_event_files.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 "use strict";
michael@0 5
michael@0 6 const {utils: Cu} = Components;
michael@0 7
michael@0 8 Cu.import("resource://gre/modules/Promise.jsm", this);
michael@0 9 Cu.import("resource://gre/modules/Services.jsm", this);
michael@0 10 Cu.import("resource://testing-common/AppData.jsm", this);
michael@0 11
michael@0 12 function run_test() {
michael@0 13 run_next_test();
michael@0 14 }
michael@0 15
michael@0 16 add_task(function* test_setup() {
michael@0 17 do_get_profile();
michael@0 18 yield makeFakeAppDir();
michael@0 19 });
michael@0 20
michael@0 21 add_task(function* test_main_process_crash() {
michael@0 22 let cm = Services.crashmanager;
michael@0 23 Assert.ok(cm, "CrashManager available.");
michael@0 24
michael@0 25 let basename;
michael@0 26 let deferred = Promise.defer();
michael@0 27 do_crash("crashType = CrashTestUtils.CRASH_RUNTIMEABORT;",
michael@0 28 (minidump, extra) => {
michael@0 29 basename = minidump.leafName;
michael@0 30 cm._eventsDirs = [getEventDir()];
michael@0 31 cm.aggregateEventsFiles().then(deferred.resolve, deferred.reject);
michael@0 32 },
michael@0 33 true);
michael@0 34
michael@0 35 let count = yield deferred.promise;
michael@0 36 Assert.equal(count, 1, "A single crash event file was seen.");
michael@0 37 let crashes = yield cm.getCrashes();
michael@0 38 Assert.equal(crashes.length, 1);
michael@0 39 let crash = crashes[0];
michael@0 40 Assert.ok(crash.isMainProcessCrash);
michael@0 41 Assert.equal(crash.id + ".dmp", basename, "ID recorded properly");
michael@0 42 });

mercurial