Bug 1111022 - Changes UITour.jsm to work with windowless browsers. r=MattN, a=lmandel
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Sun, 25 Jan 2015 07:13:00 +0100
changeset 250115 f8c1586998ef
parent 250114 e7a0f9cd3482
child 250116 9b32fd0a9844
push id4503
push userryanvm@gmail.com
push date2015-02-27 21:34 +0000
treeherdermozilla-beta@87d76aead804 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, lmandel
bugs1111022
milestone37.0
Bug 1111022 - Changes UITour.jsm to work with windowless browsers. r=MattN, a=lmandel
browser/components/uitour/UITour.jsm
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -340,16 +340,25 @@ this.UITour = {
     Services.prefs.setCharPref(PREF_SEENPAGEIDS,
                                JSON.stringify([...this.seenPageIDs]));
   },
 
   onPageEvent: function(aMessage, aEvent) {
     let contentDocument = null;
     let browser = aMessage.target;
     let window = browser.ownerDocument.defaultView;
+
+    // Does the window have tabs? We need to make sure since windowless browsers do
+    // not have tabs.
+    if (!window.gBrowser) {
+      // When using windowless browsers we don't have a valid |window|. If that's the case,
+      // use the most recent window as a target for UITour functions (see Bug 1111022).
+      window = Services.wm.getMostRecentWindow("navigator:browser");
+    }
+
     let tab = window.gBrowser.getTabForBrowser(browser);
     let messageManager = browser.messageManager;
 
     log.debug("onPageEvent:", aEvent.detail, aMessage);
 
     if (typeof aEvent.detail != "object") {
       log.warn("Malformed event - detail not an object");
       return false;