Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js |
| diff --git a/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js b/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js |
| index aab287c589c31f9a312d97e7a81348ce125bf5f8..e23dd4e22383c8c476ae68da545bc25a5cf1d9b5 100644 |
| --- a/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js |
| +++ b/third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js |
| @@ -97,20 +97,60 @@ function isWebIDLConstructor(propertyName) { |
| return descriptor.writable && !descriptor.enumerable && descriptor.configurable; |
| } |
| +var wellKnownSymbols = new Map([ |
| + [Symbol.hasInstance, "@@hasInstance"], |
| + [Symbol.isConcatSpreadable, "@@isConcatSpreadable"], |
| + [Symbol.iterator, "@@iterator"], |
| + [Symbol.match, "@@match"], |
| + [Symbol.replace, "@@replace"], |
| + [Symbol.search, "@@search"], |
| + [Symbol.species, "@@species"], |
| + [Symbol.split, "@@split"], |
| + [Symbol.toPrimitive, "@@toPrimitive"], |
| + [Symbol.toStringTag, "@@toStringTag"], |
| + [Symbol.unscopables, "@@unscopables"] |
| +]); |
| + |
| function collectPropertyInfo(object, propertyName, output) { |
|
jsbell
2016/03/11 20:23:46
Can we s/propertyName/propertyKey/ while we're her
caitp (gmail)
2016/03/11 20:29:01
Acknowledged.
|
| - var keywords = ('prototype' in object) ? 'static ' : ''; |
| + var propertyString = wellKnownSymbols.get(propertyName) || propertyName.toString(); |
|
jsbell
2016/03/11 20:23:46
Is this map necessary? Seems annoying to maintain.
caitp (gmail)
2016/03/11 20:29:01
hmm, it doesn't seem that hard --- I just wanted t
|
| + var keywords = Object.prototype.hasOwnProperty.call(object, 'prototype') ? 'static ' : ''; |
| var descriptor = Object.getOwnPropertyDescriptor(object, propertyName); |
| if ('value' in descriptor) { |
| var type = typeof descriptor.value === 'function' ? 'method' : 'attribute'; |
| - output.push(' ' + keywords + type + ' ' + propertyName); |
| + output.push(' ' + keywords + type + ' ' + propertyString); |
| } else { |
| if (descriptor.get) |
| - output.push(' ' + keywords + 'getter ' + propertyName); |
| + output.push(' ' + keywords + 'getter ' + propertyString); |
| if (descriptor.set) |
| - output.push(' ' + keywords + 'setter ' + propertyName); |
| + output.push(' ' + keywords + 'setter ' + propertyString); |
| } |
| } |
| +function ownEnumerableSymbols(object) { |
| + return Object.getOwnPropertySymbols(object). |
| + filter(function(name) { |
| + return Object.getOwnPropertyDescriptor(name).enumerable; |
| + }); |
| +} |
| + |
| +function collectPropertyNames(object) { |
| + if (Object.prototype.hasOwnProperty.call(object, 'prototype')) { |
| + // Skip properties that aren't static (e.g. consts), or are inherited. |
| + var protoProperties = new Set(Object.keys(object.prototype).concat( |
|
caitp (gmail)
2016/03/11 20:10:49
I'm not sure if it's intentional to use Object.key
jsbell
2016/03/11 20:23:46
I'm okay with leaving this as-is for now, maybe wi
|
| + Object.keys(object.__proto__), |
| + ownEnumerableSymbols(object.prototype), |
| + ownEnumerableSymbols(object.__proto__))); |
| + return propertyNames = Object.keys(object). |
| + concat(ownEnumerableSymbols(object)). |
| + filter(function(name) { |
| + // TODO(johnme): Stop filtering out 'toString' once |
| + // https://crbug.com/547773 is fixed. |
| + return !protoProperties.has(name) && name !== 'toString'; |
| + }); |
| + } |
| + return Object.getOwnPropertyNames(object).concat(Object.getOwnPropertySymbols(object)); |
| +} |
| + |
| // FIXME: List interfaces with NoInterfaceObject specified in their IDL file. |
| debug('[INTERFACES]'); |
| var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor); |
| @@ -123,18 +163,7 @@ interfaceNames.forEach(function(interfaceName) { |
| debug('interface ' + interfaceName); |
| // List static properties then prototype properties. |
| [this[interfaceName], this[interfaceName].prototype].forEach(function(object) { |
| - if ('prototype' in object) { |
| - // Skip properties that aren't static (e.g. consts), or are inherited. |
| - var protoProperties = new Set(Object.keys(object.prototype).concat( |
| - Object.keys(object.__proto__))); |
| - var propertyNames = Object.keys(object).filter(function(name) { |
| - // TODO(johnme): Stop filtering out 'toString' once |
| - // https://crbug.com/547773 is fixed. |
| - return !protoProperties.has(name) && name !== 'toString'; |
| - }); |
| - } else { |
| - var propertyNames = Object.getOwnPropertyNames(object); |
| - } |
| + var propertyNames = collectPropertyNames(object); |
| var propertyStrings = []; |
| propertyNames.forEach(function(propertyName) { |
| collectPropertyInfo(object, propertyName, propertyStrings); |