Bug 1390260 - make customize mode work in popup windows, r=mkaply
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 15 Aug 2017 12:02:11 +0100
changeset 647056 fcadf039a35df7b80c7dcb0e619d844da3e7aa67
parent 647055 cca3c23a22351625a0739db35d6efb0fa4168d79
child 647057 ea6b6c96a66f84f4fa97743100f7404da64a4ac8
push id74288
push userhikezoe@mozilla.com
push dateWed, 16 Aug 2017 00:19:57 +0000
reviewersmkaply
bugs1390260
milestone57.0a1
Bug 1390260 - make customize mode work in popup windows, r=mkaply MozReview-Commit-ID: 7lokGRuqNHv
browser/components/customizableui/CustomizeMode.jsm
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -198,16 +198,31 @@ CustomizeMode.prototype = {
     win.addEventListener("unload", unregisterGlobalTab);
 
     if (gTab.selected) {
       win.gCustomizeMode.enter();
     }
   },
 
   enter() {
+    if (!this.window.toolbar.visible) {
+      let w = this.window.getTopWin(true);
+      if (w) {
+        w.gCustomizeMode.enter();
+        return;
+      }
+      let obs = () => {
+        Services.obs.removeObserver(obs, "browser-delayed-startup-finished");
+        w = this.window.getTopWin(true);
+        w.gCustomizeMode.enter();
+      };
+      Services.obs.addObserver(obs, "browser-delayed-startup-finished");
+      this.window.openUILinkIn("about:newtab", "window");
+      return;
+    }
     this._wantToBeInCustomizeMode = true;
 
     if (this._customizing || this._handler.isEnteringCustomizeMode) {
       return;
     }
 
     // Exiting; want to re-enter once we've done that.
     if (this._handler.isExitingCustomizeMode) {