mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1659101 - fix intermittent failure in browser_preoloading_tab_moving.js, r=jaws
See discussion in the last few comments on the bug. If we don't wait for the correct URL to load in the browser, the SpecialPowers.spawn task can get aborted, which causes the test to fail. Differential Revision: https://phabricator.services.mozilla.com/D119518
This commit is contained in:
parent
f46a01150f
commit
ab5b2c0999
@ -34,8 +34,7 @@ support-files =
|
||||
[browser_PermissionUI_prompts.js]
|
||||
[browser_preloading_tab_moving.js]
|
||||
skip-if =
|
||||
os == 'linux' && (!debug || tsan || asan) # Bug 1659101
|
||||
os == "win" # Bug 1659101
|
||||
os == 'linux' && tsan # Bug 1720203
|
||||
[browser_ProcessHangNotifications.js]
|
||||
skip-if = !e10s
|
||||
[browser_SitePermissions.js]
|
||||
|
@ -21,6 +21,41 @@ async function openWinWithPreloadBrowser(options = {}) {
|
||||
return newWin;
|
||||
}
|
||||
|
||||
async function promiseNewTabLoadedInBrowser(browser) {
|
||||
let url = browser.ownerGlobal.BROWSER_NEW_TAB_URL;
|
||||
if (browser.currentURI.spec != url) {
|
||||
info(`Waiting for ${url} to be the location for the browser.`);
|
||||
await new Promise(resolve => {
|
||||
let progressListener = {
|
||||
onLocationChange(aWebProgress, aRequest, aLocationURI, aFlags) {
|
||||
if (!url || aLocationURI.spec == url) {
|
||||
browser.removeProgressListener(progressListener);
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIWebProgressListener2,
|
||||
Ci.nsIWebProgressListener,
|
||||
]),
|
||||
};
|
||||
browser.addProgressListener(
|
||||
progressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_ALL
|
||||
);
|
||||
});
|
||||
} else {
|
||||
info(`${url} already the current URI for the browser.`);
|
||||
}
|
||||
|
||||
info(`Waiting for readyState complete in the browser`);
|
||||
await SpecialPowers.spawn(browser, [], function() {
|
||||
return ContentTaskUtils.waitForCondition(() => {
|
||||
return content.document.readyState == "complete";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that moving a preloaded browser's content from one window to the next
|
||||
* works correctly.
|
||||
@ -57,22 +92,14 @@ add_task(async function moving_works() {
|
||||
browser,
|
||||
"Preloaded browser is usable when opening a new tab."
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], function() {
|
||||
return ContentTaskUtils.waitForCondition(() => {
|
||||
return content.document.readyState == "complete";
|
||||
});
|
||||
});
|
||||
await promiseNewTabLoadedInBrowser(browser);
|
||||
ok(true, "Successfully loaded the tab.");
|
||||
|
||||
tab = browser = null;
|
||||
await BrowserTestUtils.closeWindow(newWin);
|
||||
|
||||
tab = BrowserTestUtils.addTab(gBrowser, BROWSER_NEW_TAB_URL);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
|
||||
return ContentTaskUtils.waitForCondition(() => {
|
||||
return content.document.readyState == "complete";
|
||||
});
|
||||
}).catch(Cu.reportError);
|
||||
await promiseNewTabLoadedInBrowser(tab.linkedBrowser);
|
||||
|
||||
ok(true, "Managed to open a tab in the original window still.");
|
||||
|
||||
@ -115,11 +142,7 @@ add_task(async function moving_shouldnt_move_across_private_state() {
|
||||
browser,
|
||||
"Preloaded browser is usable when opening a new tab."
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [], function() {
|
||||
return ContentTaskUtils.waitForCondition(() => {
|
||||
return content.document.readyState == "complete";
|
||||
});
|
||||
});
|
||||
await promiseNewTabLoadedInBrowser(browser);
|
||||
ok(true, "Successfully loaded the tab.");
|
||||
|
||||
tab = browser = null;
|
||||
|
Loading…
Reference in New Issue
Block a user