Bug 1317697: Follow-up: Fix android test bustage. r=me

MozReview-Commit-ID: 4bFu0pPMZim
This commit is contained in:
Kris Maglione 2017-04-14 19:28:53 -07:00
Родитель 2d2f47f7b2
Коммит 2f577ad88b
2 изменённых файлов: 46 добавлений и 45 удалений

Просмотреть файл

@ -1,5 +1,51 @@
"use strict";
// This function is pretty tightly tied to Extension.jsm.
// Its job is to fill in the |tab| property of the sender.
function getSender(extension, target, sender) {
let tabId;
if ("tabId" in sender) {
// The message came from a privileged extension page running in a tab. In
// that case, it should include a tabId property (which is filled in by the
// page-open listener below).
tabId = sender.tabId;
delete sender.tabId;
} else if (target instanceof Ci.nsIDOMXULElement) {
tabId = tabTracker.getBrowserData(target).tabId;
}
if (tabId) {
let tab = extension.tabManager.get(tabId, null);
if (tab) {
sender.tab = tab.convert();
}
}
}
// Used by Extension.jsm
global.tabGetSender = getSender;
/* eslint-disable mozilla/balanced-listeners */
extensions.on("page-shutdown", (type, context) => {
if (context.viewType == "tab") {
if (context.extension.id !== context.xulBrowser.contentPrincipal.addonId) {
// Only close extension tabs.
// This check prevents about:addons from closing when it contains a
// WebExtension as an embedded inline options page.
return;
}
let {BrowserApp} = context.xulBrowser.ownerGlobal;
if (BrowserApp) {
let nativeTab = BrowserApp.getTabForBrowser(context.xulBrowser);
if (nativeTab) {
BrowserApp.closeTab(nativeTab);
}
}
}
});
/* eslint-enable mozilla/balanced-listeners */
extensions.registerModules({
pageAction: {
url: "chrome://browser/content/ext-pageAction.js",

Просмотреть файл

@ -15,51 +15,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
// This function is pretty tightly tied to Extension.jsm.
// Its job is to fill in the |tab| property of the sender.
function getSender(extension, target, sender) {
let tabId;
if ("tabId" in sender) {
// The message came from a privileged extension page running in a tab. In
// that case, it should include a tabId property (which is filled in by the
// page-open listener below).
tabId = sender.tabId;
delete sender.tabId;
} else if (target instanceof Ci.nsIDOMXULElement) {
tabId = tabTracker.getBrowserData(target).tabId;
}
if (tabId) {
let tab = extension.tabManager.get(tabId, null);
if (tab) {
sender.tab = tab.convert();
}
}
}
// Used by Extension.jsm
global.tabGetSender = getSender;
/* eslint-disable mozilla/balanced-listeners */
extensions.on("page-shutdown", (type, context) => {
if (context.viewType == "tab") {
if (context.extension.id !== context.xulBrowser.contentPrincipal.addonId) {
// Only close extension tabs.
// This check prevents about:addons from closing when it contains a
// WebExtension as an embedded inline options page.
return;
}
let {BrowserApp} = context.xulBrowser.ownerGlobal;
if (BrowserApp) {
let nativeTab = BrowserApp.getTabForBrowser(context.xulBrowser);
if (nativeTab) {
BrowserApp.closeTab(nativeTab);
}
}
}
});
/* eslint-enable mozilla/balanced-listeners */
function getBrowserWindow(window) {
return window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem