Bug 1362354 - Handle XHRs with aborted bindings as aborted rather than network errors. r?baku draft
authorThomas Wisniewski <twisniewski@mozilla.com>
Thu, 02 Aug 2018 19:07:07 -0700
changeset 826341 7e8615c09c2de41ee0dc782382511094899019e0
parent 826308 3d107866825433ab1168c7d23e94eac727e0f673
push id118300
push userwisniewskit@gmail.com
push dateFri, 03 Aug 2018 17:16:37 +0000
reviewersbaku
bugs1362354
milestone63.0a1
Bug 1362354 - Handle XHRs with aborted bindings as aborted rather than network errors. r?baku MozReview-Commit-ID: 86e00dRe6qc
dom/xhr/XMLHttpRequestMainThread.cpp
testing/web-platform/meta/xhr/abort-after-stop.htm.ini
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -2095,16 +2095,24 @@ XMLHttpRequestMainThread::OnStopRequest(
   // Is this good enough here?
   if (mXMLParserStreamListener && mFlagParseBody) {
     mXMLParserStreamListener->OnStopRequest(request, ctxt, status);
   }
 
   mXMLParserStreamListener = nullptr;
   mContext = nullptr;
 
+  // If window.stop() or other aborts were issued, handle as an abort
+  if (status == NS_BINDING_ABORTED) {
+    mFlagParseBody = false;
+    IgnoredErrorResult rv;
+    RequestErrorSteps(ProgressEventType::abort, NS_OK, rv);
+    return NS_OK;
+  }
+
   bool waitingForBlobCreation = false;
 
   // If we have this error, we have to deal with a file: URL + responseType =
   // blob. We have this error because we canceled the channel. The status will
   // be set to NS_OK.
   if (status == NS_ERROR_FILE_ALREADY_EXISTS &&
       mResponseType == XMLHttpRequestResponseType::Blob) {
     nsCOMPtr<nsIFile> file;
deleted file mode 100644
--- a/testing/web-platform/meta/xhr/abort-after-stop.htm.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[abort-after-stop.htm]
-  [XMLHttpRequest: abort event should fire when stop() method is used]
-    expected: FAIL
-