mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #9688 - KiChjang:worker-terminate, r=jdm
Implement Worker#terminate() (fixes #4427). Adds support for terminating DOM workers. A closing flag was added to WorkerGlobalScope per the spec. Rebased #6652, with some comments addressed. Fixes #4427. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9688) <!-- Reviewable:end -->
This commit is contained in:
commit
c0aa049b0a
13 changed files with 216 additions and 47 deletions
9
tests/html/worker/worker_post_block.js
Normal file
9
tests/html/worker/worker_post_block.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
var prev = Date.now()
|
||||
for (var i=0; true; i++) {
|
||||
|
||||
if (i % 100000000 == 0) {
|
||||
var now = Date.now();
|
||||
postMessage(now - prev);
|
||||
prev = now;
|
||||
}
|
||||
}
|
6
tests/html/worker/worker_post_interval.js
Normal file
6
tests/html/worker/worker_post_interval.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
var prev = Date.now()
|
||||
setInterval(function () {
|
||||
var now = Date.now();
|
||||
postMessage(now - prev);
|
||||
prev = now;
|
||||
}, 500);
|
48
tests/html/worker/worker_terminate.html
Normal file
48
tests/html/worker/worker_terminate.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Worker Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var workerPath = (function () {
|
||||
var workerType;
|
||||
switch (window.location.search.match(/worker=(\w+)/)[1]) {
|
||||
case 'block':
|
||||
workerType = 'block';
|
||||
break;
|
||||
default:
|
||||
workerType = 'interval';
|
||||
break;
|
||||
}
|
||||
|
||||
return './worker_post_' + workerType + '.js';
|
||||
})();
|
||||
|
||||
function startWorker() {
|
||||
window.w = new Worker(workerPath);
|
||||
w.onmessage = function(m) {
|
||||
var p = document.createElement('p');
|
||||
p.innerHTML = JSON.stringify(m.data);
|
||||
document.body.appendChild(p);
|
||||
};
|
||||
|
||||
var ps = document.getElementsByTagName('p');
|
||||
while (ps.length) {
|
||||
document.body.removeChild(ps[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function stopWorker() {
|
||||
if (w) {
|
||||
w.terminate();
|
||||
}
|
||||
|
||||
window.w = null;
|
||||
}
|
||||
</script>
|
||||
<button onclick="startWorker()">Start Worker</button>
|
||||
<button onclick="stopWorker()">Stop Worker</button>
|
||||
</body>
|
||||
</html>
|
|
@ -7458,9 +7458,6 @@
|
|||
[SharedWorkerGlobalScope interface: attribute onconnect]
|
||||
expected: FAIL
|
||||
|
||||
[Worker interface: operation terminate()]
|
||||
expected: FAIL
|
||||
|
||||
[SharedWorker interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[Worker_terminate_event_queue.htm]
|
||||
type: testharness
|
||||
disabled: too much output
|
|
@ -1,5 +0,0 @@
|
|||
[terminate.html]
|
||||
type: testharness
|
||||
[terminate()]
|
||||
expected: FAIL
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
[nested_worker.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[Nested worker]
|
||||
expected: FAIL
|
||||
|
||||
[Checking contents for text file]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue