1 // Track the number of clients for this worker - tests can use this to ensure
2 // that shared workers are actually shared, not distinct.
5 if (!self
.postMessage
) {
6 // This is a shared worker - mimic dedicated worker APIs
7 onconnect = function(event
) {
9 event
.ports
[0].onmessage = function(e
) {
10 self
.postMessage = function(msg
) {
11 event
.ports
[0].postMessage(msg
);
19 onmessage = function(evt
) {
20 if (evt
.data
== "ping")
22 else if (evt
.data
== "auth")
23 importScripts("/auth-basic");
24 else if (evt
.data
== "close")
26 else if (/eval.+/.test(evt
.data
)) {
28 postMessage(eval(evt
.data
.substr(5)));