Bug 1450416 - setTimeout/setInterval should silently fail if the worker is shutting down, r=asuth

This commit is contained in:
Andrea Marchesini 2018-03-31 09:47:51 +02:00
parent 0b49219fad
commit 3797da27ff
5 changed files with 34 additions and 14 deletions

View File

@ -4578,8 +4578,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx,
// If the worker is trying to call setTimeout/setInterval and the parent
// thread has initiated the close process then just silently fail.
if (currentStatus >= Closing) {
aRv.Throw(NS_ERROR_FAILURE);
return 0;
return timerId;
}
nsAutoPtr<TimeoutInfo> newInfo(new TimeoutInfo());

View File

@ -364483,6 +364483,12 @@
{}
]
],
"workers/interfaces/WorkerUtils/WindowTimers/005.html": [
[
"/workers/interfaces/WorkerUtils/WindowTimers/005.html",
{}
]
],
"workers/interfaces/WorkerUtils/importScripts/001.worker.js": [
[
"/workers/interfaces/WorkerUtils/importScripts/001.worker.html",
@ -599516,6 +599522,10 @@
"12d12036aa5937ae79aa152468cc574ac4bf4e94",
"testharness"
],
"workers/interfaces/WorkerUtils/WindowTimers/005.html": [
"11f0d7b6ea4a3c883d6c5cc8bde52c8ae9f7091b",
"testharness"
],
"workers/interfaces/WorkerUtils/importScripts/001.worker.js": [
"138e3be5d6375c8a784faabb4f2f4c82c2423bc3",
"testharness"

View File

@ -1,6 +0,0 @@
[setInterval.html]
disabled:
if debug: unstable
[close() and setInterval]
expected: FAIL

View File

@ -1,6 +0,0 @@
[setTimeout.html]
disabled:
if debug: unstable
[close() and setTimeout]
expected: FAIL

View File

@ -0,0 +1,23 @@
<!--
self.close();
var t = setInterval(function() {}, 10);
postMessage(t);
/*
-->
<!doctype html>
<title>setInterval when closing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var worker = new Worker('#');
worker.onmessage = this.step_func(function(e) {
assert_equals(e.data, 1);
this.done();
});
});
</script>
<!--
*/
//-->