зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1622420 - Set the current WindowContext for BrowsingContexts newly created over IPC. r=farre
Differential Revision: https://phabricator.services.mozilla.com/D68572 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b624dfb3f9
Коммит
88d677afa5
|
@ -646,6 +646,10 @@ void BrowsingContext::RegisterWindowContext(WindowContext* aWindow) {
|
|||
MOZ_ASSERT(!mWindowContexts.Contains(aWindow),
|
||||
"WindowContext already registered!");
|
||||
mWindowContexts.AppendElement(aWindow);
|
||||
if (aWindow->InnerWindowId() == GetCurrentInnerWindowId()) {
|
||||
MOZ_ASSERT(aWindow->GetBrowsingContext() == this);
|
||||
mCurrentWindowContext = aWindow;
|
||||
}
|
||||
}
|
||||
|
||||
void BrowsingContext::UnregisterWindowContext(WindowContext* aWindow) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
var EXPORTED_SYMBOLS = ["Bug1622420Child"];
|
||||
|
||||
class Bug1622420Child extends JSWindowActorChild {
|
||||
receiveMessage(msg) {
|
||||
switch (msg.name) {
|
||||
case "hasWindowContextForTopBC":
|
||||
return !!this.browsingContext.top.currentWindowContext;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -82,6 +82,10 @@ support-files =
|
|||
[browser_bug1347823.js]
|
||||
[browser_bug134911.js]
|
||||
[browser_bug1415918_beforeunload_options.js]
|
||||
[browser_bug1622420.js]
|
||||
support-files =
|
||||
file_bug1622420.html
|
||||
Bug1622420Child.jsm
|
||||
[browser_bug234628-1.js]
|
||||
[browser_bug234628-10.js]
|
||||
[browser_bug234628-11.js]
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
const ACTOR = "Bug1622420";
|
||||
|
||||
add_task(async function test() {
|
||||
let base = getRootDirectory(gTestPath).slice(0, -1);
|
||||
ChromeUtils.registerWindowActor(ACTOR, {
|
||||
allFrames: true,
|
||||
child: {
|
||||
moduleURI: `${base}/Bug1622420Child.jsm`,
|
||||
},
|
||||
});
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
gBrowser.removeTab(tab);
|
||||
|
||||
ChromeUtils.unregisterWindowActor(ACTOR);
|
||||
});
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
"http://example.org/browser/docshell/test/browser/file_bug1622420.html"
|
||||
);
|
||||
let childBC = tab.linkedBrowser.browsingContext.children[0];
|
||||
let success = await childBC.currentWindowGlobal
|
||||
.getActor(ACTOR)
|
||||
.sendQuery("hasWindowContextForTopBC");
|
||||
ok(
|
||||
success,
|
||||
"Should have a WindowContext for the top BrowsingContext in the process of a child BrowsingContext"
|
||||
);
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
<iframe src="http://example.com/"></iframe>
|
|
@ -35,6 +35,8 @@ interface BrowsingContext {
|
|||
|
||||
readonly attribute WindowProxy? window;
|
||||
|
||||
readonly attribute WindowContext? currentWindowContext;
|
||||
|
||||
attribute [TreatNullAs=EmptyString] DOMString customUserAgent;
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче