Bug 1010784 - Null out sync loop target to avoid assertions when reusing sync XHR. r=khuey, a=lsblakk
authorShian-Yow Wu <swu@mozilla.com>
Wed, 28 May 2014 22:07:02 -0700
changeset 192414 f2a2af61e05db88d9281debc71782a5fad5ca7f6
parent 192413 69853748c1d7f3887e3f387c6b681e0375fedf5c
child 192415 99c91ade2a45378b08b7cb5f2d2eb1d31d9f95a7
push id3610
push userryanvm@gmail.com
push dateThu, 29 May 2014 17:14:25 +0000
treeherdermozilla-beta@99c91ade2a45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, lsblakk
bugs1010784
milestone30.0
Bug 1010784 - Null out sync loop target to avoid assertions when reusing sync XHR. r=khuey, a=lsblakk
dom/workers/XMLHttpRequest.cpp
dom/workers/test/file_bug1010784_worker.js
dom/workers/test/mochitest.ini
dom/workers/test/test_bug1010784.html
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -950,16 +950,17 @@ Proxy::Teardown()
     if (mOutstandingSendCount) {
       nsRefPtr<XHRUnpinRunnable> runnable =
         new XHRUnpinRunnable(mWorkerPrivate, mXMLHttpRequestPrivate);
       if (!runnable->Dispatch(nullptr)) {
         NS_RUNTIMEABORT("We're going to hang at shutdown anyways.");
       }
 
       mWorkerPrivate = nullptr;
+      mSyncLoopTarget = nullptr;
       mOutstandingSendCount = 0;
     }
 
     mXHRUpload = nullptr;
     mXHR = nullptr;
   }
 }
 
@@ -1102,16 +1103,17 @@ LoadStartDetectionRunnable::Run()
     } else if (mProxy->mOutstandingSendCount == 1) {
       mProxy->Reset();
 
       nsRefPtr<ProxyCompleteRunnable> runnable =
         new ProxyCompleteRunnable(mWorkerPrivate, mProxy,
                                   mXMLHttpRequestPrivate, mChannelId);
       if (runnable->Dispatch(nullptr)) {
         mProxy->mWorkerPrivate = nullptr;
+        mProxy->mSyncLoopTarget = nullptr;
         mProxy->mOutstandingSendCount--;
       }
     }
   }
 
   mProxy = nullptr;
   mXHR = nullptr;
   mXMLHttpRequestPrivate = nullptr;
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/file_bug1010784_worker.js
@@ -0,0 +1,9 @@
+onmessage = function(event) {
+  var xhr = new XMLHttpRequest();
+
+  xhr.open("GET", event.data, false);
+  xhr.send();
+  xhr.open("GET", event.data, false);
+  xhr.send();
+  postMessage("done");
+}
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -10,16 +10,17 @@ support-files =
   console_worker.js
   consoleReplaceable_worker.js
   csp_worker.js
   errorPropagation_iframe.html
   errorPropagation_worker.js
   errorwarning_worker.js
   eventDispatch_worker.js
   fibonacci_worker.js
+  file_bug1010784_worker.js
   importScripts_worker.js
   importScripts_worker_imported1.js
   importScripts_worker_imported2.js
   importScripts_worker_imported3.js
   importScripts_worker_imported4.js
   instanceof_worker.js
   json_worker.js
   jsversion_worker.js
@@ -69,16 +70,17 @@ support-files =
   subdir/relativeLoad_sub_worker2.js
   subdir/relativeLoad_sub_import.js
 
 [test_404.html]
 [test_atob.html]
 [test_blobConstructor.html]
 [test_blobWorkers.html]
 [test_bug949946.html]
+[test_bug1010784.html]
 [test_chromeWorker.html]
 [test_clearTimeouts.html]
 [test_close.html]
 [test_closeOnGC.html]
 skip-if = (buildapp == 'b2g' && (toolkit != 'gonk' || debug)) || toolkit == 'android' #bug 881404 # b2g-debug(times out) b2g-desktop(times out)
 [test_console.html]
 [test_consoleReplaceable.html]
 [test_contentWorker.html]
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_bug1010784.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1010784
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1010784</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1010784">Mozilla Bug 1010784</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+  var worker = new Worker("file_bug1010784_worker.js");
+
+  worker.onmessage = function(event) {
+    is(event.data, "done", "Got correct result");
+    SimpleTest.finish();
+  }
+
+  worker.postMessage("testXHR.txt");
+
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>