Bug 1596000 - Avoid double pre-flight OPTIONS request when not necessary. r=Neil a=jorgk
authorBen Bucksch <ben.bucksch@beonex.com>
Wed, 13 Nov 2019 18:13:02 +0100
changeset 36412 db6162333c542d956ba8f43f9d94a6abfdf10686
parent 36411 216e79bcfb3ffdb15169f9445b2fe2de00926e3e
child 36413 f2f7e2432a04fe3a25bf50da78b3fcd08381d129
push id2527
push usermozilla@jorgk.com
push dateTue, 19 Nov 2019 08:49:01 +0000
treeherdercomm-beta@3e2b07cf1397 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, jorgk
bugs1596000
Bug 1596000 - Avoid double pre-flight OPTIONS request when not necessary. r=Neil a=jorgk Even though they could theoretically on different hostnames, they are in reality both on the same host, so avoid the second OPTIONS request, if it's on the same host.
mail/components/accountcreation/content/emailWizard.js
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -277,24 +277,26 @@ EmailConfigWizard.prototype = {
     _show("result_area");
     _hide("manual-edit_area");
 
     this.switchToMode("start");
     e("realname").select();
     window.sizeToContent();
 
     // In a new profile, the first request to live.thunderbird.net
-    // is much slower because of one-time overheads.
+    // is much slower because of one-time overheads like DNS and OCSP.
     // Let's create some dummy requests to prime the connections.
-    fetch(Services.prefs.getCharPref("mailnews.auto_config_url"), {
-      method: "OPTIONS",
-    });
-    fetch(Services.prefs.getCharPref("mailnews.auto_config.addons_url"), {
-      method: "OPTIONS",
-    });
+    let autoconfigURL = Services.prefs.getCharPref("mailnews.auto_config_url");
+    fetch(autoconfigURL, { method: "OPTIONS" });
+    let addonsURL = Services.prefs.getCharPref(
+      "mailnews.auto_config.addons_url"
+    );
+    if (new URL(autoconfigURL).origin != new URL(addonsURL).origin) {
+      fetch(addonsURL, { method: "OPTIONS" });
+    }
   },
 
   /**
    * Resize the window based on the content height and width.
    * Since the sizeToContent() method doesn't account for the height of
    * wrapped text, we're checking if the width and height of the "mastervbox"
    * is taller than the window width and height. This is necessary to account
    * for l10n strings or the user manually resizing the window.