Bug 965309: Shut down the sync loop, if any, when we shut down the XHR. r=bent

This commit is contained in:
Kyle Huey 2014-05-28 22:07:38 -07:00
parent d5da409df9
commit 085314c510
5 changed files with 107 additions and 1 deletions

View File

@ -564,6 +564,7 @@ private:
MainThreadRun() MOZ_OVERRIDE
{
mProxy->Teardown();
MOZ_ASSERT(!mProxy->mSyncLoopTarget);
return NS_OK;
}
};
@ -953,14 +954,27 @@ Proxy::Teardown()
NS_RUNTIMEABORT("We're going to hang at shutdown anyways.");
}
if (mSyncLoopTarget) {
// We have an unclosed sync loop. Fix that now.
nsRefPtr<MainThreadStopSyncLoopRunnable> runnable =
new MainThreadStopSyncLoopRunnable(mWorkerPrivate,
mSyncLoopTarget.forget(),
false);
if (!runnable->Dispatch(nullptr)) {
NS_RUNTIMEABORT("We're going to hang at shutdown anyways.");
}
}
mWorkerPrivate = nullptr;
mSyncLoopTarget = nullptr;
mOutstandingSendCount = 0;
}
mXHRUpload = nullptr;
mXHR = nullptr;
}
MOZ_ASSERT(!mWorkerPrivate);
MOZ_ASSERT(!mSyncLoopTarget);
}
bool

View File

@ -46,6 +46,8 @@ support-files =
suspend_iframe.html
suspend_worker.js
terminate_worker.js
terminateSyncXHR_frame.html
terminateSyncXHR_worker.js
testXHR.txt
threadErrors_worker1.js
threadErrors_worker2.js
@ -124,6 +126,7 @@ skip-if = buildapp == 'b2g' # b2g(Failed to load script: relativeLoad_import.js)
[test_suspend.html]
skip-if = buildapp == 'b2g' || e10s # b2g(test timed out, might need more time) b2g-debug(test timed out, might need more time) b2g-desktop(test timed out, might need more time)
[test_terminate.html]
[test_terminateSyncXHR.html]
[test_threadErrors.html]
[test_threadTimeouts.html]
[test_throwingOnerror.html]

View File

@ -0,0 +1,25 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Test for SharedWorker</title>
</head>
<body>
<script type="text/javascript">
function doStuff() {
var worker = new Worker("terminateSyncXHR_worker.js");
worker.onmessage = function(event) {
parent.postMessage(event.data, "*");
};
worker.onerror = function(event) {
parent.postMessage("ERROR!", "*");
}
}
</script>
</body>
</html>

View File

@ -0,0 +1,19 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
onmessage = function(event) {
throw "No messages should reach me!";
}
var xhr = new XMLHttpRequest();
xhr.open("GET", "testXHR.txt", false);
xhr.addEventListener("loadstart", function ()
{
// Tell the parent to terminate us.
postMessage("TERMINATE");
// And wait for it to do so.
while(1) { true; }
});
xhr.send(null);

View File

@ -0,0 +1,45 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<!--
Tests of DOM Worker Threads XHR(Bug 450452 )
-->
<head>
<title>Test for DOM Worker Threads XHR (Bug 450452 )</title>
<script type="text/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=450452">DOM Worker Threads XHR (Bug 450452)</a>
<p id="display"></p>
<div id="content">
<iframe id="iframe" src="terminateSyncXHR_frame.html"></iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
var ifr = document.getElementById("iframe");
window.onmessage = function(event) {
if (event.data == "TERMINATE") {
ok(true, "Got TERMINATE");
ifr.parentNode.removeChild(ifr);
SimpleTest.finish();
} else {
ok(false, "Unexpected message: " + event.data);
}
}
SimpleTest.waitForExplicitFinish();
window.onload = function() {
ifr.contentWindow.doStuff();
}
</script>
</pre>
</body>
</html>