Bug 1858769 - Fix intermittent failure on pb newtab promo test. r=omc-reviewers,negin
Differential Revision: https://phabricator.services.mozilla.com/D190864
This commit is contained in:
@@ -51,24 +51,22 @@ add_task(async function test_cookie_banners_promo() {
|
|||||||
});
|
});
|
||||||
await ASRouter.onPrefChange();
|
await ASRouter.onPrefChange();
|
||||||
|
|
||||||
const { win, tab } = await openTabAndWaitForRender();
|
const sandbox = sinon.createSandbox();
|
||||||
|
|
||||||
const expectedUrl = Services.urlFormatter.formatURL(
|
const expectedUrl = Services.urlFormatter.formatURL(
|
||||||
"https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/cookie-banner-reduction"
|
"https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/cookie-banner-reduction"
|
||||||
);
|
);
|
||||||
let tabOpened = new Promise(resolve => {
|
|
||||||
win.gBrowser.tabContainer.addEventListener(
|
const { win, tab } = await openTabAndWaitForRender();
|
||||||
"TabOpen",
|
let triedToOpenTab = new Promise(resolve => {
|
||||||
event => {
|
sandbox.stub(win, "openLinkIn").callsFake((url, where) => {
|
||||||
let newTab = event.target;
|
is(url, expectedUrl, "The link should open the expected URL");
|
||||||
let newBrowser = newTab.linkedBrowser;
|
is(
|
||||||
let result = newTab;
|
where,
|
||||||
BrowserTestUtils.waitForDocLoadAndStopIt(expectedUrl, newBrowser).then(
|
"tabshifted",
|
||||||
() => resolve(result)
|
"The link should open the expected URL in a new foreground tab"
|
||||||
);
|
|
||||||
},
|
|
||||||
{ once: true }
|
|
||||||
);
|
);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await SpecialPowers.spawn(tab, [promoImgSrc], async function (imgSrc) {
|
await SpecialPowers.spawn(tab, [promoImgSrc], async function (imgSrc) {
|
||||||
@@ -77,10 +75,11 @@ add_task(async function test_cookie_banners_promo() {
|
|||||||
);
|
);
|
||||||
ok(promoImage?.src === imgSrc, "Cookie banner reduction promo is shown");
|
ok(promoImage?.src === imgSrc, "Cookie banner reduction promo is shown");
|
||||||
let linkEl = content.document.getElementById("private-browsing-promo-link");
|
let linkEl = content.document.getElementById("private-browsing-promo-link");
|
||||||
EventUtils.synthesizeClick(linkEl);
|
linkEl.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
await tabOpened;
|
await triedToOpenTab;
|
||||||
|
sandbox.restore();
|
||||||
|
|
||||||
ok(true, "The link was clicked and the new tab opened");
|
ok(true, "The link was clicked and the new tab opened");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user