Bug 1346767 - Part 1: Check mFlagHadUploadListenersOnSend before sending progress event, r=baku
authorShawn Huang <shuang@mozilla.com>
Mon, 24 Jul 2017 19:52:16 +0800
changeset 419290 f0817bf2f80b3f4cf8ea2d4f98904c23bce9b9b3
parent 419289 3c35ec94f3ed32031f6d953a54dd90c9f7c1d0e8
child 419291 4377bafde262dfe03a76c94d365df0cf535f45fc
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1346767
milestone56.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 1346767 - Part 1: Check mFlagHadUploadListenersOnSend before sending progress event, r=baku Based on XHR spec 6.1, if one or more event listeners are registered on the associated XMLHttpRequestUpload object, then set upload listener flag. Therefore, if any event listeners are added after send(), ignore them.
dom/xhr/XMLHttpRequestMainThread.cpp
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -3740,17 +3740,17 @@ XMLHttpRequestMainThread::HandleProgress
 
   mProgressTimerIsActive = false;
 
   if (!mProgressSinceLastProgressEvent || mErrorLoad != ErrorType::eOK) {
     return;
   }
 
   if (InUploadPhase()) {
-    if (mUpload && !mUploadComplete) {
+    if (mUpload && !mUploadComplete && mFlagHadUploadListenersOnSend) {
       DispatchProgressEvent(mUpload, ProgressEventType::progress,
                             mUploadTransferred, mUploadTotal);
     }
   } else {
     FireReadystatechangeEvent();
     DispatchProgressEvent(this, ProgressEventType::progress,
                           mLoadTransferred, mLoadTotal);
   }