зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1589102 - Part 7: Fix test_browsing_context_structured_clone.js to instead schedule precise gc, r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D85086
This commit is contained in:
Родитель
a12aaa2425
Коммит
5755a94b86
|
@ -4,7 +4,11 @@ add_task(async function test_BrowsingContext_structured_clone() {
|
|||
let browser = Services.appShell.createWindowlessBrowser(false);
|
||||
|
||||
let frame = browser.document.createElement("iframe");
|
||||
browser.document.body.appendChild(frame);
|
||||
|
||||
await new Promise(r => {
|
||||
frame.onload = () => r();
|
||||
browser.document.body.appendChild(frame);
|
||||
});
|
||||
|
||||
let { browsingContext } = frame;
|
||||
|
||||
|
@ -39,11 +43,6 @@ add_task(async function test_BrowsingContext_structured_clone() {
|
|||
// Beyond that, we don't *have* to reload or destroy the parent
|
||||
// document, but we do anyway just to be safe.
|
||||
//
|
||||
// Then comes the tricky bit: The WindowGlobal actors (which keep
|
||||
// references to their BrowsingContexts) require an IPC round trip to
|
||||
// be completely destroyed, even though they're in-process, so we make
|
||||
// a quick trip through the event loop, and then run the CC in order
|
||||
// to allow their (now snow-white) references to be collected.
|
||||
|
||||
frame.remove();
|
||||
frame = null;
|
||||
|
@ -52,13 +51,11 @@ add_task(async function test_BrowsingContext_structured_clone() {
|
|||
browser.document.location.reload();
|
||||
browser.close();
|
||||
|
||||
Cu.forceGC();
|
||||
|
||||
// Give the IPC messages that destroy the actors a chance to be
|
||||
// processed.
|
||||
await new Promise(executeSoon);
|
||||
|
||||
Cu.forceCC();
|
||||
// We will schedule a precise GC and do both GC and CC a few times, to make
|
||||
// sure we have completely destroyed the WindowGlobal actors (which keep
|
||||
// references to their BrowsingContexts) in order
|
||||
// to allow their (now snow-white) references to be collected.
|
||||
await schedulePreciseGCAndForceCC(3);
|
||||
|
||||
// OK. We can be fairly confident that the BrowsingContext object
|
||||
// stored in our structured clone data has been destroyed. Make sure
|
||||
|
|
|
@ -1463,6 +1463,18 @@ function do_send_remote_message(name, data) {
|
|||
mm[sender](name, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules and awaits a precise GC, and forces CC, `maxCount` number of times.
|
||||
* @param maxCount
|
||||
* How many times GC and CC should be scheduled.
|
||||
*/
|
||||
async function schedulePreciseGCAndForceCC(maxCount) {
|
||||
for (let count = 0; count < maxCount; count++) {
|
||||
await new Promise(resolve => Cu.schedulePreciseGC(resolve));
|
||||
Cu.forceCC();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a test function to the list of tests that are to be run asynchronously.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче