Bug 1311237 - Fix the intermittent through making the observer been added earlier. r?baku draft
authorTim Huang <tihuang@mozilla.com>
Thu, 08 Dec 2016 16:04:06 -1000
changeset 448071 c5cd2a160f617f6db34b6159256701e509e186cf
parent 447934 d8f63b2935af0915a6a24b3ea8e27d9a09f66416
child 539206 5f7f36cd46c877715e233908369605d05f808649
push id38251
push userbmo:tihuang@mozilla.com
push dateFri, 09 Dec 2016 02:08:18 +0000
reviewersbaku
bugs1311237
milestone53.0a1
Bug 1311237 - Fix the intermittent through making the observer been added earlier. r?baku
browser/components/originattributes/test/browser/browser_favicon_firstParty.js
--- a/browser/components/originattributes/test/browser/browser_favicon_firstParty.js
+++ b/browser/components/originattributes/test/browser/browser_favicon_firstParty.js
@@ -291,24 +291,27 @@ add_task(function* test_favicon_firstPar
 add_task(function* test_favicon_cache_firstParty() {
   // Clear all image caches and network caches before running the test.
   clearAllImageCaches();
 
   let networkCache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
                         .getService(Ci.nsICacheStorageService);
   networkCache.clear();
 
+  // Start to observer the event of that favicon has been fully loaded and cached.
+  let promiseForFaviconLoaded = waitOnFaviconLoaded(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
+
+  // Start to observer for the favicon response of the first tab.
+  let responsePromise = waitOnFaviconResponse(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
+
   // Open the tab for the first site.
   let tabInfoA = yield openTab(TEST_SITE_ONE + TEST_CACHE_PAGE);
 
-  // Start to observer the event of that favicon has been fully loaded and cached.
-  let promiseForFaviconLoaded = waitOnFaviconLoaded(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
-
-  // Wait for the favicon response of the first tab.
-  let response = yield waitOnFaviconResponse(THIRD_PARTY_SITE + TEST_FAVICON_CACHE_URI);
+  // Waiting for the favicon response.
+  let response = yield responsePromise;
 
   // Make sure the favicon is loaded through the network and its first party domain is correct.
   is(response.topic, "http-on-examine-response", "The favicon image should be loaded through network.");
   is(response.firstPartyDomain, FIRST_PARTY_ONE, "We should only observe the network response for the first first party.");
 
   // Waiting until the favicon has been loaded and cached.
   yield promiseForFaviconLoaded;