mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
d6444f776f
--HG-- extra : rebase_source : cff8b7973ceffe97e56d49adeeac13b040279a50
83 lines
2.2 KiB
HTML
83 lines
2.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1241485
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 1241485</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 1241485 **/
|
|
SimpleTest.waitForExplicitFinish();
|
|
SimpleTest.requestCompleteLog();
|
|
SimpleTest.requestFlakyTimeout("requestFlakyTimeout is silly.");
|
|
|
|
var limit = SpecialPowers.Services.prefs.getIntPref("dom.workers.maxPerDomain");
|
|
var workers = new Array();
|
|
var workerToWait = null;
|
|
var url = URL.createObjectURL(new Blob(["postMessage('loaded');"]));
|
|
var timeouts = new Array();
|
|
|
|
function addTimeout(fn, time) {
|
|
timeouts.push(setTimeout(fn, time));
|
|
}
|
|
|
|
function createWorker() {
|
|
workerToWait = new Worker(url);
|
|
workerToWait.onmessage = function(e) {
|
|
if (!workers) {
|
|
// finish() has been called already.
|
|
return;
|
|
}
|
|
workers.push(workerToWait);
|
|
info(workers.length + " workers");
|
|
addTimeout(createWorker, 0);
|
|
if (workers.length == limit) {
|
|
// Just give the worker creation loop some more time to try to
|
|
// create more workers to check that we don't go over the limit.
|
|
addTimeout(finish, 250);
|
|
}
|
|
};
|
|
}
|
|
|
|
function test() {
|
|
info("Expecting no more than " + limit + " workers.");
|
|
// Make sure we finish at some point, even if creating workers takes
|
|
// lots of time.
|
|
addTimeout(finish, 10000);
|
|
addTimeout(createWorker, 0);
|
|
}
|
|
|
|
function finish() {
|
|
for (var i = 0; i < timeouts.length; ++i) {
|
|
clearTimeout(timeouts[i]);
|
|
}
|
|
|
|
if (workerToWait) {
|
|
workerToWait.onmessage = null;
|
|
}
|
|
|
|
ok(workers.length <= limit, "Too many workers created!");
|
|
|
|
workers = null;
|
|
SpecialPowers.gc();
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="test();">
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1241485">Mozilla Bug 1241485</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|