зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1525634 - Preserve lazyness of the old tab when adopted by another window. r=jaws
Differential Revision: https://phabricator.services.mozilla.com/D18982 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
93d45e85e9
Коммит
c3577f0fc0
|
@ -47,58 +47,67 @@ add_task(async function test() {
|
||||||
|
|
||||||
add_task(async function testLazyTabs() {
|
add_task(async function testLazyTabs() {
|
||||||
let params = {createLazyBrowser: true};
|
let params = {createLazyBrowser: true};
|
||||||
let tabs = [];
|
let oldTabs = [];
|
||||||
let numTabs = 4;
|
let numTabs = 4;
|
||||||
for (let i = 0; i < numTabs; ++i) {
|
for (let i = 0; i < numTabs; ++i) {
|
||||||
tabs.push(BrowserTestUtils.addTab(gBrowser, `http://example.com/?${i}`, params));
|
oldTabs.push(BrowserTestUtils.addTab(gBrowser, `http://example.com/?${i}`, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
await BrowserTestUtils.switchTab(gBrowser, tabs[0]);
|
await BrowserTestUtils.switchTab(gBrowser, oldTabs[0]);
|
||||||
for (let i = 1; i < numTabs; ++i) {
|
for (let i = 1; i < numTabs; ++i) {
|
||||||
await triggerClickOn(tabs[i], { ctrlKey: true });
|
await triggerClickOn(oldTabs[i], { ctrlKey: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
isnot(tabs[0].linkedPanel, "", `Tab 0 shouldn't be lazy`);
|
isnot(oldTabs[0].linkedPanel, "", `Old tab 0 shouldn't be lazy`);
|
||||||
for (let i = 1; i < numTabs; ++i) {
|
for (let i = 1; i < numTabs; ++i) {
|
||||||
is(tabs[i].linkedPanel, "", `Tab ${i} should be lazy`);
|
is(oldTabs[i].linkedPanel, "", `Old tab ${i} should be lazy`);
|
||||||
}
|
}
|
||||||
|
|
||||||
is(gBrowser.multiSelectedTabsCount, numTabs, `${numTabs} multiselected tabs`);
|
is(gBrowser.multiSelectedTabsCount, numTabs, `${numTabs} multiselected tabs`);
|
||||||
for (let i = 0; i < numTabs; ++i) {
|
for (let i = 0; i < numTabs; ++i) {
|
||||||
ok(tabs[i].multiselected, `Tab ${i} should be multiselected`);
|
ok(oldTabs[i].multiselected, `Old tab ${i} should be multiselected`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let tabsMoved = new Promise(resolve => {
|
let tabsMoved = new Promise(resolve => {
|
||||||
// Tab tabs in the new window will be about:blank before swapping the docshells.
|
// Tab tabs in the new window will be about:blank before swapping the docshells.
|
||||||
// The "EndSwapDocShells" event is not dispatched for lazy tabs, so listen for
|
// The "EndSwapDocShells" event is not dispatched for lazy tabs, so listen for
|
||||||
// "TabClose" instead and await a tick.
|
// "TabClose" instead and await a tick.
|
||||||
let i = 0;
|
let numTabsMoved = 0;
|
||||||
window.addEventListener("TabClose", async function listener() {
|
window.addEventListener("TabClose", async function listener(event) {
|
||||||
|
let tab = event.target;
|
||||||
|
let i = oldTabs.indexOf(tab);
|
||||||
|
if (i == 0) {
|
||||||
|
isnot(tab.linkedPanel, "", `Old tab ${i} should continue not being lazy`);
|
||||||
|
} else if (i > 0) {
|
||||||
|
is(tab.linkedPanel, "", `Old tab ${i} should continue being lazy`);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await Promise.resolve();
|
await Promise.resolve();
|
||||||
if (++i == numTabs) {
|
if (++numTabsMoved == numTabs) {
|
||||||
window.removeEventListener("TabClose", listener);
|
window.removeEventListener("TabClose", listener);
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let newWindow = gBrowser.replaceTabsWithWindow(tabs[0]);
|
let newWindow = gBrowser.replaceTabsWithWindow(oldTabs[0]);
|
||||||
await tabsMoved;
|
await tabsMoved;
|
||||||
tabs = newWindow.gBrowser.tabs;
|
let newTabs = newWindow.gBrowser.tabs;
|
||||||
|
|
||||||
isnot(tabs[0].linkedPanel, "", `Tab 0 should continue not being lazy`);
|
isnot(newTabs[0].linkedPanel, "", `New tab 0 should continue not being lazy`);
|
||||||
// FIXME: bug 1521923 - First inactive tab to be moved into another window loses laziness
|
// FIXME: bug 1521923 - First inactive tab to be moved into another window loses laziness
|
||||||
todo_is(tabs[1].linkedPanel, "", `Tab 1 should continue being lazy`);
|
todo_is(newTabs[1].linkedPanel, "", `New tab 1 should continue being lazy`);
|
||||||
for (let i = 2; i < numTabs; ++i) {
|
for (let i = 2; i < numTabs; ++i) {
|
||||||
is(tabs[i].linkedPanel, "", `Tab ${i} should continue being lazy`);
|
is(newTabs[i].linkedPanel, "", `New tab ${i} should continue being lazy`);
|
||||||
}
|
}
|
||||||
|
|
||||||
is(tabs[0].linkedBrowser.currentURI.spec, `http://example.com/?0`,
|
is(newTabs[0].linkedBrowser.currentURI.spec, `http://example.com/?0`,
|
||||||
`Tab 0 should have the right URL`);
|
`New tab 0 should have the right URL`);
|
||||||
todo_is(SessionStore.getLazyTabValue(tabs[1], "url"), `http://example.com/?1`,
|
todo_is(SessionStore.getLazyTabValue(newTabs[1], "url"), `http://example.com/?1`,
|
||||||
`Tab 1 should have the right lazy URL`);
|
`New tab 1 should have the right lazy URL`);
|
||||||
for (let i = 2; i < numTabs; ++i) {
|
for (let i = 2; i < numTabs; ++i) {
|
||||||
is(SessionStore.getLazyTabValue(tabs[i], "url"), `http://example.com/?${i}`,
|
is(SessionStore.getLazyTabValue(newTabs[i], "url"), `http://example.com/?${i}`,
|
||||||
`Tab ${i} should have the right lazy URL`);
|
`New tab ${i} should have the right lazy URL`);
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserTestUtils.closeWindow(newWindow);
|
BrowserTestUtils.closeWindow(newWindow);
|
||||||
|
|
|
@ -454,10 +454,11 @@ class TabTracker extends TabTrackerBase {
|
||||||
// This tab is being created to adopt a tab from a different window.
|
// This tab is being created to adopt a tab from a different window.
|
||||||
// Handle the adoption.
|
// Handle the adoption.
|
||||||
this.adopt(nativeTab, adoptedTab);
|
this.adopt(nativeTab, adoptedTab);
|
||||||
|
if (adoptedTab.linkedPanel) {
|
||||||
adoptedTab.linkedBrowser.messageManager.sendAsyncMessage("Extension:SetFrameData", {
|
adoptedTab.linkedBrowser.messageManager.sendAsyncMessage("Extension:SetFrameData", {
|
||||||
windowId: windowTracker.getId(nativeTab.ownerGlobal),
|
windowId: windowTracker.getId(nativeTab.ownerGlobal),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Save the size of the current tab, since the newly-created tab will
|
// Save the size of the current tab, since the newly-created tab will
|
||||||
// likely be active by the time the promise below resolves and the
|
// likely be active by the time the promise below resolves and the
|
||||||
|
|
Загрузка…
Ссылка в новой задаче