Bug 1481771 - Fix a race condition in browser_privatebrowsing_favicon.js by ensuring the promises that wait on conditions that happen during opening a tab are created before starting to open the tab; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 02 May 2019 21:26:11 +0000
changeset 531185 df6f7b36dda2424aecf030f4458aa16c1f086bde
parent 531184 f197fa697b139be49bd95117c265b6aa308cc947
child 531186 407a7e536bac1be8d7924f942c7e2c8b2656cb79
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1481771
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 1481771 - Fix a race condition in browser_privatebrowsing_favicon.js by ensuring the promises that wait on conditions that happen during opening a tab are created before starting to open the tab; r=baku Differential Revision: https://phabricator.services.mozilla.com/D29717
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
@@ -239,21 +239,22 @@ add_task(async function test_favicon_cac
 
   Services.cache2.clear();
 
   // Clear all favicons in Places.
   await clearAllPlacesFavicons();
 
   // Add an observer for making sure the favicon has been loaded and cached.
   let promiseFaviconLoaded = waitOnFaviconLoaded(FAVICON_CACHE_URI);
+  let promiseFaviconResponse = waitOnFaviconResponse(FAVICON_CACHE_URI);
 
   // Open a tab for the non-private window.
   let tabInfoNonPrivate = await openTab(gBrowser, TEST_CACHE_PAGE);
 
-  let response = await waitOnFaviconResponse(FAVICON_CACHE_URI);
+  let response = await promiseFaviconResponse;
 
   await promiseFaviconLoaded;
 
   // Check that the favicon response has come from the network and it has the
   // correct privateBrowsingId.
   is(response.topic, "http-on-examine-response", "The favicon image should be loaded through network.");
   is(response.privateBrowsingId, 0, "We should observe the network response for the non-private tab.");
 
@@ -261,21 +262,23 @@ add_task(async function test_favicon_cac
   let privateWindow = await BrowserTestUtils.openNewBrowserWindow({ private: true });
 
   // The page must be bookmarked for favicon requests to go through in PB mode.
   await PlacesUtils.bookmarks.insert({
     parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     url: TEST_CACHE_PAGE,
   });
 
+  promiseFaviconResponse = waitOnFaviconResponse(FAVICON_CACHE_URI);
+
   // Open a tab for the private window.
   let tabInfoPrivate = await openTab(privateWindow.gBrowser, TEST_CACHE_PAGE);
 
   // Wait for the favicon response of the private tab.
-  response = await waitOnFaviconResponse(FAVICON_CACHE_URI);
+  response = await promiseFaviconResponse;
 
   // Make sure the favicon is loaded through the network and its privateBrowsingId is correct.
   is(response.topic, "http-on-examine-response", "The favicon image should be loaded through the network again.");
   is(response.privateBrowsingId, 1, "We should observe the network response for the private tab.");
 
   BrowserTestUtils.removeTab(tabInfoPrivate.tab);
   BrowserTestUtils.removeTab(tabInfoNonPrivate.tab);
   await BrowserTestUtils.closeWindow(privateWindow);