This commit is contained in:
Kyle Huey 2013-11-13 10:33:44 +08:00
Родитель a4eca92369
Коммит ecf3d29c3b
5 изменённых файлов: 66 добавлений и 0 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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]

Просмотреть файл

@ -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>

Просмотреть файл

@ -0,0 +1,12 @@
/**
* 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);
postMessage("Begin!");