mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 936327. r=bent
This commit is contained in:
parent
9958c63251
commit
492d0e235c
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -41,6 +41,8 @@ WorkerGlobalScope::WorkerGlobalScope(WorkerPrivate* aWorkerPrivate)
|
||||
|
||||
WorkerGlobalScope::~WorkerGlobalScope()
|
||||
{
|
||||
// Matches the HoldJSObjects in CreateGlobal.
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerGlobalScope)
|
||||
|
@ -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]
|
||||
|
47
dom/workers/test/test_timeoutTracing.html
Normal file
47
dom/workers/test/test_timeoutTracing.html
Normal 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>
|
||||
|
13
dom/workers/test/timeoutTracing_worker.js
Normal file
13
dom/workers/test/timeoutTracing_worker.js
Normal 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!");
|
Loading…
Reference in New Issue
Block a user