Bug 1381010 - After resizing the window, open the onboarding overlay but the tours would not appear. r=mossop
MozReview-Commit-ID: 3ZxuqTEJJu3
--- 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.