Backed out changeset 51ffa59f1488 (bug 1521923) for WR failures on outline-013.html . CLOSED TREE

This commit is contained in:
Narcis Beleuzu
2019-03-01 06:25:27 +02:00
parent 4147b15cd2
commit 21ac2fde9f
3 changed files with 34 additions and 25 deletions

View File

@@ -1408,9 +1408,6 @@ var gBrowserInit = {
// avoid an about:blank flash. // avoid an about:blank flash.
let tabToAdopt = this.getTabToAdopt(); let tabToAdopt = this.getTabToAdopt();
if (tabToAdopt) { if (tabToAdopt) {
let evt = new CustomEvent("before-initial-tab-adopted", { bubbles: true });
gBrowser.tabpanels.dispatchEvent(evt);
// Stop the about:blank load // Stop the about:blank load
gBrowser.stop(); gBrowser.stop();
// make sure it has a docshell // make sure it has a docshell

View File

@@ -3703,6 +3703,13 @@ window._gBrowser = {
return this.replaceTabWithWindow(tabs[0], aOptions); return this.replaceTabWithWindow(tabs[0], aOptions);
} }
// The order of the tabs is preserved.
// To avoid multiple tab-switch, the active tab is "moved" last, if applicable.
// If applicable, the active tab remains active in the new window.
let activeTab = gBrowser.selectedTab;
let inactiveTabs = tabs.filter(t => t != activeTab);
let activeTabNewIndex = tabs.indexOf(activeTab);
// Play the closing animation for all selected tabs to give // Play the closing animation for all selected tabs to give
// immediate feedback while waiting for the new window to appear. // immediate feedback while waiting for the new window to appear.
if (this.animationsEnabled) { if (this.animationsEnabled) {
@@ -3712,28 +3719,33 @@ window._gBrowser = {
} }
} }
// Create a new window and make it adopt the tabs, preserving their relative order. let win;
// The initial tab of the new window will be selected, so it should adopt the let firstInactiveTab = inactiveTabs[0];
// selected tab of the original window, if applicable, or else the first moving tab.
// This avoids tab-switches in the new window, preserving tab laziness. let adoptRemainingTabs = () => {
// However, to avoid multiple tab-switches in the original window, the other tabs for (let i = 1; i < inactiveTabs.length; i++) {
// should be adopted before the selected one. win.gBrowser.adoptTab(inactiveTabs[i], i);
let selectedTabIndex = Math.max(0, tabs.indexOf(gBrowser.selectedTab));
let selectedTab = tabs[selectedTabIndex];
let win = this.replaceTabWithWindow(selectedTab, aOptions);
win.addEventListener("before-initial-tab-adopted", () => {
for (let i = 0; i < tabs.length; ++i) {
if (i != selectedTabIndex) {
win.gBrowser.adoptTab(tabs[i], i);
} }
if (activeTabNewIndex > -1) {
win.gBrowser.adoptTab(activeTab, activeTabNewIndex, true /* aSelectTab */);
} }
// Restore tab selection // Restore tab selection
let winVisibleTabs = win.gBrowser.visibleTabs; let winVisibleTabs = win.gBrowser.visibleTabs;
let winTabLength = winVisibleTabs.length; let winTabLength = winVisibleTabs.length;
win.gBrowser.addRangeToMultiSelectedTabs(winVisibleTabs[0], win.gBrowser.addRangeToMultiSelectedTabs(winVisibleTabs[0],
winVisibleTabs[winTabLength - 1]); winVisibleTabs[winTabLength - 1]);
win.gBrowser.lockClearMultiSelectionOnce(); };
}, {once: true});
// Pending tabs don't get their docshell swapped, wait for their TabClose
if (firstInactiveTab.hasAttribute("pending")) {
firstInactiveTab.addEventListener("TabClose", adoptRemainingTabs, {once: true});
} else {
firstInactiveTab.linkedBrowser.addEventListener("EndSwapDocShells", adoptRemainingTabs, {once: true});
}
win = this.replaceTabWithWindow(firstInactiveTab, aOptions);
return win; return win;
}, },

View File

@@ -95,20 +95,20 @@ add_task(async function testLazyTabs() {
let newTabs = newWindow.gBrowser.tabs; let newTabs = newWindow.gBrowser.tabs;
isnot(newTabs[0].linkedPanel, "", `New tab 0 should continue not being lazy`); isnot(newTabs[0].linkedPanel, "", `New tab 0 should continue not being lazy`);
for (let i = 1; i < numTabs; ++i) { // FIXME: bug 1521923 - First inactive tab to be moved into another window loses laziness
todo_is(newTabs[1].linkedPanel, "", `New tab 1 should continue being lazy`);
for (let i = 2; i < numTabs; ++i) {
is(newTabs[i].linkedPanel, "", `New tab ${i} should continue being lazy`); is(newTabs[i].linkedPanel, "", `New tab ${i} should continue being lazy`);
} }
is(newTabs[0].linkedBrowser.currentURI.spec, `http://example.com/?0`, is(newTabs[0].linkedBrowser.currentURI.spec, `http://example.com/?0`,
`New tab 0 should have the right URL`); `New tab 0 should have the right URL`);
for (let i = 1; i < numTabs; ++i) { todo_is(SessionStore.getLazyTabValue(newTabs[1], "url"), `http://example.com/?1`,
`New tab 1 should have the right lazy URL`);
for (let i = 2; i < numTabs; ++i) {
is(SessionStore.getLazyTabValue(newTabs[i], "url"), `http://example.com/?${i}`, is(SessionStore.getLazyTabValue(newTabs[i], "url"), `http://example.com/?${i}`,
`New tab ${i} should have the right lazy URL`); `New tab ${i} should have the right lazy URL`);
} }
for (let i = 0; i < numTabs; ++i) {
ok(newTabs[i].multiselected, `New tab ${i} should be multiselected`);
}
BrowserTestUtils.closeWindow(newWindow); BrowserTestUtils.closeWindow(newWindow);
}); });