Bug 1471375 - Reports about missing activity stream content on new tab page and about:preferences#home panel. r?k88hudson
MozReview-Commit-ID: F5B2woeju1c
--- a/browser/extensions/activity-stream/lib/Store.jsm
+++ b/browser/extensions/activity-stream/lib/Store.jsm
@@ -147,17 +147,21 @@ this.Store = class Store {
async _initIndexedDB(telemetryKey) {
this.dbStorage = new ActivityStreamStorage({
storeNames: ["sectionPrefs", "snippets"],
telemetry: this.feeds.get(telemetryKey)
});
// Accessing the db causes the object stores to be created / migrated.
// This needs to happen before other instances try to access the db, which
// would update only a subset of the stores to the latest version.
- await this.dbStorage.db; // eslint-disable-line no-unused-expressions
+ try {
+ await this.dbStorage.db; // eslint-disable-line no-unused-expressions
+ } catch (e) {
+ this.dbStorage.telemetry = null;
+ }
}
/**
* uninit - Uninitalizes each feed, clears them, and destroys the message
* manager channel.
*
* @return {type} description
*/
--- a/browser/extensions/activity-stream/test/unit/lib/Store.test.js
+++ b/browser/extensions/activity-stream/test/unit/lib/Store.test.js
@@ -154,16 +154,26 @@ describe("Store", () => {
assert.calledWithExactly(store._initIndexedDB, "feeds.telemetry");
});
it("should access the db property of indexedDB", async () => {
store._initIndexedDB.restore();
await store.init(new Map());
assert.calledOnce(dbStub);
});
+ it("should reset ActivityStreamStorage telemetry if opening the db fails", async () => {
+ store._initIndexedDB.restore();
+ // Force an IndexedDB error
+ dbStub.rejects();
+
+ await store.init(new Map());
+
+ assert.calledOnce(dbStub);
+ assert.isNull(store.dbStorage.telemetry);
+ });
it("should not initialize the feed if the Pref is set to false", async () => {
sinon.stub(store, "initFeed");
store._prefs.set("foo", false);
await store.init(new Map([["foo", () => {}]]));
assert.notCalled(store.initFeed);
});
it("should observe the pref branch", async () => {
sinon.stub(store._prefs, "observeBranch");