mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1241485 - Increase the limit for workers per-origin, r=khuey
--HG-- extra : rebase_source : cff8b7973ceffe97e56d49adeeac13b040279a50
This commit is contained in:
parent
baf69da299
commit
d6444f776f
@ -141,6 +141,7 @@ support-files =
|
||||
[test_bug1132395.html]
|
||||
skip-if = true # bug 1176225
|
||||
[test_bug1132924.html]
|
||||
[test_bug1241485.html]
|
||||
[test_chromeWorker.html]
|
||||
[test_clearTimeouts.html]
|
||||
[test_close.html]
|
||||
|
82
dom/workers/test/test_bug1241485.html
Normal file
82
dom/workers/test/test_bug1241485.html
Normal file
@ -0,0 +1,82 @@
|
||||
<!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>
|
@ -142,7 +142,7 @@ pref("dom.select_events.enabled", false);
|
||||
// Whether or not Web Workers are enabled.
|
||||
pref("dom.workers.enabled", true);
|
||||
// The number of workers per domain allowed to run concurrently.
|
||||
pref("dom.workers.maxPerDomain", 20);
|
||||
pref("dom.workers.maxPerDomain", 50);
|
||||
|
||||
pref("dom.serviceWorkers.enabled", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user