Bug 936327. r=bent

This commit is contained in:
Kyle Huey 2013-11-19 14:05:41 +08:00
parent 9958c63251
commit 492d0e235c
6 changed files with 72 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "mozilla/dom/RootedDictionary.h"
#include "mozilla/dom/workers/Workers.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/Likely.h"
#include "mozilla/Util.h"
#include "nsCycleCollector.h"
@ -2323,6 +2324,8 @@ CreateGlobal(JSContext* aCx, T* aObject, nsWrapperCache* aCache,
return nullptr;
}
mozilla::HoldJSObjects(aObject);
return global;
}

View File

@ -4240,6 +4240,11 @@ WorkerPrivate::TraceTimeouts(const TraceCallbacks& aCallbacks,
for (uint32_t index = 0; index < mTimeouts.Length(); index++) {
TimeoutInfo* info = mTimeouts[index];
if (info->mTimeoutCallable.isUndefined()) {
continue;
}
aCallbacks.Trace(&info->mTimeoutCallable, "mTimeoutCallable", aClosure);
for (uint32_t index2 = 0; index2 < info->mExtraArgVals.Length(); index2++) {
aCallbacks.Trace(&info->mExtraArgVals[index2], "mExtraArgVals[i]", aClosure);

View File

@ -41,6 +41,8 @@ WorkerGlobalScope::WorkerGlobalScope(WorkerPrivate* aWorkerPrivate)
WorkerGlobalScope::~WorkerGlobalScope()
{
// Matches the HoldJSObjects in CreateGlobal.
mozilla::DropJSObjects(this);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerGlobalScope)

View File

@ -45,6 +45,7 @@ support-files =
threadErrors_worker4.js
threadTimeouts_worker.js
throwingOnerror_worker.js
timeoutTracing_worker.js
transferable_worker.js
urlApi_worker.js
url_worker.js
@ -96,6 +97,7 @@ support-files =
[test_threadErrors.html]
[test_threadTimeouts.html]
[test_throwingOnerror.html]
[test_timeoutTracing.html]
[test_transferable.html]
[test_url.html]
[test_urlApi.html]

View File

@ -0,0 +1,47 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<!--
Tests of DOM Worker Threads
-->
<head>
<title>Test for DOM Worker Threads</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var worker = new Worker("timeoutTracing_worker.js");
worker.onmessage = function(event) {
// begin
worker.onmessage = null;
// 1 second should be enough to crash.
window.setTimeout(function(event) {
ok(true, "Didn't crash!");
SimpleTest.finish();
}, 1000);
var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
.getService(SpecialPowers.Ci.nsIObserverService);
os.notifyObservers(null, "memory-pressure", "heap-minimize");
}
worker.onerror = function(event) {
ok(false, "I was expecting a crash, not an error");
SimpleTest.finish();
};
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,13 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
onmessage = function(event) {
throw "No messages should reach me!";
}
setInterval(function() { postMessage("Still alive!"); }, 20);
setInterval(";", 20);
postMessage("Begin!");