mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 938084 - Drop pending collections when docShells are swapped r=billm
From c9f166092e28ede16159c7e067df5b307a68f145 Mon Sep 17 00:00:00 2001
This commit is contained in:
parent
096d5da258
commit
6b89b04d32
@ -2595,7 +2595,7 @@ let SessionStoreInternal = {
|
||||
|
||||
// Any data that's in the process of being collected for this tab will be
|
||||
// out of date now that we're restoring it.
|
||||
TabState.dropPendingCollections(tab);
|
||||
TabState.dropPendingCollections(browser);
|
||||
|
||||
if (!tabData.entries) {
|
||||
tabData.entries = [];
|
||||
|
@ -43,13 +43,13 @@ this.TabState = Object.freeze({
|
||||
return TabStateInternal.clone(tab);
|
||||
},
|
||||
|
||||
dropPendingCollections: function (tab) {
|
||||
TabStateInternal.dropPendingCollections(tab);
|
||||
dropPendingCollections: function (browser) {
|
||||
TabStateInternal.dropPendingCollections(browser);
|
||||
}
|
||||
});
|
||||
|
||||
let TabStateInternal = {
|
||||
// A map (xul:tab -> promise) that keeps track of tabs and
|
||||
// A map (xul:browser -> promise) that keeps track of tabs and
|
||||
// their promises when collecting tab data asynchronously.
|
||||
_pendingCollections: new WeakMap(),
|
||||
|
||||
@ -72,6 +72,12 @@ let TabStateInternal = {
|
||||
* be swapped just like the docshell.
|
||||
*/
|
||||
onSwapDocShells: function (browser, otherBrowser) {
|
||||
// Data collected while docShells have been swapped should not go into
|
||||
// the TabStateCache. Collections will most probably time out but we want
|
||||
// to make sure.
|
||||
this.dropPendingCollections(browser);
|
||||
this.dropPendingCollections(otherBrowser);
|
||||
|
||||
// Make sure that one or the other of these has a sync handler,
|
||||
// and let it be |browser|.
|
||||
if (!this._syncHandlers.has(browser)) {
|
||||
@ -119,6 +125,8 @@ let TabStateInternal = {
|
||||
return Promise.resolve(tabData);
|
||||
}
|
||||
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
let promise = Task.spawn(function task() {
|
||||
// Collect session history data asynchronously. Also collects
|
||||
// text and scroll data.
|
||||
@ -156,9 +164,9 @@ let TabStateInternal = {
|
||||
// If we're still the latest async collection for the given tab and
|
||||
// the cache hasn't been filled by collect() in the meantime, let's
|
||||
// fill the cache with the data we received.
|
||||
if (this._pendingCollections.get(tab) == promise) {
|
||||
if (this._pendingCollections.get(browser) == promise) {
|
||||
TabStateCache.set(tab, tabData);
|
||||
this._pendingCollections.delete(tab);
|
||||
this._pendingCollections.delete(browser);
|
||||
}
|
||||
|
||||
throw new Task.Result(tabData);
|
||||
@ -167,7 +175,7 @@ let TabStateInternal = {
|
||||
// Save the current promise as the latest asynchronous collection that is
|
||||
// running. This will be used to check whether the collected data is still
|
||||
// valid and will be used to fill the tab state cache.
|
||||
this._pendingCollections.set(tab, promise);
|
||||
this._pendingCollections.set(browser, promise);
|
||||
|
||||
return promise;
|
||||
},
|
||||
@ -201,7 +209,7 @@ let TabStateInternal = {
|
||||
// can't expect to retrieve different data than the sync call. That's why
|
||||
// we just fill the cache with the data collected from the sync call and
|
||||
// discard any data collected asynchronously.
|
||||
this.dropPendingCollections(tab);
|
||||
this.dropPendingCollections(tab.linkedBrowser);
|
||||
|
||||
return tabData;
|
||||
},
|
||||
@ -211,11 +219,11 @@ let TabStateInternal = {
|
||||
* continue to run, but they won't store their results in the
|
||||
* TabStateCache.
|
||||
*
|
||||
* @param tab
|
||||
* tabbrowser tab
|
||||
* @param browser
|
||||
* xul:browser
|
||||
*/
|
||||
dropPendingCollections: function (tab) {
|
||||
this._pendingCollections.delete(tab);
|
||||
dropPendingCollections: function (browser) {
|
||||
this._pendingCollections.delete(browser);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user