mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 1398955 - Include url with RemotePage messages. r=mossop
MozReview-Commit-ID: CkwHOpTAvUw --HG-- extra : rebase_source : bd4b6bd66d2c922bdf082c74284e0e197a89a86a
This commit is contained in:
parent
a9fb858445
commit
02f10c7eab
@ -206,6 +206,13 @@ function publicMessagePort(port) {
|
||||
return port.browser;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(clean, "url", {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return port.url;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return clean;
|
||||
@ -303,11 +310,12 @@ MessagePort.prototype = {
|
||||
|
||||
|
||||
// The chome side of a message port
|
||||
function ChromeMessagePort(browser, portID) {
|
||||
function ChromeMessagePort(browser, portID, url) {
|
||||
MessagePort.call(this, browser.messageManager, portID);
|
||||
|
||||
this._browser = browser;
|
||||
this._permanentKey = browser.permanentKey;
|
||||
this._url = url;
|
||||
|
||||
Services.obs.addObserver(this, "message-manager-disconnect");
|
||||
this.publicPort = publicMessagePort(this);
|
||||
@ -324,6 +332,12 @@ Object.defineProperty(ChromeMessagePort.prototype, "browser", {
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(ChromeMessagePort.prototype, "url", {
|
||||
get() {
|
||||
return this._url;
|
||||
}
|
||||
});
|
||||
|
||||
// Called when the docshell is being swapped with another browser. We have to
|
||||
// update to use the new browser's message manager
|
||||
ChromeMessagePort.prototype.swapBrowsers = function({ detail: newBrowser }) {
|
||||
@ -512,7 +526,7 @@ var RemotePageManagerInternal = {
|
||||
return;
|
||||
}
|
||||
|
||||
let port = new ChromeMessagePort(browser, portID);
|
||||
let port = new ChromeMessagePort(browser, portID, url);
|
||||
callback(port.publicPort);
|
||||
}
|
||||
};
|
||||
|
@ -330,7 +330,8 @@ add_task(async function check_port_properties() {
|
||||
"loaded",
|
||||
"portID",
|
||||
"removeMessageListener",
|
||||
"sendAsyncMessage"
|
||||
"sendAsyncMessage",
|
||||
"url"
|
||||
];
|
||||
function checkProperties(port, description) {
|
||||
const expected = [];
|
||||
@ -356,18 +357,25 @@ add_task(async function check_port_properties() {
|
||||
let portFromInit = await portFrom("RemotePage:Init", () =>
|
||||
(gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TEST_URL)));
|
||||
checkProperties(portFromInit, "inited port");
|
||||
ok(["about:blank", TEST_URL].includes(portFromInit.browser.currentURI.spec),
|
||||
`inited port browser is either still blank or already at the target url - got ${portFromInit.browser.currentURI.spec}`);
|
||||
is(portFromInit.loaded, false, "inited port has not been loaded yet");
|
||||
is(portFromInit.url, TEST_URL, "got expected url");
|
||||
|
||||
let portFromLoad = await portFrom("RemotePage:Load");
|
||||
is(portFromLoad, portFromInit, "got the same port from init and load");
|
||||
checkProperties(portFromLoad, "loaded port");
|
||||
is(portFromInit.browser.currentURI.spec, TEST_URL, "loaded port has browser with actual url");
|
||||
is(portFromInit.loaded, true, "loaded port is now loaded");
|
||||
is(portFromInit.url, TEST_URL, "still got expected url");
|
||||
|
||||
let portFromUnload = await portFrom("RemotePage:Unload", () =>
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab));
|
||||
is(portFromUnload, portFromInit, "got the same port from init and unload");
|
||||
checkProperties(portFromUnload, "unloaded port");
|
||||
is(portFromInit.browser, null, "unloaded port has no browser");
|
||||
is(portFromInit.loaded, false, "unloaded port is now not loaded");
|
||||
is(portFromInit.url, TEST_URL, "still got expected url");
|
||||
|
||||
pages.destroy();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user