blob: 02a12787f2c9715a7ddf72cf3d2a9667cbb58ad5 [file] [log] [blame]
<body onload="test()">
<p>The regression test for <a href=https://bugs.webkit.org/show_bug.cgi?id=99658>Bug 99658</a></p>
<p>The test starts bunch of workers that just throw an exception. During that time, current document is unloaded. The test passes if there are no crashes after the page unload.</p>
<p>Note that the test is potentially flaky and may produce false positives if we are unlucky with the worker exceptions timing. It should not fail if there is no bug though.</p>
<script src="../../resources/gc.js"></script>
<script>
function test() {
if (document.location.search == "?done") {
// Set timeout to give the test some time to crash.
setTimeout(function() {
if (window.testRunner) {
console.log("No crashes: PASSED!");
testRunner.notifyDone();
}
}, 100);
return;
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
// Create sufficiently large number of workers in hopes that one of the exceptions they throw will be processed in short time interval in
// which it could cause the crash from the bug.
var workers = [];
console.log("Creating the workers.")
for (var i = 0; i < 20; i++) {
setTimeout(function() {
try {
var worker = new Worker('resources/worker-exception.js');
worker.onerror = function(evt) {
// The number of worker exceptions that will be caught is not deterministic,
// so let's make sure the exception is not written to console to have deterministic text output.
evt.preventDefault();
};
workers.push(worker);
} catch (ex) {
}
}, i / 2);
}
setTimeout(function() {
console.log("Unloading the current document to see if there will be a crash.");
document.location.href = "?done";
workers = null;
gc();
}, 10);
}
</script>
</body>