Bug 1630176 - Fix the race between process switching and the new browser window loading code, r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D81563
This commit is contained in:
Anny Gakhokidze 2020-06-30 20:57:52 +00:00
Родитель 81d6dc12a4
Коммит 9f398ab019
3 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -458,6 +458,22 @@ var SessionStore = {
return SessionStoreInternal.resetBrowserToLazyState(tab);
},
/**
* Ensures that session store has registered and started tracking a given window.
* @param window
* Window reference
*/
ensureInitialized(window) {
if (SessionStoreInternal._sessionInitialized && !window.__SSi) {
/*
We need to check that __SSi is not defined on the window so that if
onLoad function is in the middle of executing we don't enter the function
again and try to redeclare the ContentSessionStore script.
*/
SessionStoreInternal.onLoad(window);
}
},
/**
* Determines whether the passed version number is compatible with
* the current version number of the SessionStore.

Просмотреть файл

@ -6,6 +6,12 @@
var EXPORTED_SYMBOLS = ["TabStateFlusher"];
ChromeUtils.defineModuleGetter(
this,
"SessionStore",
"resource:///modules/sessionstore/SessionStore.jsm"
);
/**
* A module that enables async flushes. Updates from frame scripts are
* throttled to be sent only once per second. If an action wants a tab's latest
@ -92,6 +98,15 @@ var TabStateFlusherInternal = {
*/
requestNativeListener = browser.frameLoader.requestTabStateFlush(id);
}
/*
In the event that we have to trigger a process switch and thus change
browser remoteness, session store needs to register and track the new
browser window loaded and to have message manager listener registered
** before ** TabStateFlusher send "SessionStore:flush" message. This fixes
the race where we send the message before the message listener is
registered for it.
*/
SessionStore.ensureInitialized(browser.ownerGlobal);
let mm = browser.messageManager;
mm.sendAsyncMessage("SessionStore:flush", { id });

Просмотреть файл

@ -288,7 +288,7 @@ skip-if = serviceworker_e10s # leaks InterceptedHttpChannel and others things
[test_notification_constructor_error.html]
[test_notification_get.html]
[test_notification_openWindow.html]
skip-if = toolkit == 'android' && !is_fennec || (os == "linux" && bits == 64) || (os == "win" && !debug && bits == 64) # Bug 1620052
skip-if = toolkit == 'android' && !is_fennec # Bug 1620052
|| xorigin # JavaScript error: http://mochi.xorigin-test:8888/tests/SimpleTest/TestRunner.js, line 157: SecurityError: Permission denied to access property "wrappedJSObject" on cross-origin object
support-files = notification_openWindow_worker.js file_notification_openWindow.html
tags = openwindow