Bug 1381010 - After resizing the window, open the onboarding overlay but the tours would not appear. r=mossop
authorFischer.json <fischer.json@gmail.com>
Fri, 14 Jul 2017 21:41:26 +0800
changeset 369185 c94795e8415360b8e192a2c47874d811e5614026
parent 369184 299ad6c757d75cb4c0bed80847727d7eb7b9fdf6
child 369186 ec0dc3ef3bf73ed9e8159b0c25b17a7fcab55129
push id32192
push userkwierso@gmail.com
push dateTue, 18 Jul 2017 00:01:01 +0000
treeherdermozilla-central@efc0b1525edb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1381010
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -231,18 +231,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]);
       }
     });
@@ -278,16 +276,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);
@@ -409,16 +409,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);
     }
@@ -462,17 +463,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.