Bug 791001 - Create an empty dummy builder in OnStopRequest if builder is null. r=smaug
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Mon, 17 Sep 2012 18:42:36 -0400
changeset 107296 f5db1f9f47fc
parent 107295 562ab305f2f3
child 107297 5cdc27b83300
push id14961
push userryanvm@gmail.com
push date2012-09-17 22:42 +0000
treeherdermozilla-inbound@8fce157732f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs791001
milestone18.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 791001 - Create an empty dummy builder in OnStopRequest if builder is null. r=smaug
content/base/crashtests/crashtests.list
content/base/crashtests/xhr_empty_datauri.html
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/crashtests/crashtests.list
+++ b/content/base/crashtests/crashtests.list
@@ -109,8 +109,9 @@ load 713417-2.html
 load 715056.html
 load 741163-1.html
 load 766426.html
 load 771639.html
 load 752226-1.html
 load 752226-2.html
 HTTP(..) load xhr_abortinprogress.html
 load 786854.html
+load xhr_empty_datauri.html
new file mode 100644
--- /dev/null
+++ b/content/base/crashtests/xhr_empty_datauri.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html class="reftest-wait"><meta charset=utf-8>
+<script>
+var xhr=new XMLHttpRequest();xhr.open("GET","data:,");xhr.responseType='blob';xhr.onloadend=function(){document.documentElement.removeAttribute('class');};xhr.send();
+</script>
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -2261,16 +2261,21 @@ nsXMLHttpRequest::OnStopRequest(nsIReque
        mResponseType == XML_HTTP_RESPONSE_TYPE_MOZ_BLOB)) {
     if (!mDOMFile) {
       CreateDOMFile(request);
     }
     if (mDOMFile) {
       mResponseBlob = mDOMFile;
       mDOMFile = nullptr;
     } else {
+      // mBuilder can be null if the channel is non-file non-cacheable
+      // and if the response length is zero.
+      if (!mBuilder) {
+        mBuilder = new nsDOMBlobBuilder();
+      }
       // Smaller files may be written in cache map instead of separate files.
       // Also, no-store response cannot be written in persistent cache.
       nsAutoCString contentType;
       mChannel->GetContentType(contentType);
       mBuilder->GetBlobInternal(NS_ConvertASCIItoUTF16(contentType),
                                 false, getter_AddRefs(mResponseBlob));
       mBuilder = nullptr;
     }