Bug 1238639 - HeapAnalysesWorker getCreationTime throws when given non-existant path;r=fitzgen

This commit is contained in:
Julian Descottes 2016-01-12 11:13:54 +01:00
parent 55ac9f732d
commit 1eaaa02678
2 changed files with 14 additions and 7 deletions

View File

@ -91,8 +91,10 @@ workerHelper.createTask(self, "takeCensusDiff", request => {
* @see HeapAnalysesClient.prototype.getCreationTime
*/
workerHelper.createTask(self, "getCreationTime", snapshotFilePath => {
let snapshot = snapshots[snapshotFilePath];
return snapshot ? snapshot.creationTime : null;
if (!snapshots[snapshotFilePath]) {
throw new Error(`No known heap snapshot for '${snapshotFilePath}'`);
}
return snapshots[snapshotFilePath].creationTime;
});
/**

View File

@ -32,12 +32,17 @@ add_task(function* () {
yield client.readHeapSnapshot(snapshotFilePath);
ok(true, "Should have read the heap snapshot");
let time = yield client.getCreationTime("/not/a/real/path", {
let threw = false;
try {
yield client.getCreationTime("/not/a/real/path", {
breakdown: BREAKDOWN
});
equal(time, null, "getCreationTime returns `null` when snapshot does not exist");
} catch (_) {
threw = true;
}
ok(threw, "getCreationTime should throw when snapshot does not exist");
time = yield client.getCreationTime(snapshotFilePath, {
let time = yield client.getCreationTime(snapshotFilePath, {
breakdown: BREAKDOWN
});
ok(time >= start, "creation time occurred after start");