Bug 1706445 - Fix test helpers that use "SessionStore:update", r=nika,perftest-reviewers,sparky

Also skips a frame script OOM test for Fission.

Differential Revision: https://phabricator.services.mozilla.com/D115930
This commit is contained in:
Kashav Madan 2021-06-01 20:06:48 +00:00
Родитель 1209d70a99
Коммит 8b26cd73bb
4 изменённых файлов: 48 добавлений и 56 удалений

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

@ -289,6 +289,7 @@ skip-if = verify && debug
run-if = e10s
tags = openUILinkIn
[browser_send_async_message_oom.js]
skip-if = fission # Tests that the frame script OOMs, which is unused in Fission.
[browser_sessionStoreContainer.js]
[browser_windowStateContainer.js]
[browser_1234021.js]
@ -328,7 +329,7 @@ skip-if = true #Bug 1455602
[browser_reopen_all_windows.js]
[browser_ignore_updates_crashed_tabs.js]
run-if = e10s && crashreporter
skip-if =
skip-if =
asan
apple_silicon # crash
(os == "win" && fission && verify) # bug 1709907
(os == "win" && fission && verify) # bug 1709907

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

@ -1119,6 +1119,7 @@ var BrowserTestUtils = {
let domWinClosedPromise = BrowserTestUtils.domWindowClosed(win);
let promises = [domWinClosedPromise];
let winType = win.document.documentElement.getAttribute("windowtype");
let flushTopic = "sessionstore-browser-shutdown-flush";
if (winType == "navigator:browser") {
let finalMsgsPromise = new Promise(resolve => {
@ -1128,24 +1129,21 @@ var BrowserTestUtils = {
browserSet.forEach(browser => {
win.gBrowser._insertBrowser(win.gBrowser.getTabForBrowser(browser));
});
let mm = win.getGroupMessageManager("browsers");
mm.addMessageListener(
"SessionStore:update",
function onMessage(msg) {
if (browserSet.has(msg.target) && msg.data.isFinal) {
browserSet.delete(msg.target);
if (!browserSet.size) {
mm.removeMessageListener("SessionStore:update", onMessage);
// Give the TabStateFlusher a chance to react to this final
// update and for the TabStateFlusher.flushWindow promise
// to resolve before we resolve.
TestUtils.executeSoon(resolve);
}
}
},
true
);
let observer = (subject, topic, data) => {
if (browserSet.has(subject)) {
browserSet.delete(subject);
}
if (!browserSet.size) {
Services.obs.removeObserver(observer, flushTopic);
// Give the TabStateFlusher a chance to react to this final
// update and for the TabStateFlusher.flushWindow promise
// to resolve before we resolve.
TestUtils.executeSoon(resolve);
}
};
Services.obs.addObserver(observer, flushTopic);
});
promises.push(finalMsgsPromise);
@ -1165,19 +1163,17 @@ var BrowserTestUtils = {
*/
waitForSessionStoreUpdate(tab) {
return new Promise(resolve => {
let { messageManager: mm, frameLoader } = tab.linkedBrowser;
mm.addMessageListener(
"SessionStore:update",
function onMessage(msg) {
if (msg.targetFrameLoader == frameLoader && msg.data.isFinal) {
mm.removeMessageListener("SessionStore:update", onMessage);
// Wait for the next event tick to make sure other listeners are
// called.
TestUtils.executeSoon(() => resolve());
}
},
true
);
let browser = tab.linkedBrowser;
let flushTopic = "sessionstore-browser-shutdown-flush";
let observer = (subject, topic, data) => {
if (subject === browser) {
Services.obs.removeObserver(observer, flushTopic);
// Wait for the next event tick to make sure other listeners are
// called.
TestUtils.executeSoon(() => resolve());
}
};
Services.obs.addObserver(observer, flushTopic);
});
},

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

@ -23,6 +23,7 @@ ChromeUtils.defineModuleGetter(
const PREALLOCATED_PREF = "dom.ipc.processPrelaunch.enabled";
const MESSAGES = ["CPStartup:Go", "CPStartup:BrowserChildReady"];
const BROWSER_FLUSH_TOPIC = "sessionstore-browser-shutdown-flush";
let domainID = 1;
/* global ExtensionAPI */
@ -117,18 +118,14 @@ this.cpstartup = class extends ExtensionAPI {
removeTab(tab) {
return new Promise(resolve => {
let { messageManager: mm, frameLoader } = tab.linkedBrowser;
mm.addMessageListener(
"SessionStore:update",
function onMessage(msg) {
if (msg.targetFrameLoader == frameLoader && msg.data.isFinal) {
mm.removeMessageListener("SessionStore:update", onMessage);
resolve();
}
},
true
);
let browser = tab.linkedBrowser;
let observer = (subject, topic, data) => {
if (subject === browser) {
Services.obs.removeObserver(observer, BROWSER_FLUSH_TOPIC);
resolve();
}
};
Services.obs.addObserver(observer, BROWSER_FLUSH_TOPIC);
tab.ownerGlobal.gBrowser.removeTab(tab);
});
}

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

@ -36,6 +36,8 @@ const MULTI_OPT_OUT_PREF = "dom.ipc.multiOptOut";
const MESSAGES = ["TabPaint:Go", "TabPaint:Painted"];
const BROWSER_FLUSH_TOPIC = "sessionstore-browser-shutdown-flush";
/* globals ExtensionAPI */
this.tabpaint = class extends ExtensionAPI {
onStartup() {
@ -201,18 +203,14 @@ this.tabpaint = class extends ExtensionAPI {
removeTab(tab) {
TalosParentProfiler.mark("Tabpaint: Remove Tab");
return new Promise(resolve => {
let { messageManager: mm, frameLoader } = tab.linkedBrowser;
mm.addMessageListener(
"SessionStore:update",
function onMessage(msg) {
if (msg.targetFrameLoader == frameLoader && msg.data.isFinal) {
mm.removeMessageListener("SessionStore:update", onMessage);
resolve();
}
},
true
);
let browser = tab.linkedBrowser;
let observer = (subject, topic, data) => {
if (subject === browser) {
Services.obs.removeObserver(observer, BROWSER_FLUSH_TOPIC);
resolve();
}
};
Services.obs.addObserver(observer, BROWSER_FLUSH_TOPIC);
tab.ownerGlobal.gBrowser.removeTab(tab);
});
}