| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js
|
| index 2a06adfaa1cba7eb751627f56cd517b84aa16894..08743cc9857fac4cc32eb0329c8e095b3e4f1ff7 100644
|
| --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js
|
| @@ -1,19 +1,139 @@
|
| -// Avoid polluting the global scope.
|
| +/* Adopted from LayoutTests/webexposed/resources/global-interface-listing.js */
|
| +
|
| +// Run all the code in a local scope.
|
| (function(global_object) {
|
|
|
| - // Save the list of property names of the global object before loading other scripts.
|
| - var global_property_names = Object.getOwnPropertyNames(global_object);
|
| +var globals = [];
|
|
|
| - importScripts('/js-test-resources/global-interface-listing.js');
|
| +// List of builtin JS constructors; Blink is not controlling what properties these
|
| +// objects have, so exercising them in a Blink test doesn't make sense.
|
| +//
|
| +// This list should be kept in sync with the one at LayoutTests/webexposed/resources/global-interface-listing.js
|
| +var js_builtins = new Set([
|
| + 'Array',
|
| + 'ArrayBuffer',
|
| + 'Boolean',
|
| + 'Date',
|
| + 'Error',
|
| + 'EvalError',
|
| + 'Float32Array',
|
| + 'Float64Array',
|
| + 'Function',
|
| + 'Infinity',
|
| + 'Int16Array',
|
| + 'Int32Array',
|
| + 'Int8Array',
|
| + 'Intl',
|
| + 'JSON',
|
| + 'Map',
|
| + 'Math',
|
| + 'NaN',
|
| + 'Number',
|
| + 'Object',
|
| + 'Promise',
|
| + 'Proxy',
|
| + 'RangeError',
|
| + 'ReferenceError',
|
| + 'Reflect',
|
| + 'RegExp',
|
| + 'Set',
|
| + 'String',
|
| + 'Symbol',
|
| + 'SyntaxError',
|
| + 'TypeError',
|
| + 'URIError',
|
| + 'Uint16Array',
|
| + 'Uint32Array',
|
| + 'Uint8Array',
|
| + 'Uint8ClampedArray',
|
| + 'WeakMap',
|
| + 'WeakSet',
|
| + 'WebAssembly',
|
| + 'decodeURI',
|
| + 'decodeURIComponent',
|
| + 'encodeURI',
|
| + 'encodeURIComponent',
|
| + 'escape',
|
| + 'eval',
|
| + 'isFinite',
|
| + 'isNaN',
|
| + 'parseFloat',
|
| + 'parseInt',
|
| + 'undefined',
|
| + 'unescape',
|
| +]);
|
|
|
| - var globals = [];
|
| +function is_web_idl_constructor(property_name) {
|
| + if (js_builtins.has(property_name))
|
| + return false;
|
| + var descriptor = Object.getOwnPropertyDescriptor(this, property_name);
|
| + if (descriptor.value === undefined ||
|
| + descriptor.value.prototype === undefined) {
|
| + return false;
|
| + }
|
| + return descriptor.writable && !descriptor.enumerable &&
|
| + descriptor.configurable;
|
| +}
|
|
|
| - globalInterfaceListing(global_object,
|
| - global_property_names,
|
| - string => globals.push(string));
|
| +function collect_property_info(object, property_name, output) {
|
| + var keywords = ('prototype' in object) ? 'static ' : '';
|
| + var descriptor = Object.getOwnPropertyDescriptor(object, property_name);
|
| + if ('value' in descriptor) {
|
| + var type;
|
| + if (typeof descriptor.value === 'function') {
|
| + type = 'method';
|
| + } else {
|
| + type = 'attribute';
|
| + }
|
| + output.push(' ' + keywords + type + ' ' + property_name);
|
| + } else {
|
| + if (descriptor.get)
|
| + output.push(' ' + keywords + 'getter ' + property_name);
|
| + if (descriptor.set)
|
| + output.push(' ' + keywords + 'setter ' + property_name);
|
| + }
|
| +}
|
|
|
| - self.addEventListener('message', function(event) {
|
| - event.ports[0].postMessage({ result: globals });
|
| +var interface_names = Object.getOwnPropertyNames(global_object).filter(is_web_idl_constructor);
|
| +interface_names.sort();
|
| +interface_names.forEach(function(interface_name) {
|
| + var inherits_from = this[interface_name].__proto__.name;
|
| + if (inherits_from)
|
| + globals.push('interface ' + interface_name + ' : ' + inherits_from);
|
| + else
|
| + globals.push('interface ' + interface_name);
|
| + // List static properties then prototype properties.
|
| + [this[interface_name], this[interface_name].prototype].forEach(function(object) {
|
| + if ('prototype' in object) {
|
| + // Skip properties that aren't static (e.g. consts), or are inherited.
|
| + var proto_properties = new Set(Object.keys(object.prototype).concat(
|
| + Object.keys(object.__proto__)));
|
| + var property_names = Object.keys(object).filter(function(name) {
|
| + return !proto_properties.has(name);
|
| + });
|
| + } else {
|
| + var property_names = Object.getOwnPropertyNames(object);
|
| + }
|
| + var property_strings = [];
|
| + property_names.forEach(function(property_name) {
|
| + collect_property_info(object, property_name, property_strings);
|
| + });
|
| + globals.push.apply(globals, property_strings.sort());
|
| });
|
| +});
|
|
|
| -})(this);
|
| +globals.push('global object');
|
| +var property_strings = [];
|
| +var member_names = Object.getOwnPropertyNames(global_object).filter(function(property_name) {
|
| + return !js_builtins.has(property_name) && !is_web_idl_constructor(property_name);
|
| +});
|
| +member_names.forEach(function(property_name) {
|
| + collect_property_info(global_object, property_name, property_strings);
|
| +});
|
| +globals.push.apply(globals, property_strings.sort());
|
| +
|
| +self.addEventListener('message', function(event) {
|
| + event.ports[0].postMessage({ result: globals });
|
| +});
|
| +
|
| +})(this); // Run all the code in a local scope.
|
|
|