Index: LayoutTests/webexposed/resources/global-context-constructors-listing.js |
diff --git a/LayoutTests/webexposed/resources/global-context-constructors-listing.js b/LayoutTests/webexposed/resources/global-context-constructors-listing.js |
index 193fa9698d7393702b8f6878d64d523985375c7e..c3ce16d8052bd320c0758036bbc25837e7bce0ce 100644 |
--- a/LayoutTests/webexposed/resources/global-context-constructors-listing.js |
+++ b/LayoutTests/webexposed/resources/global-context-constructors-listing.js |
@@ -1,6 +1,29 @@ |
-if (this.importScripts) |
+if (self.importScripts) { |
importScripts('../../fast/js/resources/js-test-pre.js'); |
+ if (!self.postMessage) { |
+ // Shared worker. Make postMessage send to the newest client, which in |
+ // our tests is the only client. |
+ |
+ // Store messages for sending until we have somewhere to send them. |
+ self.postMessage = function(message) { |
+ if (typeof self.pendingMessages === "undefined") |
+ self.pendingMessages = []; |
+ self.pendingMessages.push(message); |
+ }; |
+ self.onconnect = function(event) { |
+ self.postMessage = function(message) { |
+ event.ports[0].postMessage(message); |
+ }; |
+ // Offload any stored messages now that someone has connected to us. |
+ if (typeof self.pendingMessages === "undefined") |
+ return; |
+ while (self.pendingMessages.length) |
+ event.ports[0].postMessage(self.pendingMessages.shift()); |
+ }; |
+ } |
+} |
+ |
function isConstructor(propertyName) { |
var descriptor = Object.getOwnPropertyDescriptor(this, propertyName); |
if (descriptor.value == undefined || descriptor.value.prototype == undefined) |