Bug 1518410, try to make browser_UsageTelemetry_uniqueOriginsVisitedInPast24Hours.js fail a bit less likely, r=Ehsan

There is still another related bug 1579591, which this may make a bit less likely, since that seems to be timing dependent, but
the patch is not trying to fix that.

Differential Revision: https://phabricator.services.mozilla.com/D46242

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Olli Pettay 2019-09-19 14:29:09 +00:00
parent bee28f01d7
commit 5a966fa06e

View File

@ -53,9 +53,11 @@ add_task(async function test_uniqueDomainsVisitedInPast24Hours() {
"127.0.0.1 should not count as a unique visit"
);
// Set the expiry time to 1 second
// Set the expiry time to 4 seconds. The value should be reasonably short
// for testing, but long enough so that waiting for openNewForegroundTab
// does not cause the expiry timeout to run.
await SpecialPowers.pushPrefEnv({
set: [["browser.engagement.recent_visited_origins.expiry", 1]],
set: [["browser.engagement.recent_visited_origins.expiry", 4]],
});
// http://www.exämple.test
@ -71,13 +73,15 @@ add_task(async function test_uniqueDomainsVisitedInPast24Hours() {
let countBefore = URICountListener.uniqueDomainsVisitedInPast24Hours;
await new Promise(resolve => {
setTimeout(_ => {
let countAfter = URICountListener.uniqueDomainsVisitedInPast24Hours;
is(countAfter, countBefore - 1, "The expiry should work correctly");
resolve();
}, 1100);
});
// If expiration does not work correctly, the following will time out.
await BrowserTestUtils.waitForCondition(() => {
return (
URICountListener.uniqueDomainsVisitedInPast24Hours == countBefore - 1
);
}, 250);
let countAfter = URICountListener.uniqueDomainsVisitedInPast24Hours;
is(countAfter, countBefore - 1, "The expiry should work correctly");
BrowserTestUtils.removeTab(win.gBrowser.selectedTab);
BrowserTestUtils.removeTab(win.gBrowser.selectedTab);