Bug 1009640 - The final upload progress event should have lengthComputable true. r=bz, a=sledru
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 22 May 2014 13:54:32 +0300
changeset 193397 4d1be211f901adbe5259316ce532953997d4d033
parent 193396 96491de02d3aaf35b883950b584932048d051ec4
child 193398 c4eead99c95ba9d3452c43f62d329de6939fff48
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sledru
bugs1009640
milestone30.0
Bug 1009640 - The final upload progress event should have lengthComputable true. r=bz, a=sledru
content/base/src/nsXMLHttpRequest.cpp
content/base/test/test_bug435425.html
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -1904,16 +1904,17 @@ nsXMLHttpRequest::OnStartRequest(nsIRequ
       (mState & XML_HTTP_REQUEST_ASYNC)) {
     if (mProgressTimerIsActive) {
       mProgressTimerIsActive = false;
       mProgressNotifier->Cancel();
     }
     if (mUploadTransferred < mUploadTotal) {
       mUploadTransferred = mUploadTotal;
       mProgressSinceLastProgressEvent = true;
+      mUploadLengthComputable = true;
       MaybeDispatchProgressEvents(true);
     }
     mUploadComplete = true;
     DispatchProgressEvent(mUpload, NS_LITERAL_STRING(LOAD_STR),
                           true, mUploadTotal, mUploadTotal);
   }
 
   mContext = ctxt;
--- a/content/base/test/test_bug435425.html
+++ b/content/base/test/test_bug435425.html
@@ -32,16 +32,19 @@ function logEvent(evt) {
          ((currentEvents[i].type != evt.type) ||
           !(evt.target instanceof currentEvents[i].target))) {
     ++i;
   }
   if (evt.target instanceof XMLHttpRequestUpload) {
     if (evt.type == "loadstart") {
       uploadTotal = evt.total
     } else {
+      if (evt.type == "progress") {
+        ok(evt.lengthComputable, "event(" + evt.type +  ").lengthComputable should be true.");
+      }
       is(evt.total, uploadTotal, "event(" + evt.type +  ").total should not change during upload.");
     }
   }
   ok(i != currentEvents.length, "Extra or wrong event?");
   is(evt.type, currentEvents[i].type, "Wrong event!")
   ok(evt.target instanceof currentEvents[i].target,
      "Wrong event target [" + evt.target + "," + evt.type + "]!");
   // If we handled non-optional event, remove all optional events before the