Bug 1010784: Null out sync loop target to avoid assertions when reusing sync XHR. r=khuey
authorShian-Yow Wu <swu@mozilla.com>
Wed, 28 May 2014 22:07:02 -0700
changeset 185537 05ec9bfe2eaa2e46cdd8499e6df30e8a3ed904a7
parent 185536 3af9693b858d2ce106f423384298192260245069
child 185538 ca0c1428aeba75f47059f7d2d5ca79fc74bae341
push id26855
push useremorley@mozilla.com
push dateThu, 29 May 2014 14:35:37 +0000
treeherdermozilla-central@9a72db713446 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1010784
milestone32.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 1010784: Null out sync loop target to avoid assertions when reusing sync XHR. r=khuey
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
@@ -949,16 +949,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;
   }
 }
 
@@ -1101,16 +1102,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>