Bug 1381010 - After resizing the window, open the onboarding overlay but the tours would not appear. r=mossop draft
authorFischer.json <fischer.json@gmail.com>
Fri, 14 Jul 2017 21:41:26 +0800
changeset 609693 0c24d0da2f4b116e06bd6e72450d9f395c282100
parent 609596 aff336ac161daa3ea350e59a288963edbd58ed39
child 637628 fd77c698deb4fc54fb72832d6e80441792b5c3a8
push id68640
push userbmo:fliu@mozilla.com
push dateMon, 17 Jul 2017 08:33:12 +0000
reviewersmossop
bugs1381010
milestone56.0a1
Bug 1381010 - After resizing the window, open the onboarding overlay but the tours would not appear. r=mossop MozReview-Commit-ID: 3ZxuqTEJJu3
browser/extensions/onboarding/content/onboarding.js
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -228,18 +228,16 @@ var onboardingTourset = {
  */
 class Onboarding {
   constructor(contentWindow) {
     this.init(contentWindow);
   }
 
   async init(contentWindow) {
     this._window = contentWindow;
-    this._tourItems = [];
-    this._tourPages = [];
     this._tours = [];
 
     let tourIds = this._getTourIDList(Services.prefs.getStringPref("browser.onboarding.tour-type", "update"));
     tourIds.forEach(tourId => {
       if (onboardingTourset[tourId]) {
         this._tours.push(onboardingTourset[tourId]);
       }
     });
@@ -275,16 +273,18 @@ class Onboarding {
     }
   }
 
   _initUI() {
     if (this.uiInitialized) {
       return;
     }
     this.uiInitialized = true;
+    this._tourItems = [];
+    this._tourPages = [];
 
     this._overlayIcon = this._renderOverlayIcon();
     this._overlayIcon.addEventListener("click", this);
     this._window.document.body.appendChild(this._overlayIcon);
 
     this._overlay = this._renderOverlay();
     this._overlay.addEventListener("click", this);
     this._window.document.body.appendChild(this._overlay);
@@ -406,16 +406,17 @@ class Onboarding {
 
     this._clearPrefObserver();
     this._overlayIcon.remove();
     this._overlay.remove();
     if (this._notificationBar) {
       this._notificationBar.remove();
     }
 
+    this._tourItems = this._tourPages =
     this._overlayIcon = this._overlay = this._notificationBar = null;
   }
 
   toggleOverlay() {
     if (this._tourItems.length == 0) {
       // Lazy loading until first toggle.
       this._loadTours(this._tours);
     }
@@ -459,17 +460,17 @@ class Onboarding {
     });
     if (params.length > 0) {
       this.sendMessageToChrome("set-prefs", params);
     }
   }
 
   markTourCompletionState(tourId) {
     // We are doing lazy load so there might be no items.
-    if (this._tourItems.length > 0 && this.isTourCompleted(tourId)) {
+    if (this._tourItems && this._tourItems.length > 0 && this.isTourCompleted(tourId)) {
       let targetItem = this._tourItems.find(item => item.id == tourId);
       targetItem.classList.add("onboarding-complete");
     }
   }
 
   _muteNotificationOnFirstSession() {
     if (Preferences.isSet("browser.onboarding.notification.tour-ids-queue")) {
       // There is a queue. We had prompted before, this must not be the 1st session.