Bug 1375490: Part 1 - Support alerts in OOP extension sidebars. r?mixedpuppy draft
authorKris Maglione <maglione.k@gmail.com>
Tue, 01 Aug 2017 15:44:05 -0700
changeset 619376 5e5d831e1b9ee7acc757ba812ef94954431d4935
parent 619375 73e5ca7d8bf08eff5e1ba57df3e8da18123cebd9
child 640373 9bcaa75e81928a0c0c54a0e30099bf7cb2a9bfee
push id71654
push usermaglione.k@gmail.com
push dateTue, 01 Aug 2017 22:44:34 +0000
reviewersmixedpuppy
bugs1375490
milestone56.0a1
Bug 1375490: Part 1 - Support alerts in OOP extension sidebars. r?mixedpuppy MozReview-Commit-ID: AbQ2uVcZzM4
browser/base/content/webext-panels.js
--- a/browser/base/content/webext-panels.js
+++ b/browser/base/content/webext-panels.js
@@ -19,16 +19,19 @@ var {
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 function getBrowser(sidebar) {
   let browser = document.getElementById("webext-panels-browser");
   if (browser) {
     return Promise.resolve(browser);
   }
 
+  let stack = document.createElementNS(XUL_NS, "stack");
+  stack.setAttribute("flex", "1");
+
   browser = document.createElementNS(XUL_NS, "browser");
   browser.setAttribute("id", "webext-panels-browser");
   browser.setAttribute("type", "content");
   browser.setAttribute("flex", "1");
   browser.setAttribute("disableglobalhistory", "true");
   browser.setAttribute("webextension-view-type", "sidebar");
   browser.setAttribute("context", "contentAreaContextMenu");
   browser.setAttribute("tooltip", "aHTMLTooltip");
@@ -45,17 +48,19 @@ function getBrowser(sidebar) {
 
     window.messageManager.addMessageListener("contextmenu", openContextMenu);
     window.addEventListener("unload", () => {
       window.messageManager.removeMessageListener("contextmenu", openContextMenu);
     }, {once: true});
   } else {
     readyPromise = Promise.resolve();
   }
-  document.documentElement.appendChild(browser);
+
+  stack.appendChild(browser);
+  document.documentElement.appendChild(stack);
 
   return readyPromise.then(() => {
     browser.messageManager.loadFrameScript("chrome://browser/content/content.js", false);
     ExtensionParent.apiManager.emit("extension-browser-inserted", browser);
 
     if (sidebar.browserStyle) {
       browser.messageManager.loadFrameScript(
         "chrome://extensions/content/ext-browser-content.js", false);
@@ -63,16 +68,30 @@ function getBrowser(sidebar) {
       browser.messageManager.sendAsyncMessage("Extension:InitBrowser", {
         stylesheets: ExtensionParent.extensionStylesheets,
       });
     }
     return browser;
   });
 }
 
+// Stub tabbrowser implementation for use by the tab-modal alert code.
+var gBrowser = {
+  getTabForBrowser(browser) {
+    return null;
+  },
+
+  getTabModalPromptBox(browser) {
+    if (!browser.tabModalPromptBox) {
+      browser.tabModalPromptBox = new TabModalPromptBox(browser);
+    }
+    return browser.tabModalPromptBox;
+  },
+};
+
 function loadWebPanel() {
   let sidebarURI = new URL(location);
   let sidebar = {
     uri: sidebarURI.searchParams.get("panel"),
     remote: sidebarURI.searchParams.get("remote"),
     browserStyle: sidebarURI.searchParams.get("browser-style"),
   };
   getBrowser(sidebar).then(browser => {