Bug 1256289 force external links to open in tabs if non-tab browser, r?kmag
MozReview-Commit-ID: 3Xn6XvjZ8KG
--- a/toolkit/components/extensions/ExtensionChild.jsm
+++ b/toolkit/components/extensions/ExtensionChild.jsm
@@ -1019,16 +1019,21 @@ class ContentGlobal {
receiveMessage({name, data}) {
switch (name) {
case "Extension:InitExtensionView":
// The view type is initialized once and then fixed.
this.global.removeMessageListener("Extension:InitExtensionView", this);
this.viewType = data.viewType;
+ // Force external links to open in tabs.
+ if (["popup", "sidebar"].includes(this.viewType)) {
+ this.global.docShell.isAppTab = true;
+ }
+
if (data.devtoolsToolboxInfo) {
this.devtoolsToolboxInfo = data.devtoolsToolboxInfo;
}
promiseEvent(this.global, "DOMContentLoaded", true).then(() => {
this.global.sendAsyncMessage("Extension:ExtensionViewLoaded");
});
--- a/toolkit/components/extensions/ext-browser-content.js
+++ b/toolkit/components/extensions/ext-browser-content.js
@@ -43,16 +43,19 @@ const BrowserListener = {
this.oldBackground = null;
if (allowScriptsToClose) {
content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.allowScriptsToClose();
}
+ // Force external links to open in tabs.
+ docShell.isAppTab = true;
+
addEventListener("DOMWindowCreated", this, true);
addEventListener("load", this, true);
addEventListener("DOMContentLoaded", this, true);
addEventListener("DOMWindowClose", this, true);
addEventListener("MozScrolledAreaChanged", this, true);
},
destroy() {