1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Track the number of clients for this worker - tests can use this to ensure
6 // that shared workers are actually shared, not distinct.
9 if (!self.postMessage) {
10 // This is a shared worker - mimic dedicated worker APIs
11 onconnect = function(event) {
13 event.ports[0].onmessage = function(e) {
14 self.postMessage = function(msg) {
15 event.ports[0].postMessage(msg);
23 onmessage = function(evt) {
24 if (evt.data == "ping")
26 else if (evt.data == "auth")
27 importScripts("/auth-basic");
28 else if (evt.data == "close")
30 else if (/eval.+/.test(evt.data)) {
32 postMessage(eval(evt.data.substr(5)));
36 } else if (/tls-client-auth.+/.test(evt.data)) {
38 importScripts(evt.data.substr(16));