1 if (self.importScripts) {
2 importScripts('../../resources/js-test.js');
4 if (!self.postMessage) {
5 // Shared worker. Make postMessage send to the newest client, which in
6 // our tests is the only client.
8 // Store messages for sending until we have somewhere to send them.
9 self.postMessage = function(message) {
10 if (typeof self.pendingMessages === "undefined")
11 self.pendingMessages = [];
12 self.pendingMessages.push(message);
14 self.onconnect = function(event) {
15 self.postMessage = function(message) {
16 event.ports[0].postMessage(message);
18 // Offload any stored messages now that someone has connected to us.
19 if (typeof self.pendingMessages === "undefined")
21 while (self.pendingMessages.length)
22 event.ports[0].postMessage(self.pendingMessages.shift());
27 // List of builtin JS constructors; Blink is not controlling what properties these
28 // objects have, so exercising them in a Blink test doesn't make sense.
30 // If new builtins are added, please update this list along with the one in
31 // LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js
32 var jsBuiltins = new Set([
66 function isWebIDLConstructor(propertyName) {
67 if (jsBuiltins.has(propertyName))
69 var descriptor = Object.getOwnPropertyDescriptor(this, propertyName);
70 if (descriptor.value == undefined || descriptor.value.prototype == undefined)
72 return descriptor.writable && !descriptor.enumerable && descriptor.configurable;
75 // FIXME: List interfaces with NoInterfaceObject specified in their IDL file.
77 var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor);
78 interfaceNames.sort();
79 interfaceNames.forEach(function(interfaceName) {
80 debug('interface ' + interfaceName);
81 var propertyStrings = [];
82 var prototype = this[interfaceName].prototype;
83 Object.getOwnPropertyNames(prototype).forEach(function(propertyName) {
84 var descriptor = Object.getOwnPropertyDescriptor(prototype, propertyName);
85 if ('value' in descriptor) {
86 var type = typeof descriptor.value === 'function' ? 'method' : 'attribute';
87 propertyStrings.push(' ' + type + ' ' + propertyName);
90 propertyStrings.push(' getter ' + propertyName);
92 propertyStrings.push(' setter ' + propertyName);
95 propertyStrings.sort().forEach(debug);