Bug 1367450 - Don't trigger captive portal check until delayed startup has completed. r=florian
authorNihanth Subramanya <nhnt11@gmail.com>
Thu, 01 Jun 2017 06:23:10 +0530
changeset 411118 90deb122d260c1547228ed2ac05e26750775f224
parent 411117 5719ed999b403c9a9949bf8c8f84f86fb8cf83bf
child 411119 47f43b453c2d66958de80486d851ea85d31c0756
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1367450
milestone55.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 1367450 - Don't trigger captive portal check until delayed startup has completed. r=florian MozReview-Commit-ID: LCinITjTlK7
browser/base/content/browser-captivePortal.js
--- a/browser/base/content/browser-captivePortal.js
+++ b/browser/base/content/browser-captivePortal.js
@@ -57,34 +57,45 @@ var CaptivePortalWatcher = {
       // A captive portal has already been detected.
       this._captivePortalDetected();
 
       // Automatically open a captive portal tab if there's no other browser window.
       let windows = Services.wm.getEnumerator("navigator:browser");
       if (windows.getNext() == window && !windows.hasMoreElements()) {
         this.ensureCaptivePortalTab();
       }
+    } else if (cps.state == cps.UNKNOWN) {
+      // We trigger a portal check after delayed startup to avoid doing a network
+      // request before first paint.
+      this._delayedRecheckPending = true;
+      Services.obs.addObserver(this, "browser-delayed-startup-finished");
     }
-
-    cps.recheckCaptivePortal();
   },
 
   uninit() {
     Services.obs.removeObserver(this, "captive-portal-login");
     Services.obs.removeObserver(this, "captive-portal-login-abort");
     Services.obs.removeObserver(this, "captive-portal-login-success");
 
+    if (this._delayedRecheckPending) {
+      Services.obs.removeObserver(this, "browser-delayed-startup-finished");
+    }
 
     if (this._delayedCaptivePortalDetectedInProgress) {
       Services.obs.removeObserver(this, "xul-window-visible");
     }
   },
 
   observe(aSubject, aTopic, aData) {
     switch (aTopic) {
+      case "browser-delayed-startup-finished":
+        Services.obs.removeObserver(this, "browser-delayed-startup-finished");
+        delete this._delayedRecheckPending;
+        cps.recheckCaptivePortal();
+        break;
       case "captive-portal-login":
         this._captivePortalDetected();
         break;
       case "captive-portal-login-abort":
       case "captive-portal-login-success":
         this._captivePortalGone();
         break;
       case "xul-window-visible":