зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1720990 - Clear mActiveBrowsingContextInContent when a page goes into the BFCache. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D123941
This commit is contained in:
Родитель
3a366c9529
Коммит
24ff2ec352
|
@ -224,3 +224,4 @@ https_first_disabled = true
|
|||
[browser_bug1716290-2.js]
|
||||
[browser_bug1716290-3.js]
|
||||
[browser_bug1716290-4.js]
|
||||
[browser_bfcache_copycommand.js]
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function dummyPageURL(domain, query = "") {
|
||||
return (
|
||||
getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
`https://${domain}`
|
||||
) +
|
||||
"dummy_page.html" +
|
||||
query
|
||||
);
|
||||
}
|
||||
|
||||
async function openContextMenu(browser) {
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
let awaitPopupShown = BrowserTestUtils.waitForEvent(
|
||||
contextMenu,
|
||||
"popupshown"
|
||||
);
|
||||
await BrowserTestUtils.synthesizeMouse(
|
||||
"body",
|
||||
1,
|
||||
1,
|
||||
{
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
},
|
||||
browser
|
||||
);
|
||||
await awaitPopupShown;
|
||||
}
|
||||
|
||||
async function closeContextMenu() {
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
let awaitPopupHidden = BrowserTestUtils.waitForEvent(
|
||||
contextMenu,
|
||||
"popuphidden"
|
||||
);
|
||||
contextMenu.hidePopup();
|
||||
await awaitPopupHidden;
|
||||
}
|
||||
|
||||
async function testWithDomain(domain) {
|
||||
// Passing a query to make sure the next load is never a same-document
|
||||
// navigation.
|
||||
let dummy = dummyPageURL("example.org", "?start");
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, dummy);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
let sel = await SpecialPowers.spawn(browser, [], function() {
|
||||
let sel = content.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.selectAllChildren(content.document.body);
|
||||
return sel.toString();
|
||||
});
|
||||
|
||||
await openContextMenu(browser);
|
||||
|
||||
let copyItem = document.getElementById("context-copy");
|
||||
ok(!copyItem.disabled, "Copy item should be enabled if text is selected.");
|
||||
|
||||
await closeContextMenu();
|
||||
|
||||
let loaded = BrowserTestUtils.browserLoaded(browser, false, null, true);
|
||||
BrowserTestUtils.loadURI(browser, dummyPageURL(domain));
|
||||
await loaded;
|
||||
loaded = BrowserTestUtils.waitForLocationChange(gBrowser, dummy);
|
||||
browser.goBack();
|
||||
await loaded;
|
||||
|
||||
let sel2 = await SpecialPowers.spawn(browser, [], function() {
|
||||
return content.getSelection().toString();
|
||||
});
|
||||
is(sel, sel2, "Selection should remain when coming out of BFCache.");
|
||||
|
||||
await openContextMenu(browser);
|
||||
|
||||
ok(!copyItem.disabled, "Copy item should be enabled if text is selected.");
|
||||
|
||||
await closeContextMenu();
|
||||
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(async function testValidSameOrigin() {
|
||||
await testWithDomain("example.org");
|
||||
});
|
||||
|
||||
add_task(async function testValidCrossOrigin() {
|
||||
await testWithDomain("example.com");
|
||||
});
|
||||
|
||||
add_task(async function testInvalid() {
|
||||
await testWithDomain("this.is.invalid");
|
||||
});
|
|
@ -1153,6 +1153,13 @@ void nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!XRE_IsParentProcess() &&
|
||||
mActiveBrowsingContextInContent ==
|
||||
docShellBeingHidden->GetBrowsingContext() &&
|
||||
mActiveBrowsingContextInContent->GetIsInBFCache()) {
|
||||
SetActiveBrowsingContextInContent(nullptr, aActionId);
|
||||
}
|
||||
|
||||
// if the window being hidden is an ancestor of the focused window, adjust
|
||||
// the focused window so that it points to the one being hidden. This
|
||||
// ensures that the focused window isn't in a chain of frames that doesn't
|
||||
|
|
Загрузка…
Ссылка в новой задаче