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