| OLD | NEW |
| 1 // Run all the code in a local scope. | 1 // Run all the code in a local scope. |
| 2 (function(globalObject) { | 2 (function(globalObject) { |
| 3 | 3 |
| 4 // Save the list of property names of the global object before loading other scr
ipts. | 4 // Save the list of property names of the global object before loading other scr
ipts. |
| 5 var propertyNamesInGlobal = globalObject.propertyNamesInGlobal || Object.getOwnP
ropertyNames(globalObject); | 5 var propertyNamesInGlobal = globalObject.propertyNamesInGlobal || Object.getOwnP
ropertyNames(globalObject); |
| 6 | 6 |
| 7 if (self.importScripts) { | 7 if (self.importScripts) { |
| 8 importScripts('../../resources/js-test.js'); | 8 importScripts('../../resources/js-test.js'); |
| 9 | 9 |
| 10 if (!self.postMessage) { | 10 if (!self.postMessage) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 'escape', | 81 'escape', |
| 82 'eval', | 82 'eval', |
| 83 'isFinite', | 83 'isFinite', |
| 84 'isNaN', | 84 'isNaN', |
| 85 'parseFloat', | 85 'parseFloat', |
| 86 'parseInt', | 86 'parseInt', |
| 87 'undefined', | 87 'undefined', |
| 88 'unescape', | 88 'unescape', |
| 89 ]); | 89 ]); |
| 90 | 90 |
| 91 function isWebIDLConstructor(propertyName) { | 91 function isWebIDLConstructor(propertyKey) { |
| 92 if (jsBuiltins.has(propertyName)) | 92 if (jsBuiltins.has(propertyKey)) |
| 93 return false; | 93 return false; |
| 94 var descriptor = Object.getOwnPropertyDescriptor(this, propertyName); | 94 var descriptor = Object.getOwnPropertyDescriptor(this, propertyKey); |
| 95 if (descriptor.value == undefined || descriptor.value.prototype == undefined
) | 95 if (descriptor.value == undefined || descriptor.value.prototype == undefined
) |
| 96 return false; | 96 return false; |
| 97 return descriptor.writable && !descriptor.enumerable && descriptor.configura
ble; | 97 return descriptor.writable && !descriptor.enumerable && descriptor.configura
ble; |
| 98 } | 98 } |
| 99 | 99 |
| 100 function collectPropertyInfo(object, propertyName, output) { | 100 var wellKnownSymbols = new Map([ |
| 101 var keywords = ('prototype' in object) ? 'static ' : ''; | 101 [Symbol.hasInstance, "@@hasInstance"], |
| 102 var descriptor = Object.getOwnPropertyDescriptor(object, propertyName); | 102 [Symbol.isConcatSpreadable, "@@isConcatSpreadable"], |
| 103 [Symbol.iterator, "@@iterator"], |
| 104 [Symbol.match, "@@match"], |
| 105 [Symbol.replace, "@@replace"], |
| 106 [Symbol.search, "@@search"], |
| 107 [Symbol.species, "@@species"], |
| 108 [Symbol.split, "@@split"], |
| 109 [Symbol.toPrimitive, "@@toPrimitive"], |
| 110 [Symbol.toStringTag, "@@toStringTag"], |
| 111 [Symbol.unscopables, "@@unscopables"] |
| 112 ]); |
| 113 |
| 114 function collectPropertyInfo(object, propertyKey, output) { |
| 115 var propertyString = wellKnownSymbols.get(propertyKey) || propertyKey.toStri
ng(); |
| 116 var keywords = Object.prototype.hasOwnProperty.call(object, 'prototype') ? '
static ' : ''; |
| 117 var descriptor = Object.getOwnPropertyDescriptor(object, propertyKey); |
| 103 if ('value' in descriptor) { | 118 if ('value' in descriptor) { |
| 104 var type = typeof descriptor.value === 'function' ? 'method' : 'attribut
e'; | 119 var type = typeof descriptor.value === 'function' ? 'method' : 'attribut
e'; |
| 105 output.push(' ' + keywords + type + ' ' + propertyName); | 120 output.push(' ' + keywords + type + ' ' + propertyString); |
| 106 } else { | 121 } else { |
| 107 if (descriptor.get) | 122 if (descriptor.get) |
| 108 output.push(' ' + keywords + 'getter ' + propertyName); | 123 output.push(' ' + keywords + 'getter ' + propertyString); |
| 109 if (descriptor.set) | 124 if (descriptor.set) |
| 110 output.push(' ' + keywords + 'setter ' + propertyName); | 125 output.push(' ' + keywords + 'setter ' + propertyString); |
| 111 } | 126 } |
| 112 } | 127 } |
| 113 | 128 |
| 129 function ownEnumerableSymbols(object) { |
| 130 return Object.getOwnPropertySymbols(object). |
| 131 filter(function(name) { |
| 132 return Object.getOwnPropertyDescriptor(object, name).enumerable; |
| 133 }); |
| 134 } |
| 135 |
| 136 function collectPropertyKeys(object) { |
| 137 if (Object.prototype.hasOwnProperty.call(object, 'prototype')) { |
| 138 // Skip properties that aren't static (e.g. consts), or are inherited. |
| 139 // TODO(caitp): Don't exclude non-enumerable properties |
| 140 var protoProperties = new Set(Object.keys(object.prototype).concat( |
| 141 Object.keys(object.__proto__), |
| 142 ownEnumerableSymbols(object.prototype), |
| 143 ownEnumerableSymbols(object.__proto__))); |
| 144 return propertyKeys = Object.keys(object). |
| 145 concat(ownEnumerableSymbols(object)). |
| 146 filter(function(name) { |
| 147 // TODO(johnme): Stop filtering out 'toString' once |
| 148 // https://crbug.com/547773 is fixed. |
| 149 return !protoProperties.has(name) && name !== 'toString'; |
| 150 }); |
| 151 } |
| 152 return Object.getOwnPropertyNames(object).concat(Object.getOwnPropertySymbols
(object)); |
| 153 } |
| 154 |
| 114 // FIXME: List interfaces with NoInterfaceObject specified in their IDL file. | 155 // FIXME: List interfaces with NoInterfaceObject specified in their IDL file. |
| 115 debug('[INTERFACES]'); | 156 debug('[INTERFACES]'); |
| 116 var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor
); | 157 var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor
); |
| 117 interfaceNames.sort(); | 158 interfaceNames.sort(); |
| 118 interfaceNames.forEach(function(interfaceName) { | 159 interfaceNames.forEach(function(interfaceName) { |
| 119 var inheritsFrom = this[interfaceName].__proto__.name; | 160 var inheritsFrom = this[interfaceName].__proto__.name; |
| 120 if (inheritsFrom) | 161 if (inheritsFrom) |
| 121 debug('interface ' + interfaceName + ' : ' + inheritsFrom); | 162 debug('interface ' + interfaceName + ' : ' + inheritsFrom); |
| 122 else | 163 else |
| 123 debug('interface ' + interfaceName); | 164 debug('interface ' + interfaceName); |
| 124 // List static properties then prototype properties. | 165 // List static properties then prototype properties. |
| 125 [this[interfaceName], this[interfaceName].prototype].forEach(function(object
) { | 166 [this[interfaceName], this[interfaceName].prototype].forEach(function(object
) { |
| 126 if ('prototype' in object) { | 167 var propertyKeys = collectPropertyKeys(object); |
| 127 // Skip properties that aren't static (e.g. consts), or are inherite
d. | |
| 128 var protoProperties = new Set(Object.keys(object.prototype).concat( | |
| 129 Object.keys(object.__proto__))); | |
| 130 var propertyNames = Object.keys(object).filter(function(name) { | |
| 131 // TODO(johnme): Stop filtering out 'toString' once | |
| 132 // https://crbug.com/547773 is fixed. | |
| 133 return !protoProperties.has(name) && name !== 'toString'; | |
| 134 }); | |
| 135 } else { | |
| 136 var propertyNames = Object.getOwnPropertyNames(object); | |
| 137 } | |
| 138 var propertyStrings = []; | 168 var propertyStrings = []; |
| 139 propertyNames.forEach(function(propertyName) { | 169 propertyKeys.forEach(function(propertyKey) { |
| 140 collectPropertyInfo(object, propertyName, propertyStrings); | 170 collectPropertyInfo(object, propertyKey, propertyStrings); |
| 141 }); | 171 }); |
| 142 propertyStrings.sort().forEach(debug); | 172 propertyStrings.sort().forEach(debug); |
| 143 }); | 173 }); |
| 144 }); | 174 }); |
| 145 | 175 |
| 146 debug('[GLOBAL OBJECT]'); | 176 debug('[GLOBAL OBJECT]'); |
| 147 var propertyStrings = []; | 177 var propertyStrings = []; |
| 148 var memberNames = propertyNamesInGlobal.filter(function(propertyName) { | 178 var memberNames = propertyNamesInGlobal.filter(function(propertyKey) { |
| 149 return !jsBuiltins.has(propertyName) && !isWebIDLConstructor(propertyName); | 179 return !jsBuiltins.has(propertyKey) && !isWebIDLConstructor(propertyKey); |
| 150 }); | 180 }); |
| 151 memberNames.forEach(function(propertyName) { | 181 memberNames.forEach(function(propertyKey) { |
| 152 collectPropertyInfo(globalObject, propertyName, propertyStrings); | 182 collectPropertyInfo(globalObject, propertyKey, propertyStrings); |
| 153 }); | 183 }); |
| 154 propertyStrings.sort().forEach(debug); | 184 propertyStrings.sort().forEach(debug); |
| 155 | 185 |
| 156 if (isWorker()) | 186 if (isWorker()) |
| 157 finishJSTest(); | 187 finishJSTest(); |
| 158 | 188 |
| 159 })(this); // Run all the code in a local scope. | 189 })(this); // Run all the code in a local scope. |
| OLD | NEW |