mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-09 04:54:33 +00:00
34 lines
696 B
JavaScript
34 lines
696 B
JavaScript
|
function test_workers() {
|
||
|
onmessage = function(e) {
|
||
|
postMessage(e.data, e.ports);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function test_broadcastChannel() {
|
||
|
var bc = new BroadcastChannel('postMessagesTest_inWorkers');
|
||
|
bc.onmessage = function(e) {
|
||
|
postMessage(e.data);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function test_messagePort(port) {
|
||
|
port.onmessage = function(e) {
|
||
|
postMessage(e.data, e.ports);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onmessage = function(e) {
|
||
|
if (e.data == 'workers') {
|
||
|
test_workers();
|
||
|
postMessage('ok');
|
||
|
} else if (e.data == 'broadcastChannel') {
|
||
|
test_broadcastChannel();
|
||
|
postMessage('ok');
|
||
|
} else if (e.data == 'messagePort') {
|
||
|
test_messagePort(e.ports[0]);
|
||
|
postMessage('ok');
|
||
|
} else {
|
||
|
postMessage('ko');
|
||
|
}
|
||
|
}
|