mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
e499e838b2
* * * Bug 649537 - 'Workers: Make one OS thread and JS runtime per worker, and lose XPConnect'. r=sicking+mrbkap. Add workaround for bug 666963. --HG-- rename : dom/src/threads/Makefile.in => dom/workers/Makefile.in rename : dom/src/threads/test/Makefile.in => dom/workers/test/Makefile.in rename : dom/src/threads/test/WorkerTest.jsm => dom/workers/test/WorkerTest.jsm rename : dom/src/threads/test/WorkerTest_badworker.js => dom/workers/test/WorkerTest_badworker.js rename : dom/src/threads/test/WorkerTest_subworker.js => dom/workers/test/WorkerTest_subworker.js rename : dom/src/threads/test/WorkerTest_worker.js => dom/workers/test/WorkerTest_worker.js rename : dom/src/threads/test/atob_worker.js => dom/workers/test/atob_worker.js rename : dom/src/threads/test/chromeWorker_subworker.js => dom/workers/test/chromeWorker_subworker.js rename : dom/src/threads/test/chromeWorker_worker.js => dom/workers/test/chromeWorker_worker.js rename : dom/src/threads/test/closeOnGC_server.sjs => dom/workers/test/closeOnGC_server.sjs rename : dom/src/threads/test/closeOnGC_worker.js => dom/workers/test/closeOnGC_worker.js rename : dom/src/threads/test/close_worker.js => dom/workers/test/close_worker.js rename : dom/src/threads/test/fibonacci_worker.js => dom/workers/test/fibonacci_worker.js rename : dom/src/threads/test/importScripts_worker.js => dom/workers/test/importScripts_worker.js rename : dom/src/threads/test/importScripts_worker_imported1.js => dom/workers/test/importScripts_worker_imported1.js rename : dom/src/threads/test/importScripts_worker_imported2.js => dom/workers/test/importScripts_worker_imported2.js rename : dom/src/threads/test/importScripts_worker_imported3.js => dom/workers/test/importScripts_worker_imported3.js rename : dom/src/threads/test/importScripts_worker_imported4.js => dom/workers/test/importScripts_worker_imported4.js rename : dom/src/threads/test/json_worker.js => dom/workers/test/json_worker.js rename : dom/src/threads/test/location_worker.js => dom/workers/test/location_worker.js rename : dom/src/threads/test/longThread_worker.js => dom/workers/test/longThread_worker.js rename : dom/src/threads/test/navigator_worker.js => dom/workers/test/navigator_worker.js rename : dom/src/threads/test/newError_worker.js => dom/workers/test/newError_worker.js rename : dom/src/threads/test/recursion_worker.js => dom/workers/test/recursion_worker.js rename : dom/src/threads/test/relativeLoad_import.js => dom/workers/test/relativeLoad_import.js rename : dom/src/threads/test/relativeLoad_sub_import.js => dom/workers/test/relativeLoad_sub_import.js rename : dom/src/threads/test/relativeLoad_sub_worker.js => dom/workers/test/relativeLoad_sub_worker.js rename : dom/src/threads/test/relativeLoad_sub_worker2.js => dom/workers/test/relativeLoad_sub_worker2.js rename : dom/src/threads/test/relativeLoad_worker.js => dom/workers/test/relativeLoad_worker.js rename : dom/src/threads/test/relativeLoad_worker2.js => dom/workers/test/relativeLoad_worker2.js rename : dom/src/threads/test/simpleThread_worker.js => dom/workers/test/simpleThread_worker.js rename : dom/src/threads/test/suspend_iframe.html => dom/workers/test/suspend_iframe.html rename : dom/src/threads/test/suspend_worker.js => dom/workers/test/suspend_worker.js rename : dom/src/threads/test/terminate_worker.js => dom/workers/test/terminate_worker.js rename : dom/src/threads/test/testXHR.txt => dom/workers/test/testXHR.txt rename : dom/src/threads/test/test_404.html => dom/workers/test/test_404.html rename : dom/src/threads/test/test_atob.html => dom/workers/test/test_atob.html rename : dom/src/threads/test/test_chromeWorker.html => dom/workers/test/test_chromeWorker.html rename : dom/src/threads/test/test_chromeWorker.xul => dom/workers/test/test_chromeWorker.xul rename : dom/src/threads/test/test_chromeWorkerJSM.xul => dom/workers/test/test_chromeWorkerJSM.xul rename : dom/src/threads/test/test_close.html => dom/workers/test/test_close.html rename : dom/src/threads/test/test_closeOnGC.html => dom/workers/test/test_closeOnGC.html rename : dom/src/threads/test/test_errorPropagation.html => dom/workers/test/test_errorPropagation.html rename : dom/src/threads/test/test_fibonacci.html => dom/workers/test/test_fibonacci.html rename : dom/src/threads/test/test_importScripts.html => dom/workers/test/test_importScripts.html rename : dom/src/threads/test/test_json.html => dom/workers/test/test_json.html rename : dom/src/threads/test/test_location.html => dom/workers/test/test_location.html rename : dom/src/threads/test/test_longThread.html => dom/workers/test/test_longThread.html rename : dom/src/threads/test/test_navigator.html => dom/workers/test/test_navigator.html rename : dom/src/threads/test/test_newError.html => dom/workers/test/test_newError.html rename : dom/src/threads/test/test_recursion.html => dom/workers/test/test_recursion.html rename : dom/src/threads/test/test_relativeLoad.html => dom/workers/test/test_relativeLoad.html rename : dom/src/threads/test/test_simpleThread.html => dom/workers/test/test_simpleThread.html rename : dom/src/threads/test/test_suspend.html => dom/workers/test/test_suspend.html rename : dom/src/threads/test/test_terminate.html => dom/workers/test/test_terminate.html rename : dom/src/threads/test/test_threadErrors.html => dom/workers/test/test_threadErrors.html rename : dom/src/threads/test/test_threadTimeouts.html => dom/workers/test/test_threadTimeouts.html rename : dom/src/threads/test/test_throwingOnerror.html => dom/workers/test/test_throwingOnerror.html rename : dom/src/threads/test/test_xhr.html => dom/workers/test/test_xhr.html rename : dom/src/threads/test/test_xhrAbort.html => dom/workers/test/test_xhrAbort.html rename : dom/src/threads/test/threadErrors_worker1.js => dom/workers/test/threadErrors_worker1.js rename : dom/src/threads/test/threadErrors_worker2.js => dom/workers/test/threadErrors_worker2.js rename : dom/src/threads/test/threadErrors_worker3.js => dom/workers/test/threadErrors_worker3.js rename : dom/src/threads/test/threadErrors_worker4.js => dom/workers/test/threadErrors_worker4.js rename : dom/src/threads/test/threadTimeouts_worker.js => dom/workers/test/threadTimeouts_worker.js rename : dom/src/threads/test/throwingOnerror_worker.js => dom/workers/test/throwingOnerror_worker.js rename : dom/src/threads/test/xhrAbort_worker.js => dom/workers/test/xhrAbort_worker.js rename : dom/src/threads/test/xhr_worker.js => dom/workers/test/xhr_worker.js
150 lines
4.0 KiB
HTML
150 lines
4.0 KiB
HTML
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for DOM Worker Threads</title>
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none"></div>
|
|
<pre id="test">
|
|
<iframe id="workerFrame" src="suspend_iframe.html" onload="subframeLoaded();">
|
|
</iframe>
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
var iframe;
|
|
var lastCount;
|
|
|
|
var suspended = false;
|
|
var resumed = false;
|
|
var finished = false;
|
|
|
|
var interval;
|
|
var oldMessageCount;
|
|
var waitCount = 0;
|
|
|
|
function setCachePref(enabled) {
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
|
if (enabled) {
|
|
prefBranch.setBoolPref("browser.sessionhistory.cache_subframes", true);
|
|
}
|
|
else {
|
|
try {
|
|
prefBranch.clearUserPref("browser.sessionhistory.cache_subframes");
|
|
} catch (e) { /* Pref didn't exist, meh */ }
|
|
}
|
|
}
|
|
|
|
function finishTest() {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
finished = true;
|
|
setCachePref(false);
|
|
iframe.terminateWorker();
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function waitInterval() {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
is(iframe.location, "about:blank", "Wrong url!");
|
|
is(suspended, true, "Not suspended?");
|
|
is(resumed, false, "Already resumed?!");
|
|
is(lastCount, oldMessageCount, "Received a message while suspended!");
|
|
if (++waitCount == 5) {
|
|
clearInterval(interval);
|
|
resumed = true;
|
|
iframe.history.back();
|
|
}
|
|
}
|
|
|
|
function badOnloadCallback() {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
ok(false, "We don't want suspend_iframe.html to fire a new load event, we want it to come out of the bfcache!");
|
|
finishTest();
|
|
}
|
|
|
|
function suspendCallback() {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
is(iframe.location, "about:blank", "Wrong url!");
|
|
is(suspended, false, "Already suspended?");
|
|
is(resumed, false, "Already resumed?");
|
|
setCachePref(false);
|
|
suspended = true;
|
|
var iframeElement = document.getElementById("workerFrame");
|
|
iframeElement.onload = badOnloadCallback;
|
|
oldMessageCount = lastCount;
|
|
interval = setInterval(waitInterval, 1000);
|
|
}
|
|
|
|
function messageCallback(data) {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
|
|
if (!suspended) {
|
|
ok(lastCount === undefined || lastCount == data - 1,
|
|
"Got good data, lastCount = " + lastCount + ", data = " + data);
|
|
lastCount = data;
|
|
if (lastCount == 25) {
|
|
setCachePref(true);
|
|
iframe.location = "about:blank";
|
|
// We want suspend_iframe.html to go into bfcache, so we need to flush
|
|
// out all pending notifications. Otherwise, if they're flushed too
|
|
// late, they could kick us out of the bfcache again.
|
|
iframe.document.body.offsetTop;
|
|
}
|
|
return;
|
|
}
|
|
|
|
var newLocation =
|
|
window.location.toString().replace("test_suspend.html",
|
|
"suspend_iframe.html");
|
|
is(newLocation.indexOf(iframe.location.toString()), 0, "Wrong url!");
|
|
is(resumed, true, "Got message before resumed!");
|
|
is(lastCount, data - 1, "Missed a message, suspend failed!");
|
|
finishTest();
|
|
}
|
|
|
|
function errorCallback(data) {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
ok(false, "Iframe had an error: '" + data + "'");
|
|
finishTest();
|
|
}
|
|
|
|
function subframeLoaded() {
|
|
if (finished) {
|
|
return;
|
|
}
|
|
var iframeElement = document.getElementById("workerFrame");
|
|
iframeElement.onload = suspendCallback;
|
|
|
|
iframe = iframeElement.contentWindow;
|
|
ok(iframe, "No iframe?!");
|
|
|
|
iframe.startWorker(messageCallback, errorCallback);
|
|
}
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|