Bug 1281726 - Support TabActor.getTab against mozbrowser iframes. r=jryans

This commit is contained in:
Alexandre Poirot 2016-07-13 23:34:17 -07:00
Родитель d63a3adedf
Коммит 213ad20a2e
2 изменённых файлов: 21 добавлений и 2 удалений

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

@ -38,10 +38,10 @@ add_task(function* () {
info("Test invalid tab id"); info("Test invalid tab id");
try { try {
yield targetFromURL(new URL("http://foo?type=tab&id=1")); yield targetFromURL(new URL("http://foo?type=tab&id=10000"));
ok(false, "Shouldn't pass"); ok(false, "Shouldn't pass");
} catch (e) { } catch (e) {
is(e.message, "targetFromURL, tab with outerWindowID:'1' doesn't exist"); is(e.message, "targetFromURL, tab with outerWindowID:'10000' doesn't exist");
} }
info("Test parent process"); info("Test parent process");

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

@ -382,6 +382,25 @@ BrowserTabList.prototype._getActorForBrowser = function (browser) {
BrowserTabList.prototype.getTab = function ({ outerWindowID, tabId }) { BrowserTabList.prototype.getTab = function ({ outerWindowID, tabId }) {
if (typeof outerWindowID == "number") { if (typeof outerWindowID == "number") {
// First look for in-process frames with this ID
let window = Services.wm.getOuterWindowWithId(outerWindowID);
// Safety check to prevent debugging top level window via getTab
if (window instanceof Ci.nsIDOMChromeWindow) {
return promise.reject({
error: "forbidden",
message: "Window with outerWindowID '" + outerWindowID + "' is chrome"
});
}
if (window) {
let iframe = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.containerElement;
if (iframe) {
return this._getActorForBrowser(iframe);
}
}
// Then also look on registered <xul:browsers> when using outerWindowID for
// OOP tabs
for (let browser of this._getBrowsers()) { for (let browser of this._getBrowsers()) {
if (browser.outerWindowID == outerWindowID) { if (browser.outerWindowID == outerWindowID) {
return this._getActorForBrowser(browser); return this._getActorForBrowser(browser);