Bug 1510700 wait for ContextualIdentityService before updating Discovery cookies r=Gijs
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 28 Nov 2018 19:14:10 +0000
changeset 507773 db4247c271273dc6316f9cea5f3fd6d42e83e0d6
parent 507772 7fa4a5ba46716d2eb35c628e18f36c765e349c0c
child 507774 7235cbf1093860707e4094dd2cb1fe4c3f229596
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1510700
milestone65.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 1510700 wait for ContextualIdentityService before updating Discovery cookies r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D13291
browser/components/nsBrowserGlue.js
toolkit/components/contextualidentity/ContextualIdentityService.jsm
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1574,18 +1574,19 @@ BrowserGlue.prototype = {
    * _scheduleArbitrarilyLateIdleTasks.
    * Don't be fooled by thinking that the use of the timeout parameter
    * will delay your function: it will just ensure that it potentially
    * happens _earlier_ than expected (when the timeout limit has been reached),
    * but it will not make it happen later (and out of order) compared
    * to the other ones scheduled together.
    */
   _scheduleStartupIdleTasks() {
-    Services.tm.idleDispatchToMainThread(() => {
-      ContextualIdentityService.load();
+    Services.tm.idleDispatchToMainThread(async () => {
+      await ContextualIdentityService.load();
+      Discovery.update();
     });
 
     Services.tm.idleDispatchToMainThread(() => {
       let enableCertErrorUITelemetry =
         Services.prefs.getBoolPref("security.certerrors.recordEventTelemetry", false);
       Services.telemetry.setEventRecordingEnabled("security.ui.certerror",
         enableCertErrorUITelemetry);
     });
@@ -1667,20 +1668,16 @@ BrowserGlue.prototype = {
       Blocklist.loadBlocklistAsync();
     });
 
     if (Services.prefs.getIntPref("browser.livebookmarks.migrationAttemptsLeft", 0) > 0) {
       Services.tm.idleDispatchToMainThread(() => {
         LiveBookmarkMigrator.migrate().catch(Cu.reportError);
       });
     }
-
-    Services.tm.idleDispatchToMainThread(() => {
-      Discovery.update();
-    });
   },
 
   /**
    * Use this function as an entry point to schedule tasks that need
    * to run once per session, at any arbitrary point in time.
    * This function will be called from an idle observer. Check the value of
    * LATE_TASKS_IDLE_TIME_SEC to see the current value for this idle
    * observer.
--- a/toolkit/components/contextualidentity/ContextualIdentityService.jsm
+++ b/toolkit/components/contextualidentity/ContextualIdentityService.jsm
@@ -142,17 +142,17 @@ function _ContextualIdentityService(path
         await this.closeContainerTabs();
         this.notifyAllContainersCleared();
         this.resetDefault();
       }
     }
   },
 
   load() {
-    OS.File.read(this._path).then(bytes => {
+    return OS.File.read(this._path).then(bytes => {
       // If synchronous loading happened in the meantime, exit now.
       if (this._dataReady) {
         return;
       }
 
       try {
         this.parseData(bytes);
       } catch (error) {