Bug 1471375 - Reports about missing activity stream content on new tab page and about:preferences#home panel. r?k88hudson draft
authorEd Lee <edilee@mozilla.com>
Fri, 29 Jun 2018 09:40:49 -0700
changeset 812613 3220dc77184a
parent 812281 8f49b2a0e003
child 812684 e255b3d99127
child 812697 4a81e99f378e
push id114604
push userbmo:edilee@mozilla.com
push dateFri, 29 Jun 2018 17:25:07 +0000
reviewersk88hudson
bugs1471375
milestone63.0a1
Bug 1471375 - Reports about missing activity stream content on new tab page and about:preferences#home panel. r?k88hudson MozReview-Commit-ID: F5B2woeju1c
browser/extensions/activity-stream/lib/Store.jsm
browser/extensions/activity-stream/test/unit/lib/Store.test.js
--- 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");