Bug 1024672 - Part 6: Allow storing multiple crash classifications. r=bsmedberg
--- a/toolkit/components/crashes/CrashManager.jsm
+++ b/toolkit/components/crashes/CrashManager.jsm
@@ -427,23 +427,23 @@ this.CrashManager.prototype = Object.fre
yield store.save();
}
}),
/**
* Set the classification of a crash.
*
* @param crashID (string) Crash ID. Likely a UUID.
- * @param classification (string) Crash classification/reason.
+ * @param classifications (array) Crash classifications.
*
- * @return boolean True if the classification was recorded and false if not.
+ * @return boolean True if the data was recorded and false if not.
*/
- setCrashClassification: Task.async(function* (crashID, classification) {
+ setCrashClassifications: Task.async(function* (crashID, classifications) {
let store = yield this._getStore();
- if (store.setCrashClassification(crashID, classification)) {
+ if (store.setCrashClassifications(crashID, classifications)) {
yield store.save();
}
}),
/**
* Obtain the paths of all unprocessed events files.
*
* The promise-resolved array is sorted by file mtime, oldest to newest.
@@ -1077,17 +1077,17 @@ CrashStore.prototype = Object.freeze({
}
this._data.crashes.set(id, {
id: id,
remoteID: null,
type: type,
crashDate: date,
submissions: new Map(),
- classification: null,
+ classifications: [],
});
}
let crash = this._data.crashes.get(id);
crash.type = type;
crash.crashDate = date;
return crash;
@@ -1188,25 +1188,25 @@ CrashStore.prototype = Object.freeze({
}
submission.responseDate = date;
submission.result = result;
return true;
},
/**
- * @return boolean True if the classification was set.
+ * @return boolean True if the classifications were set.
*/
- setCrashClassification: function (crashID, classification) {
+ setCrashClassifications: function (crashID, classifications) {
let crash = this._data.crashes.get(crashID);
if (!crash) {
return false;
}
- crash.classification = classification;
+ crash.classifications = classifications;
return true;
},
});
/**
* Represents an individual crash with metadata.
*
* This is a wrapper around the low-level anonymous JS objects that define
@@ -1257,18 +1257,18 @@ CrashRecord.prototype = Object.freeze({
isOfType: function (processType, crashType) {
return processType + "-" + crashType == this.type;
},
get submissions() {
return this._o.submissions;
},
- get classification() {
- return this._o.classification;
+ get classifications() {
+ return this._o.classifications;
},
});
/**
* Obtain the global CrashManager instance used by the running application.
*
* CrashManager is likely only ever instantiated once per application lifetime.
* The main reason it's implemented as a reusable type is to facilitate testing.
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
+++ b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
@@ -400,23 +400,24 @@ add_task(function* test_addSubmissionAtt
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_setCrashClassification() {
+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.setCrashClassification("main-crash", "class");
- Assert.equal((yield m.getCrashes())[0].classification, "class");
+ 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");
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_store.js
+++ b/toolkit/components/crashes/tests/xpcshell/test_crash_store.js
@@ -566,20 +566,25 @@ add_task(function* test_convertSubmissio
Assert.equal(submission.responseDate.getTime(), DUMMY_DATE_2.getTime());
});
add_task(function* test_setCrashClassification() {
let s = yield getStore();
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1",
new Date()));
- Assert.equal(s.crashes[0].classification, null);
+ let classifications = s.crashes[0].classifications;
+ Assert.ok(!!classifications);
+ Assert.equal(classifications.length, 0);
- Assert.ok(s.setCrashClassification("crash1", "foo"));
- Assert.equal(s.crashes[0].classification, "foo");
+ 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);