| OLD | NEW |
| 1 // Track the number of clients for this worker - tests can use this to ensure | 1 // Track the number of clients for this worker - tests can use this to ensure |
| 2 // that shared workers are actually shared, not distinct. | 2 // that shared workers are actually shared, not distinct. |
| 3 var num_clients = 0; | 3 var num_clients = 0; |
| 4 | 4 |
| 5 if (!self.postMessage) { | 5 if (!self.postMessage) { |
| 6 // This is a shared worker - mimic dedicated worker APIs | 6 // This is a shared worker - mimic dedicated worker APIs |
| 7 onconnect = function(event) { | 7 onconnect = function(event) { |
| 8 num_clients++; | 8 num_clients++; |
| 9 event.ports[0].onmessage = function(e) { | 9 event.ports[0].onmessage = function(e) { |
| 10 self.postMessage = function(msg) { | 10 self.postMessage = function(msg) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 else if (evt.data == "auth") | 22 else if (evt.data == "auth") |
| 23 importScripts("/auth-basic"); | 23 importScripts("/auth-basic"); |
| 24 else if (evt.data == "close") | 24 else if (evt.data == "close") |
| 25 close(); | 25 close(); |
| 26 else if (/eval.+/.test(evt.data)) { | 26 else if (/eval.+/.test(evt.data)) { |
| 27 try { | 27 try { |
| 28 postMessage(eval(evt.data.substr(5))); | 28 postMessage(eval(evt.data.substr(5))); |
| 29 } catch (ex) { | 29 } catch (ex) { |
| 30 postMessage(ex); | 30 postMessage(ex); |
| 31 } | 31 } |
| 32 } else if (/tls-client-auth.+/.test(evt.data)) { |
| 33 try { |
| 34 importScripts(evt.data.substr(16)); |
| 35 } catch (ex) { |
| 36 } |
| 37 postMessage("done"); |
| 32 } | 38 } |
| 33 } | 39 } |
| OLD | NEW |