Bug 1541969 - Fix intermittent newtab/browser_asrouter_cfr.js r=k88hudson
authorAndrei Oprea <andrei.br92@gmail.com>
Thu, 16 May 2019 13:33:58 +0000
changeset 536018 96802be91766718fa33fe2e98f7a910e4dd1bb5e
parent 536017 6f7ed4fc33113c365c1c97a9ad7c7a8a9c1bc54d
child 536019 3ebc795b98bac8c64597369f65b7774d18111a93
child 536109 786f094a30ae94722246f078561928990ab1e0b7
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersk88hudson
bugs1541969
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1541969 - Fix intermittent newtab/browser_asrouter_cfr.js r=k88hudson Differential Revision: https://phabricator.services.mozilla.com/D31263
browser/components/newtab/test/browser/browser_asrouter_cfr.js
--- a/browser/components/newtab/test/browser/browser_asrouter_cfr.js
+++ b/browser/components/newtab/test/browser/browser_asrouter_cfr.js
@@ -371,38 +371,40 @@ add_task(async function test_onLocationC
   await BrowserTestUtils.browserLoaded(browser, false, TEST_URL);
 
   Assert.equal(count, 2, "We moved to a new document");
 });
 
 add_task(async function test_matchPattern() {
   let count = 0;
   const triggerHandler = () => ++count;
-  ASRouterTriggerListeners.get("frequentVisits").init(triggerHandler, [], ["*://*.example.com/"]);
+  const frequentVisitsTrigger = ASRouterTriggerListeners.get("frequentVisits");
+  frequentVisitsTrigger.init(triggerHandler, [], ["*://*.example.com/"]);
 
   const browser = gBrowser.selectedBrowser;
   await BrowserTestUtils.loadURI(browser, "http://example.com/");
   await BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
 
-  Assert.equal(count, 1, "Registered pattern matched the current location");
+  BrowserTestUtils.waitForCondition(() => frequentVisitsTrigger._visits.get("example.com").length === 1, "Registered pattern matched the current location");
 
   await BrowserTestUtils.loadURI(browser, "about:config");
   await BrowserTestUtils.browserLoaded(browser, false, "about:config");
 
-  Assert.equal(count, 1, "Navigated to a new page but not a match");
+  BrowserTestUtils.waitForCondition(() => frequentVisitsTrigger._visits.get("example.com").length === 1, "Navigated to a new page but not a match");
 
   await BrowserTestUtils.loadURI(browser, "http://example.com/");
   await BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
 
-  Assert.equal(count, 1, "Navigated to a location that matches the pattern but within 15 mins");
+  BrowserTestUtils.waitForCondition(() => frequentVisitsTrigger._visits.get("example.com").length === 1, "Navigated to a location that matches the pattern but within 15 mins");
 
   await BrowserTestUtils.loadURI(browser, "http://www.example.com/");
   await BrowserTestUtils.browserLoaded(browser, false, "http://www.example.com/");
 
-  Assert.equal(count, 2, "www.example.com is a different host that also matches the pattern.");
+  BrowserTestUtils.waitForCondition(() => frequentVisitsTrigger._visits.get("www.example.com").length === 1, "www.example.com is a different host that also matches the pattern.");
+  BrowserTestUtils.waitForCondition(() => frequentVisitsTrigger._visits.get("example.com").length === 1, "www.example.com is a different host that also matches the pattern.");
 });
 
 add_task(async function test_providerNames() {
   const providersBranch = "browser.newtabpage.activity-stream.asrouter.providers.";
   const cfrProviderPrefs = Services.prefs.getChildList(providersBranch);
   for (const prefName of cfrProviderPrefs) {
     const prefValue = JSON.parse(Services.prefs.getStringPref(prefName));
     if (prefValue.id) { // Snippets are disabled in tests and value is set to []