Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: LayoutTests/webexposed/resources/global-context-constructors-listing.js

Issue 17826003: Expose WorkerGlobalScope interface in worker environment (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix bindings tests Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)
« no previous file with comments | « LayoutTests/webexposed/global-constructors-listing-worker-expected.txt ('k') | Source/bindings/derived_sources.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698