merge mozilla-inbound to mozilla-central. r=merge a=merge
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sun, 20 Aug 2017 23:24:15 +0200
changeset 649622 7dddbd85047c6dc73ddbe1e423cd643a217845b3
parent 649612 0286df0f0eba0e81e2c628c332f90457c38ea926 (current diff)
parent 649621 47172ec305228afaa7fff15c8cb3c864954ef14c (diff)
child 649623 bce6139373766b281a8ea76365e90de536697d16
child 649624 6a94c6da43a581702069d880fe480dfb668af7f0
child 649626 6caa3cc65026d8b1af2c708e74059223f2291d22
child 649635 f6881bb88d224896a8971a41b47a10d5b1cfc623
child 649637 d3383d9e5f97802c86ac21a4ed0a12f33487d054
child 649640 4f60032fa31871af7a0ce2459616cd59afd49b01
child 649646 ea10b09efae8a00314def0d51c0f681348aebdba
child 649648 f07e24e9dc36c7af14376691c0053ad643c2da67
child 649655 f7b204cacb5f6493e0010c64c2322d7fb81c5ab7
child 649658 9914f61c12671114a6e063b353f5ac70394ab9ae
child 649671 2bd16202e16784aa83eb2e5a822a2a967de5e995
child 649673 7906746f8cf75321d80c972032d1c8b2e097108f
child 649674 6668a2b3f65ac1b362fc1c2c4511ad8d8ee13d2f
child 649682 1c868acb96b35b72f76fab5c6930e9431745a682
child 649700 69f5d120ec38af52ec7d959d69652ca761f502f7
child 649706 ab6f60252a36cd187f768a10dda9f59a6ee3b1a5
child 649708 173bc1af4cfb85d432c409df754d1323d676cf34
child 649713 cd708ac7b0f45317827e834be0d8b8954d6eab9d
child 649716 677ab508030e3d0faf641e7dd6af2238a2191248
child 649717 ca0726c9b152e613eac73e9ee094020a589c1220
child 649718 1ca2f422e1286cb4e6b1a8f43356aa96c70e38fd
child 649719 b209f49e2be81b6f9df43bb36d96ef45dec71f4c
child 649727 97721224066b1eeb06a7d88cda5473b79c80ac72
child 649735 a41686860e9d56007bdefef519273dd64d65344e
child 649746 7966dd14a24a1e0469631f1d5556aae1843923ab
child 649747 e0c7025c92cc40aa776af94e25d72d5e47b11925
child 649750 74f00e42bbee76cf8da45bcda2c0725ca9cc4027
child 649752 a9ac63695d1548bd0b9036a32467d5ae300d34a3
child 649756 bdbf2f6633493c4655aea692bb0b778ab88bcd05
child 649759 190b87d7a0030e63f9252e325b946997c93f540d
child 649760 b40849e282cdf77aac3fd574a0dc1d8b4f510078
child 649761 da84406817d624e81c71ad75f0d79044faa45330
child 649763 1334172d7de16d76911fd54f1b2272e9ece01333
child 649764 3588360d88f0319908f2316a5e72799cf3f8a184
child 649766 2cf23b5af69d9db7f810f9f75c95dd2a15fca8af
child 649771 92cf38e3a4aa5f2606f4914f62283b6767e870a2
child 649774 cabf05f32c3ad55165336c208012000562a3c597
child 649782 5bf0610c96b4cd83d7f881f52838a6c3f4cc5971
child 649788 861ef3236a4bc77a24ce3ea92b5b1299460b9302
child 649789 a025cb7bc8902beea54bb35927874288d916c22a
child 649819 2b9a373c34eebdf54ad71fdd2fca42462bdc8539
child 649823 9adc007cab943b5f5ac3e084a9c9cff481bf3c69
child 649825 d58a6edc813f2315305fd63ad4aa9835ea3e272f
child 649847 50797933ec6712ffece56f6b7354d86bafe7dc76
child 649849 3ad01e2fe36da9e1ded8a85afb4c887256316af3
child 649875 b1ea096e3485981176336a5b01fdf44de27fe67f
child 649876 a1383e188bfd418fee72216afdef14f564deca39
child 649885 e23f19fb9b6233cd003572515567290ac9df354d
child 649886 db85b167c9fafab9c3113d7a92d123da122efa57
child 649888 2c55d1d7ca115826db9acb71d8feb555543a8990
child 649899 bd7e78a5e9f5bea1a0181024a3b342bf296c175b
child 649900 43b43299fcd6fcd550d2e241d36fe4aded6806c6
child 649901 7f5add763623ef00af5eee188efb54dc84096583
child 649904 db96840f7716d54320f1f08769bd2ad5319c1088
child 649905 cf5e49c0c24855143eacf5ff5c42b29ba976929f
child 649911 7a9ff4f17affdbcd09c34a00201ea85f2cebf0fe
child 649913 a2d140d2906dba0858554c4cd7b9e97f05474518
child 649914 6a50be304d6b7ca5cac53568652318bb98b3f3c8
child 649918 6094eb004a7598e154abd092b6c70b7419ac775c
child 649966 6d012d5662514b34494eda178f19bf0723d301d4
child 650040 0f854f11a376a4ef7c6d336ed68936771b458093
child 650044 9127181753653c050f7cdf344592e7e0ac99ea1e
child 650045 c6278f5644165906a6a337d6a4f98430261b2e11
child 650052 423699cb7adfee68150234f2437af2560f119be9
child 650090 9aad032830363df4625cf13a6f74b07d728532d5
child 650151 8e27e7541b86ce0270543f64ff36b046a3f1d3e3
child 650178 2e30d7cc8cd996132e10afb02a38331ccba11f7b
child 650202 1b546184438fd5338c9d8119974ff90b0ed35d4b
child 650252 8a9844308f03007075f82e1799eeb9cb8bbc0128
child 650253 1cfff2e2e8c601ba5522c3d20ed762e4a37b60fb
child 650255 9d7a201f571bc8da606956ac14be424e4d61f620
child 650257 8ec4df9160a8a749ace5678b7937f5f62ac16627
child 650266 b5b341e83210da700da1d7345474b969c6916d57
child 650268 ba9746043236952bd82086326359803cd8da0841
child 650269 ccc3570aba994046c2acf19320e159e19cf57043
child 650277 9e57a338b479c69dc2de77e90691c46c1e57a0ee
child 650329 809f7e5a97efe3e26d442e54785005fad04ffcd1
child 650332 792b00650fc784c3a4f7ec89aafbfa56431deaf3
child 650337 5c66dec053406077326dbf6270d1c1c73c58b4ec
child 650395 f0160c5790fe68e66ffe9ccbb761a7f32e011847
child 650398 2c525369ce37d5981c85959f2ef24f25f548cf90
child 650421 263b260823a0d84310ecdbcabb00200f20bb1dbc
child 650428 5ef76f53d514f3a5d0b10d66d84066710843f22b
child 650439 edff88b2a373fca2a6f28563320078ff6d7d4cd3
child 650564 5e5810df4aeae678f7bc7cf6ae486187bbe600cd
child 650969 cc05ea07517a8ac13a309740a1dbce4c64d34028
child 650970 724ae38bc0fe496c33e71e533e324dd90811aaa6
child 650971 e226857a865e8eb6cd2d39ab676f097c6dbdd4a7
child 651071 e1b4d7f8dd0885efcc7b83f97a38cbaf65adbfc7
child 651105 56423dab78aff6f86e4cadd823d442eee138a0a0
child 651151 ac61b7bf5dbacbe96af305b57ccabf758d1bc8ec
child 651210 92a7c8d4beae7af41e2767fdee13f2f98b9d3065
child 651321 1558f151c026b5c0ae94937d20784e3df8d8625a
child 651378 c6257c059c1c753f5b6b0b180630c21ac2f3a145
child 651847 527dbc66a876b03a199ff0129224d2fe9263d9d8
child 652143 d839fd11b694342587246d604f9f0ac193891831
child 652145 21a6065bbd12418e3db5908e5d155c3dd4480874
child 652183 d7556e1227a34623863da19cd0639c8b795da0c6
child 652687 7e0cf39e71dd040c5446f1aafba13a9867037d33
child 652798 9132d877b036823a938ef2a966688611e07af29e
child 653123 263f24206e3d5cb738804c33deccd6a3875e867b
child 654205 76f3564cb57e9a6a69f954cf28dbc283024b558e
child 654220 f7a21cc12e58d925543d86035ba4904272bff0e5
child 654255 ddd9f2b2493d70d35f11589bac924ad39592b039
child 654304 d275e7fb60ed9742e22c89b7506c5b4052a8d7de
child 654763 c31b59291dc99d9f359ea2d40a7695f35f8e5f60
child 655033 4e0320a7d3fdcb9c39d4afaa7fdbccf90258c1fb
child 655418 6b4167f0508bf3bfea7115f3cc42b93e5dd7d52e
child 655661 53fd1d1df0804d50f73f8e6db3d65858cdde6249
push id75073
push userbmo:mozilla@hocat.ca
push dateSun, 20 Aug 2017 22:21:51 +0000
reviewersmerge, merge
milestone57.0a1
merge mozilla-inbound to mozilla-central. r=merge a=merge MozReview-Commit-ID: 1yS8D5e0Ejz
--- a/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
+++ b/devtools/client/inspector/rules/test/browser_rules_eyedropper.js
@@ -96,16 +96,19 @@ function* testSelect(view, swatch, inspe
                                    options: {type: "mouseup"}});
 
   yield onPicked;
   yield onRuleViewChanged;
 
   let color = swatch.style.backgroundColor;
   is(color, EXPECTED_COLOR, "swatch changed colors");
 
+  ok(!swatch.eyedropperOpen, "swatch eye dropper is closed");
+  ok(!swatch.activeSwatch, "no active swatch");
+
   is((yield getComputedStyleProperty("div", null, "background-color")),
      EXPECTED_COLOR,
      "div's color set to body color after dropper");
 }
 
 function* openEyedropper(view, swatch) {
   let tooltip = view.tooltips.getTooltip("colorPicker").tooltip;
 
--- a/devtools/client/netmonitor/src/assets/styles/netmonitor.css
+++ b/devtools/client/netmonitor/src/assets/styles/netmonitor.css
@@ -92,25 +92,31 @@ body,
   align-items: center;
 }
 
 .requests-list-filter-buttons {
   display: flex;
   flex-wrap: wrap;
 }
 
-.learn-more-link {
-  color: var(--theme-highlight-blue);
-  cursor: pointer;
-  margin: 0 5px;
-  white-space: nowrap;
+/* Learn more links */
+
+.learn-more-link::before {
+  background-image: url(chrome://devtools/skin/images/help.svg);
 }
 
-.learn-more-link:hover {
-  text-decoration: underline;
+.tree-container .treeTable tr .learn-more-link {
+  position: absolute;
+  top: 0;
+  left: 0;
+  padding: 0;
+}
+
+.tree-container .treeTable tr:not(:hover) .learn-more-link {
+  opacity: 0.1;
 }
 
 /* Status bar */
 
 .devtools-status-bar-label {
   flex: 0;
 }
 
@@ -851,16 +857,17 @@ body,
    * Therefore, we set height with this magic number in order to remove the
    * redundant scrollbar when source editor appears.
    */
   height: calc(100% - 4px);
 }
 
 .tree-container .treeTable tr {
   display: block;
+  position: relative;
 }
 
 /* Make right td fill available horizontal space */
 .tree-container .treeTable td:last-child {
   width: 100%;
 }
 
 .properties-view .devtools-searchbox,
@@ -980,20 +987,16 @@ body,
 .headers-summary .textbox-input {
   margin-inline-end: 2px;
 }
 
 .headers-summary .status-text {
     width: auto!important;
 }
 
-.headers-summary .learn-more-link {
-  flex-grow: 1;
-}
-
 /* Response tabpanel */
 
 .response-error-header {
   margin: 0;
   padding: 3px 8px;
   background-color: var(--theme-highlight-red);
   color: var(--theme-selection-color);
 }
--- a/devtools/client/netmonitor/src/components/mdn-link.js
+++ b/devtools/client/netmonitor/src/components/mdn-link.js
@@ -14,20 +14,20 @@ const { L10N } = require("../utils/l10n"
 
 const { a } = DOM;
 
 const LEARN_MORE = L10N.getStr("netmonitor.headers.learnMore");
 
 function MDNLink({ url }) {
   return (
     a({
-      className: "learn-more-link",
-      title: url,
+      className: "devtools-button learn-more-link",
+      title: LEARN_MORE,
       onClick: (e) => onLearnMoreClick(e, url),
-    }, `[${LEARN_MORE}]`)
+    })
   );
 }
 
 MDNLink.displayName = "MDNLink";
 
 MDNLink.propTypes = {
   url: PropTypes.string.isRequired,
 };
--- a/devtools/client/netmonitor/test/browser_net_raw_headers.js
+++ b/devtools/client/netmonitor/test/browser_net_raw_headers.js
@@ -27,17 +27,17 @@ add_task(function* () {
 
   wait = waitForDOM(document, ".headers-overview");
   EventUtils.sendMouseEvent({ type: "mousedown" },
     document.querySelectorAll(".request-list-item")[0]);
   yield wait;
 
   wait = waitForDOM(document, ".raw-headers-container textarea", 2);
   EventUtils.sendMouseEvent({ type: "click" },
-    document.querySelectorAll(".headers-summary .devtools-button")[1]);
+    document.querySelectorAll(".headers-summary .devtools-button")[2]);
   yield wait;
 
   testShowRawHeaders(getSortedRequests(store.getState()).get(0));
 
   EventUtils.sendMouseEvent({ type: "click" },
     document.querySelectorAll(".headers-summary .devtools-button")[1]);
 
   testHideRawHeaders(document);
--- a/devtools/client/shared/widgets/tooltip/SwatchColorPickerTooltip.js
+++ b/devtools/client/shared/widgets/tooltip/SwatchColorPickerTooltip.js
@@ -171,16 +171,17 @@ SwatchColorPickerTooltip.prototype = Her
       this.hide();
 
       this.tooltip.emit("eyedropper-opened");
     }, e => console.error(e));
 
     inspector.once("color-picked", color => {
       toolbox.win.focus();
       this._selectColor(color);
+      this._onEyeDropperDone();
     });
 
     inspector.once("color-pick-canceled", () => {
       this._onEyeDropperDone();
     });
   },
 
   _onEyeDropperDone: function () {
--- a/devtools/client/themes/images/help.svg
+++ b/devtools/client/themes/images/help.svg
@@ -1,4 +1,6 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
-  <circle cx="12" cy="12" r="11" stroke-width="2" stroke="currentColor" fill="none"/>
-  <path d="M12.2,4.9c-1.6,0-2.9,0.4-3.8,0.8L9.2,8c0.6-0.4,1.5-0.6,2.2-0.6c1.1,0,1.6,0.5,1.6,1.2 c0,0.7-0.6,1.3-1.3,2.1c-1,1.1-1.4,2.1-1.3,3.2l0,0.5h3V14c0-0.9,0.3-1.7,1.2-2.5c0.9-0.9,1.9-1.9,1.9-3.4 C16.6,6.4,15.2,4.9,12.2,4.9z M12,16.1c-1.1,0-1.9,0.8-1.9,1.9c0,1.1,0.8,1.9,1.9,1.9c1.2,0,1.9-0.8,1.9-1.9 C13.9,16.9,13.1,16.1,12,16.1z"/>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+  <path fill="context-fill" d="M8 1a7 7 0 1 0 7 7 7.008 7.008 0 0 0-7-7zm0 13a6 6 0 1 1 6-6 6.007 6.007 0 0 1-6 6zM8 3.125A2.7 2.7 0 0 0 5.125 6a.875.875 0 0 0 1.75 0c0-1 .6-1.125 1.125-1.125a1.105 1.105 0 0 1 1.13.744.894.894 0 0 1-.53 1.016A2.738 2.738 0 0 0 7.125 9v.337a.875.875 0 0 0 1.75 0v-.37a1.041 1.041 0 0 1 .609-.824A2.637 2.637 0 0 0 10.82 5.16 2.838 2.838 0 0 0 8 3.125zm0 7.625A1.25 1.25 0 1 0 9.25 12 1.25 1.25 0 0 0 8 10.75z"></path>
 </svg>
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -84,16 +84,17 @@ using namespace mozilla::dom;
     result.swap(mPtr);               \
     return result.forget();          \
   }
 #include "mozilla/ServoArcTypeList.h"
 SERVO_ARC_TYPE(StyleContext, ServoStyleContext)
 #undef SERVO_ARC_TYPE
 
 static Mutex* sServoFontMetricsLock = nullptr;
+static Mutex* sServoWidgetLock = nullptr;
 static RWLock* sServoLangFontPrefsLock = nullptr;
 
 static
 const nsFont*
 ThreadSafeGetDefaultFontHelper(const nsPresContext* aPresContext,
                                nsIAtom* aLanguage, uint8_t aGenericId)
 {
   bool needsCache = false;
@@ -857,22 +858,24 @@ Gecko_FillAllMaskLists(nsStyleImageLayer
 }
 
 RawGeckoElementBorrowedOrNull
 Gecko_GetBody(RawGeckoPresContextBorrowed aPresContext)
 {
   return aPresContext->Document()->GetBodyElement();
 }
 
-nscolor Gecko_GetLookAndFeelSystemColor(int32_t aId,
-                                        RawGeckoPresContextBorrowed aPresContext)
+nscolor
+Gecko_GetLookAndFeelSystemColor(int32_t aId,
+                                RawGeckoPresContextBorrowed aPresContext)
 {
   bool useStandinsForNativeColors = aPresContext && !aPresContext->IsChrome();
   nscolor result;
   LookAndFeel::ColorID colorId = static_cast<LookAndFeel::ColorID>(aId);
+  MutexAutoLock guard(*sServoWidgetLock);
   LookAndFeel::GetColor(colorId, useStandinsForNativeColors, &result);
   return result;
 }
 
 bool
 Gecko_MatchStringArgPseudo(RawGeckoElementBorrowed aElement,
                            CSSPseudoClassType aType,
                            const char16_t* aIdent,
@@ -2453,23 +2456,29 @@ Gecko_XBLBinding_InheritsStyle(RawGeckoX
 
 void
 InitializeServo()
 {
   URLExtraData::InitDummy();
   Servo_Initialize(URLExtraData::Dummy());
 
   sServoFontMetricsLock = new Mutex("Gecko_GetFontMetrics");
+  sServoWidgetLock = new Mutex("Servo::WidgetLock");
   sServoLangFontPrefsLock = new RWLock("nsPresContext::GetDefaultFont");
 }
 
 void
 ShutdownServo()
 {
+  MOZ_ASSERT(sServoFontMetricsLock);
+  MOZ_ASSERT(sServoWidgetLock);
+  MOZ_ASSERT(sServoLangFontPrefsLock);
+
   delete sServoFontMetricsLock;
+  delete sServoWidgetLock;
   delete sServoLangFontPrefsLock;
   Servo_Shutdown();
 }
 
 namespace mozilla {
 
 void
 AssertIsMainThreadOrServoFontMetricsLocked()
--- a/netwerk/base/TCPFastOpenLayer.h
+++ b/netwerk/base/TCPFastOpenLayer.h
@@ -14,20 +14,30 @@ namespace net {
 
 /**
  * This layer must be placed just above PR-tcp socket, i.e. it must be under
  * nss layer.
  * At the beginning of TCPFastOpenLayer.cpp there is explanation what this
  * layer do.
  **/
 
-#define TFO_NOT_TRIED 0
-#define TFO_TRIED     1
-#define TFO_DATA_SENT 2
-#define TFO_FAILED    3
+typedef enum {
+  TFO_NOT_TRIED,
+  TFO_TRIED,
+  TFO_DATA_SENT,
+  TFO_FAILED_CONNECTION_REFUSED,
+  TFO_FAILED_NET_TIMEOUT,
+  TFO_FAILED_UNKNOW_ERROR,
+  TFO_FAILED_BACKUP_CONNECTION,
+  TFO_FAILED_CONNECTION_REFUSED_NO_TFO_FAILED_TOO,
+  TFO_FAILED_NET_TIMEOUT__NO_TFO_FAILED_TOO,
+  TFO_FAILED_UNKNOW_ERROR_NO_TFO_FAILED_TOO,
+  TFO_FAILED_BACKUP_CONNECTION_NO_TFO_FAILED_TOO,
+  TFO_FAILED
+} TFOResult;
 
 nsresult AttachTCPFastOpenIOLayer(PRFileDesc *fd);
 
 // Get the result of TCP Fast Open.
 void TCPFastOpenFinish(PRFileDesc *fd, PRErrorCode &err,
                        bool &fastOpenNotSupported, uint8_t &tfoStatus);
 
 int32_t TCPFastOpenGetBufferSizeLeft(PRFileDesc *fd);
--- a/netwerk/base/nsISocketTransport.idl
+++ b/netwerk/base/nsISocketTransport.idl
@@ -266,9 +266,11 @@ interface nsISocketTransport : nsITransp
      * Note that the attribute as well as the setter can only accessed
      * in the socket thread.
      */
     attribute boolean keepaliveEnabled;
     void setKeepaliveVals(in long keepaliveIdleTime,
                           in long keepaliveRetryInterval);
 
     [noscript] void setFastOpenCallback(in TCPFastOpenPtr aFastOpen);
+
+    readonly attribute nsresult firstRetryError;
 };
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -795,16 +795,18 @@ nsSocketTransport::nsSocketTransport()
     , mOutput(this)
     , mQoSBits(0x00)
     , mKeepaliveEnabled(false)
     , mKeepaliveIdleTimeS(-1)
     , mKeepaliveRetryIntervalS(-1)
     , mKeepaliveProbeCount(-1)
     , mFastOpenCallback(nullptr)
     , mFastOpenLayerHasBufferedData(false)
+    , mFastOpenStatus(TFO_NOT_TRIED)
+    , mFirstRetryError(NS_OK)
     , mDoNotRetryToConnect(false)
 {
     SOCKET_LOG(("creating nsSocketTransport @%p\n", this));
 
     mTimeouts[TIMEOUT_CONNECT]    = UINT16_MAX; // no timeout
     mTimeouts[TIMEOUT_READ_WRITE] = UINT16_MAX; // no timeout
 }
 
@@ -1565,35 +1567,34 @@ nsSocketTransport::InitiateSocket()
             mFastOpenCallback = nullptr;
             MutexAutoLock lock(mLock);
             mFDFastOpenInProgress = false;
             return rv;
         }
         status = PR_FAILURE;
         connectCalled = false;
         bool fastOpenNotSupported = false;
-        uint8_t tfoStatus = TFO_NOT_TRIED;
-        TCPFastOpenFinish(fd, code, fastOpenNotSupported, tfoStatus);
+        TCPFastOpenFinish(fd, code, fastOpenNotSupported, mFastOpenStatus);
 
         // If we have sent data, trigger a socket status event.
-        if (tfoStatus == TFO_DATA_SENT) {
+        if (mFastOpenStatus == TFO_DATA_SENT) {
             SendStatus(NS_NET_STATUS_SENDING_TO);
         }
 
         // If we have still some data buffered this data must be flush before
         // mOutput.OnSocketReady(NS_OK) is called in
         // nsSocketTransport::OnSocketReady, partially to keep socket status
         // event in order.
         mFastOpenLayerHasBufferedData = TCPFastOpenGetCurrentBufferSize(fd);
 
-        mFastOpenCallback->SetFastOpenStatus(tfoStatus);
+        mFastOpenCallback->SetFastOpenStatus(mFastOpenStatus);
         SOCKET_LOG(("called StartFastOpen - code=%d; fastOpen is %s "
                     "supported.\n", code,
                     fastOpenNotSupported ? "not" : ""));
-        SOCKET_LOG(("TFO status %d\n", tfoStatus));
+        SOCKET_LOG(("TFO status %d\n", mFastOpenStatus));
 
         if (fastOpenNotSupported) {
           // When TCP_FastOpen is turned off on the local host
           // SendTo will return PR_NOT_TCP_SOCKET_ERROR. This is only
           // on Linux.
           // If a windows version does not support Fast Open, the return value
           // will be PR_NOT_IMPLEMENTED_ERROR. This is only for windows 10
           // versions older than version 1607, because we do not have subverion
@@ -1771,18 +1772,23 @@ nsSocketTransport::RecoverFromError()
         tryAgain = true;
         // If we cancel the connection because backup socket was successfully
         // connected, mFDFastOpenInProgress will be true but mFastOpenCallback
         // will be nullptr.
         if (mFastOpenCallback) {
             mFastOpenCallback->SetFastOpenConnected(mCondition, true);
         }
         mFastOpenCallback = nullptr;
+
     } else {
 
+        // This is only needed for telemetry.
+        if (NS_SUCCEEDED(mFirstRetryError)) {
+            mFirstRetryError = mCondition;
+        }
         if ((mState == STATE_CONNECTING) && mDNSRecord &&
             mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) {
             if (mNetAddr.raw.family == AF_INET) {
                 Telemetry::Accumulate(Telemetry::IPV4_AND_IPV6_ADDRESS_CONNECTIVITY,
                                       UNSUCCESSFUL_CONNECTING_TO_IPV4_ADDRESS);
             } else if (mNetAddr.raw.family == AF_INET6) {
                 Telemetry::Accumulate(Telemetry::IPV4_AND_IPV6_ADDRESS_CONNECTIVITY,
                                       UNSUCCESSFUL_CONNECTING_TO_IPV6_ADDRESS);
@@ -2212,16 +2218,34 @@ nsSocketTransport::OnSocketReady(PRFileD
         // nsIOService::LastConectivityChange time to be atomic.
         PRIntervalTime connectStarted = 0;
         if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) {
             connectStarted = PR_IntervalNow();
         }
 
         PRStatus status = PR_ConnectContinue(fd, outFlags);
 
+#if defined(_WIN64) && defined(WIN95)
+#ifndef TCP_FASTOPEN
+#define TCP_FASTOPEN 15
+#endif
+
+        if (mFDFastOpenInProgress && mFastOpenCallback &&
+            (mFastOpenStatus == TFO_DATA_SENT)) {
+            PROsfd osfd = PR_FileDesc2NativeHandle(fd);
+            BOOL option = 0;
+            int len = sizeof(option);
+            PRInt32 rv = getsockopt((SOCKET)osfd, IPPROTO_TCP, TCP_FASTOPEN, (char*)&option, &len);
+            if ((rv != 0) && !option) {
+                // On error, I will let the normal necko paths pickup the error.
+                mFastOpenCallback->SetFastOpenStatus(TFO_NOT_TRIED);
+            }
+        }
+#endif
+
         if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase() &&
             connectStarted) {
             SendPRBlockingTelemetry(connectStarted,
                 Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_NORMAL,
                 Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_SHUTDOWN,
                 Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_CONNECTIVITY_CHANGE,
                 Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_LINK_CHANGE,
                 Telemetry::PRCONNECTCONTINUE_BLOCKING_TIME_OFFLINE);
@@ -3579,10 +3603,17 @@ nsSocketTransport::SendPRBlockingTelemet
 
 NS_IMETHODIMP
 nsSocketTransport::SetFastOpenCallback(TCPFastOpen *aFastOpen)
 {
   mFastOpenCallback = aFastOpen;
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsSocketTransport::GetFirstRetryError(nsresult *aFirstRetryError)
+{
+  *aFirstRetryError = mFirstRetryError;
+  return NS_OK;
+}
+
 } // namespace net
 } // namespace mozilla
--- a/netwerk/base/nsSocketTransport2.h
+++ b/netwerk/base/nsSocketTransport2.h
@@ -473,16 +473,18 @@ private:
     // Keepalive config (support varies by platform).
     int32_t mKeepaliveIdleTimeS;
     int32_t mKeepaliveRetryIntervalS;
     int32_t mKeepaliveProbeCount;
 
     // A Fast Open callback.
     TCPFastOpen *mFastOpenCallback;
     bool mFastOpenLayerHasBufferedData;
+    uint8_t mFastOpenStatus;
+    nsresult mFirstRetryError;
 
     bool mDoNotRetryToConnect;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // !nsSocketTransport_h__
--- a/netwerk/protocol/http/TunnelUtils.cpp
+++ b/netwerk/protocol/http/TunnelUtils.cpp
@@ -1520,16 +1520,22 @@ SocketTransportShim::SetEventSink(nsITra
 }
 
 NS_IMETHODIMP
 SocketTransportShim::Bind(NetAddr *aLocalAddr)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP
+SocketTransportShim::GetFirstRetryError(nsresult *aFirstRetryError)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 #define FWD_TS_PTR(fx, ts) NS_IMETHODIMP \
 SocketTransportShim::fx(ts *arg) { return mWrapped->fx(arg); }
 
 #define FWD_TS_ADDREF(fx, ts) NS_IMETHODIMP \
 SocketTransportShim::fx(ts **arg) { return mWrapped->fx(arg); }
 
 #define FWD_TS(fx, ts) NS_IMETHODIMP \
 SocketTransportShim::fx(ts arg) { return mWrapped->fx(arg); }
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -120,17 +120,30 @@ nsHttpConnection::~nsHttpConnection()
                               Telemetry::HTTP_KBREAD_PER_CONN,
                               totalKBRead);
     }
     if (mForceSendTimer) {
         mForceSendTimer->Cancel();
         mForceSendTimer = nullptr;
     }
 
-    Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN, mFastOpenStatus);
+    if ((mFastOpenStatus != TFO_FAILED) &&
+        ((mFastOpenStatus != TFO_NOT_TRIED) ||
+ #if defined(_WIN64) && defined(WIN95)
+         (gHttpHandler->UseFastOpen() &&
+          gSocketTransportService &&
+          gSocketTransportService->HasFileDesc2PlatformOverlappedIOHandleFunc()))) {
+#else
+         gHttpHandler->UseFastOpen())) {
+#endif
+        // TFO_FAILED will be reported in the replacement connection with more
+        // details.
+        // Otherwise report only if TFO is enabled and supported.
+        Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_2, mFastOpenStatus);
+    }
 }
 
 nsresult
 nsHttpConnection::Init(nsHttpConnectionInfo *info,
                        uint16_t maxHangTime,
                        nsISocketTransport *transport,
                        nsIAsyncInputStream *instream,
                        nsIAsyncOutputStream *outstream,
@@ -2389,15 +2402,28 @@ nsHttpConnection::SetFastOpen(bool aFast
     if (!mFastOpen &&
         mTransaction &&
         !mTransaction->IsNullTransaction()) {
         mExperienced = true;
     }
 }
 
 void
+nsHttpConnection::SetFastOpenStatus(uint8_t tfoStatus) {
+    mFastOpenStatus = tfoStatus;
+    if ((mFastOpenStatus >= TFO_FAILED_CONNECTION_REFUSED) &&
+        mSocketTransport) {
+        nsresult firstRetryError;
+        if (NS_SUCCEEDED(mSocketTransport->GetFirstRetryError(&firstRetryError)) &&
+            (NS_FAILED(firstRetryError))) {
+            mFastOpenStatus = tfoStatus + 4; 
+        }
+    }
+}
+
+void
 nsHttpConnection::BootstrapTimings(TimingStruct times)
 {
     mBootstrappedTimings = times;
 }
 
 } // namespace net
 } // namespace mozilla
--- a/netwerk/protocol/http/nsHttpConnection.h
+++ b/netwerk/protocol/http/nsHttpConnection.h
@@ -228,19 +228,17 @@ public:
             !mFastOpen;
     }
     // override of nsAHttpConnection
     virtual uint32_t Version();
 
     bool TestJoinConnection(const nsACString &hostname, int32_t port);
     bool JoinConnection(const nsACString &hostname, int32_t port);
 
-    void SetFastOpenStatus(uint8_t tfoStatus) {
-        mFastOpenStatus = tfoStatus;
-    }
+    void SetFastOpenStatus(uint8_t tfoStatus);
 
 private:
     // Value (set in mTCPKeepaliveConfig) indicates which set of prefs to use.
     enum TCPKeepaliveConfig {
       kTCPKeepaliveDisabled = 0,
       kTCPKeepaliveShortLivedConfig,
       kTCPKeepaliveLongLivedConfig
     };
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -3721,16 +3721,17 @@ nsHalfOpenSocket::nsHalfOpenSocket(nsCon
     , mIsFromPredictor(isFromPredictor)
     , mAllow1918(true)
     , mHasConnected(false)
     , mPrimaryConnectedOK(false)
     , mBackupConnectedOK(false)
     , mFreeToUse(true)
     , mPrimaryStreamStatus(NS_OK)
     , mFastOpenInProgress(false)
+    , mFastOpenStatus(TFO_NOT_TRIED)
     , mEnt(ent)
 {
     MOZ_ASSERT(ent && trans, "constructor with null arguments");
     LOG(("Creating nsHalfOpenSocket [this=%p trans=%p ent=%s key=%s]\n",
          this, trans, ent->mConnInfo->Origin(), ent->mConnInfo->HashKey().get()));
 
     if (speculative) {
         Telemetry::AutoCounter<Telemetry::HTTPCONNMGR_TOTAL_SPECULATIVE_CONN> totalSpeculativeConn;
@@ -4171,16 +4172,17 @@ nsHalfOpenSocket::OnOutputStreamReady(ns
         }
         if (mEnt->mUseFastOpen) {
             gHttpHandler->IncrementFastOpenConsecutiveFailureCounter();
             mEnt->mUseFastOpen = false;
         }
 
         mFastOpenInProgress = false;
         mConnectionNegotiatingFastOpen = nullptr;
+        mFastOpenStatus = TFO_FAILED_BACKUP_CONNECTION;
     }
 
     nsresult rv =  SetupConn(out, false);
     if (mEnt) {
         mEnt->mDoNotDestroy = false;
     }
     return rv;
 }
@@ -4353,16 +4355,17 @@ nsHalfOpenSocket::SetFastOpenConnected(n
     if (aWillRetry &&
         ((aError == NS_ERROR_CONNECTION_REFUSED) ||
 #if defined(_WIN64) && defined(WIN95)
          // On Windows PR_ContinueConnect can return NS_ERROR_FAILURE.
          // This will be fixed in bug 1386719 and this is just a temporary
          // work around.
          (aError == NS_ERROR_FAILURE) ||
 #endif
+         (aError == NS_ERROR_PROXY_CONNECTION_REFUSED) ||
          (aError == NS_ERROR_NET_TIMEOUT))) {
         if (mEnt->mUseFastOpen) {
             gHttpHandler->IncrementFastOpenConsecutiveFailureCounter();
             mEnt->mUseFastOpen = false;
         }
         // This is called from nsSocketTransport::RecoverFromError. The
         // socket will try connect and we need to rewind nsHttpTransaction.
 
@@ -4392,16 +4395,24 @@ nsHalfOpenSocket::SetFastOpenConnected(n
         gHttpHandler->ConnMgr()->StartedConnect();
 
         // Restore callbacks.
         mStreamOut->AsyncWait(this, 0, 0, nullptr);
         mSocketTransport->SetEventSink(this, nullptr);
         mSocketTransport->SetSecurityCallbacks(this);
         mStreamIn->AsyncWait(nullptr, 0, 0, nullptr);
 
+        if (aError == NS_ERROR_CONNECTION_REFUSED) {
+            mFastOpenStatus = TFO_FAILED_CONNECTION_REFUSED;
+        } else if (aError == NS_ERROR_NET_TIMEOUT) {
+            mFastOpenStatus = TFO_FAILED_NET_TIMEOUT;
+        } else {
+            mFastOpenStatus = TFO_FAILED_UNKNOW_ERROR;
+        }
+
     } else {
         // On success or other error we proceed with connection, we just need
         // to close backup timer and halfOpenSock.
         CancelBackupTimer();
         if (NS_SUCCEEDED(aError)) {
             NetAddr peeraddr;
             if (NS_SUCCEEDED(mSocketTransport->GetPeerAddr(&peeraddr))) {
                 mEnt->RecordIPFamilyPreference(peeraddr.raw.family);
@@ -4653,16 +4664,18 @@ nsHalfOpenSocket::SetupConn(nsIAsyncOutp
         MOZ_ASSERT(mEnt);
         MOZ_ASSERT(static_cast<int32_t>(mEnt->mIdleConns.IndexOf(conn)) == -1);
         int32_t idx = mEnt->mActiveConns.IndexOf(conn);
         if (NS_SUCCEEDED(rv) && (idx != -1)) {
             mConnectionNegotiatingFastOpen = conn;
         } else {
             conn->SetFastOpen(false);
         }
+    } else {
+        conn->SetFastOpenStatus(mFastOpenStatus);
     }
 
     // If this halfOpenConn was speculative, but at the ende the conn got a
     // non-null transaction than this halfOpen is not speculative anymore!
     if (conn->Transaction() && !conn->Transaction()->IsNullTransaction()) {
         Claim();
     }
 
--- a/netwerk/protocol/http/nsHttpConnectionMgr.h
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.h
@@ -468,16 +468,17 @@ private:
         // but the transaction can be dispatch to another connection. In that
         // case we can free this transaction to be claimed by other
         // transactions.
         bool                           mFreeToUse;
         nsresult                       mPrimaryStreamStatus;
 
         bool                           mFastOpenInProgress;
         RefPtr<nsHttpConnection>       mConnectionNegotiatingFastOpen;
+        uint8_t                        mFastOpenStatus;
 
         RefPtr<nsConnectionEntry>      mEnt;
         nsCOMPtr<nsITimer>             mSynTimer;
         nsCOMPtr<nsISocketTransport>   mBackupTransport;
         nsCOMPtr<nsIAsyncOutputStream> mBackupStreamOut;
         nsCOMPtr<nsIAsyncInputStream>  mBackupStreamIn;
     };
     friend class nsHalfOpenSocket;
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -2294,16 +2294,26 @@ nsHttpHandler::Observe(nsISupports *subj
         // depend on this value.
         mSessionStartTime = NowInSeconds();
 
         if (!mDoNotTrackEnabled) {
             Telemetry::Accumulate(Telemetry::DNT_USAGE, 2);
         } else {
             Telemetry::Accumulate(Telemetry::DNT_USAGE, 1);
         }
+
+        if (UseFastOpen()) {
+            Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 0);
+        } else if (!mFastOpenSupported) {
+            Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 1);
+        } else if (!mUseFastOpen) {
+            Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 2);
+        } else {
+            Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 3);
+        }
     } else if (!strcmp(topic, "profile-change-net-restore")) {
         // initialize connection manager
         rv = InitConnectionMgr();
         MOZ_ASSERT(NS_SUCCEEDED(rv));
     } else if (!strcmp(topic, "net:clear-active-logins")) {
         Unused << mAuthCache.ClearAll();
         Unused << mPrivateAuthCache.ClearAll();
     } else if (!strcmp(topic, "net:prune-dead-connections")) {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -2540,24 +2540,33 @@
     "alert_emails": ["necko@mozilla.com"],
     "bug_numbers": [1357682],
     "expires_in_version": "61",
     "kind": "categorical",
     "keyed": true,
     "description": "Stats about success rate of HTTP OMT request in content process, keyed by content policy.",
     "labels": ["success", "successMainThread", "failListener", "failListenerChain", "notRequested"]
   },
-  "TCP_FAST_OPEN": {
+  "TCP_FAST_OPEN_2": {
+    "record_in_processes": ["main", "content"],
+    "expires_in_version": "61",
+    "kind": "enumerated",
+    "n_values": 16,
+    "description": "When a http connection is closed, track whether or not TCP Fast Open was used: 0=TFO_NOT_TRIED(There was no http connection and it was not TLS), 1=TFO_TRIED_NEGOTIATING, 2=TFO_DATA_SENT, 3=TFO_FAILED_CONNECTION_REFUSED, 4=TFO_FAILED_NET_TIMEOUT, 5=TFO_FAILED_UNKNOW_ERROR, 6=TFO_FAILED_BACKUP_CONNECTION, 7=TFO_FAILED_CONNECTION_REFUSED_NO_TFO_FAILED_TOO, 8=TFO_FAILED_NET_TIMEOUT__NO_TFO_FAILED_TOO, 9=TFO_FAILED_UNKNOW_ERROR_NO_TFO_FAILED_TOO, 10=TFO_FAILED_BACKUP_CONNECTION_NO_TFO_FAILED_TOO.",
+    "alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
+    "bug_numbers": [1390881]
+  },
+  "TCP_FAST_OPEN_STATUS": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "61",
     "kind": "enumerated",
     "n_values": 8,
-    "description": "When a http connection is closed, track whether or not TCP Fast Open was used: 0=TFO_NOT_TRIED, 1=TFO_TRIED_NEGOTIATING, 2=TFO_DATA_SENT, 3=TFO_FAILED.",
-    "alert_emails": ["necko@mozilla.com"],
-    "bug_numbers": [1352271]
+    "description": "TCP Fast Open was: 0=enabled during the session, 1=not available or disabled in the os, 2=disabled by the pref, 3=disabled based on the too many connection failures.",
+    "alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
+    "bug_numbers": [1390881]
   },
   "TLS_EARLY_DATA_NEGOTIATED": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "58",
     "kind": "enumerated",
     "n_values": 3,
     "description": "Sending TLS early data was possible: 0 - not possible, 1 - possible but not used, 2 - possible and used.",
     "alert_emails": ["necko@mozilla.com"],