зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1728332 - Part 1: Predict remote type when inserting restored tabs, r=Gijs
This should mostly avoid the issue where newly created pinned tabs when restoring a session are first created in the shared web process, and migrated into the correct process upon navigating. I also added remoteType prediction to the undoCloseTab and duplicateTab codepaths to avoid unnecessary process changes there as well. Differential Revision: https://phabricator.services.mozilla.com/D141146
This commit is contained in:
Родитель
5b0e505389
Коммит
be0eb28428
|
@ -2987,9 +2987,7 @@
|
|||
restoreTabsLazily && !select && !tabData.pinned;
|
||||
|
||||
let url = "about:blank";
|
||||
if (createLazyBrowser && tabData.entries && tabData.entries.length) {
|
||||
// Let tabbrowser know the future URI because progress listeners won't
|
||||
// get onLocationChange notification before the browser is inserted.
|
||||
if (tabData.entries?.length) {
|
||||
let activeIndex = (tabData.index || tabData.entries.length) - 1;
|
||||
// Ensure the index is in bounds.
|
||||
activeIndex = Math.min(activeIndex, tabData.entries.length - 1);
|
||||
|
@ -2997,10 +2995,23 @@
|
|||
url = tabData.entries[activeIndex].url;
|
||||
}
|
||||
|
||||
let preferredRemoteType = E10SUtils.getRemoteTypeForURI(
|
||||
url,
|
||||
gMultiProcessBrowser,
|
||||
gFissionBrowser,
|
||||
E10SUtils.DEFAULT_REMOTE_TYPE,
|
||||
null,
|
||||
E10SUtils.predictOriginAttributes({ window, userContextId })
|
||||
);
|
||||
|
||||
// If we're creating a lazy browser, let tabbrowser know the future
|
||||
// URI because progress listeners won't get onLocationChange
|
||||
// notification before the browser is inserted.
|
||||
//
|
||||
// Setting noInitialLabel is a perf optimization. Rendering tab labels
|
||||
// would make resizing the tabs more expensive as we're adding them.
|
||||
// Each tab will get its initial label set in restoreTab.
|
||||
tab = this.addTrustedTab(url, {
|
||||
tab = this.addTrustedTab(createLazyBrowser ? url : "about:blank", {
|
||||
createLazyBrowser,
|
||||
skipAnimation: true,
|
||||
allowInheritPrincipal: true,
|
||||
|
@ -3009,6 +3020,8 @@
|
|||
skipBackgroundNotify: true,
|
||||
bulkOrderedOpen: true,
|
||||
batchInsertingTabs: true,
|
||||
skipLoad: !createLazyBrowser,
|
||||
preferredRemoteType,
|
||||
});
|
||||
|
||||
if (select) {
|
||||
|
|
|
@ -3110,6 +3110,7 @@ var SessionStoreInternal = {
|
|||
? { relatedToCurrent: true, ownerTab: aTab }
|
||||
: {}),
|
||||
skipLoad: true,
|
||||
preferredRemoteType: aTab.linkedBrowser.remoteType,
|
||||
};
|
||||
let newTab = aWindow.gBrowser.addTrustedTab(null, tabOptions);
|
||||
|
||||
|
@ -3246,12 +3247,35 @@ var SessionStoreInternal = {
|
|||
aIndex
|
||||
);
|
||||
|
||||
// Predict the remote type to use for the load to avoid unnecessary process
|
||||
// switches.
|
||||
let preferredRemoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||
if (state.entries?.length) {
|
||||
let activeIndex = (state.index || state.entries.length) - 1;
|
||||
activeIndex = Math.min(activeIndex, state.entries.length - 1);
|
||||
activeIndex = Math.max(activeIndex, 0);
|
||||
|
||||
preferredRemoteType = E10SUtils.getRemoteTypeForURI(
|
||||
state.entries[activeIndex].url,
|
||||
aWindow.gMultiProcessBrowser,
|
||||
aWindow.gFissionBrowser,
|
||||
E10SUtils.DEFAULT_REMOTE_TYPE,
|
||||
null,
|
||||
E10SUtils.predictOriginAttributes({
|
||||
window: aWindow,
|
||||
userContextId: state.userContextId,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// create a new tab
|
||||
let tabbrowser = aWindow.gBrowser;
|
||||
let tab = (tabbrowser.selectedTab = tabbrowser.addTrustedTab(null, {
|
||||
index: pos,
|
||||
pinned: state.pinned,
|
||||
userContextId: state.userContextId,
|
||||
skipLoad: true,
|
||||
preferredRemoteType,
|
||||
}));
|
||||
|
||||
// restore tab content
|
||||
|
|
|
@ -201,31 +201,10 @@ add_task(async function testRestore() {
|
|||
let uri = container_tab.linkedBrowser.currentURI.spec;
|
||||
|
||||
// Verify XULFrameLoaderCreated was fired once
|
||||
if (
|
||||
test_page_data.uri == "about:preferences" ||
|
||||
test_page_data.uri == "about:config" ||
|
||||
gFissionBrowser
|
||||
) {
|
||||
todo_is(
|
||||
xulFrameLoaderCreatedCounter.numCalledSoFar,
|
||||
1,
|
||||
`XULFrameLoaderCreated was fired once, when restoring ${uri} in container ${userContextId} `
|
||||
);
|
||||
} else {
|
||||
is(
|
||||
xulFrameLoaderCreatedCounter.numCalledSoFar,
|
||||
1,
|
||||
`XULFrameLoaderCreated was fired once, when restoring ${uri} in container ${userContextId} `
|
||||
);
|
||||
}
|
||||
// While the above assertion is `todo_is`, ensure that we don't have a regression
|
||||
// from current behaviour by checking that the event is fired < 3 times.
|
||||
info(
|
||||
`XULFrameLoaderCreated has been fired ${xulFrameLoaderCreatedCounter.numCalledSoFar} times, when restoring ${uri} in container ${userContextId}`
|
||||
);
|
||||
ok(
|
||||
xulFrameLoaderCreatedCounter.numCalledSoFar <= 2,
|
||||
`XULFrameLoaderCreated was fired [1,2] times, when restoring ${uri} in container ${userContextId} `
|
||||
is(
|
||||
xulFrameLoaderCreatedCounter.numCalledSoFar,
|
||||
1,
|
||||
`XULFrameLoaderCreated was fired once, when restoring ${uri} in container ${userContextId} `
|
||||
);
|
||||
container_tab.ownerGlobal.gBrowser.removeEventListener(
|
||||
"XULFrameLoaderCreated",
|
||||
|
|
Загрузка…
Ссылка в новой задаче