| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3482bca commit 9264cae
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1213,11 +1213,31 @@ function isIdentifier(str) { | |||
| 1213 | 1213 | return true; | |
| 1214 | 1214 | } | |
| 1215 | 1215 | ||
| 1216 | + function isNotLegacyObjectPrototypeMethod(str) { | ||
| 1217 | + return isIdentifier(str) && | ||
| 1218 | + str !== '__defineGetter__' && | ||
| 1219 | + str !== '__defineSetter__' && | ||
| 1220 | + str !== '__lookupGetter__' && | ||
| 1221 | + str !== '__lookupSetter__'; | ||
| 1222 | + } | ||
| 1223 | + | ||
| 1216 | 1224 | function filteredOwnPropertyNames(obj) { | |
| 1217 | 1225 | if (!obj) return []; | |
| 1226 | + // `Object.prototype` is the only non-contrived object that fulfills | ||
| 1227 | + // `Object.getPrototypeOf(X) === null && | ||
| 1228 | + // Object.getPrototypeOf(Object.getPrototypeOf(X.constructor)) === X`. | ||
| 1229 | + let isObjectPrototype = false; | ||
| 1230 | + if (ObjectGetPrototypeOf(obj) === null) { | ||
| 1231 | + const ctorDescriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor'); | ||
| 1232 | + if (ctorDescriptor && ctorDescriptor.value) { | ||
| 1233 | + const ctorProto = ObjectGetPrototypeOf(ctorDescriptor.value); | ||
| 1234 | + isObjectPrototype = ctorProto && ObjectGetPrototypeOf(ctorProto) === obj; | ||
| 1235 | + } | ||
| 1236 | + } | ||
| 1218 | 1237 | const filter = ALL_PROPERTIES | SKIP_SYMBOLS; | |
| 1219 | - return ArrayPrototypeFilter(getOwnNonIndexProperties(obj, filter), | ||
| 1220 | - isIdentifier); | ||
| 1238 | + return ArrayPrototypeFilter( | ||
| 1239 | + getOwnNonIndexProperties(obj, filter), | ||
| 1240 | + isObjectPrototype ? isNotLegacyObjectPrototypeMethod : isIdentifier); | ||
| 1221 | 1241 | } | |
| 1222 | 1242 | ||
| 1223 | 1243 | function getGlobalLexicalScopeNames(contextId) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -443,6 +443,18 @@ testMe.complete('obj.', common.mustCall((error, data) => { | |||
| 443 | 443 | assert(data[0].includes('obj.key')); | |
| 444 | 444 | })); | |
| 445 | 445 | ||
| 446 | + // Make sure tab completion does not include __defineSetter__ and friends. | ||
| 447 | + putIn.run(['.clear']); | ||
| 448 | + | ||
| 449 | + putIn.run(['var obj = {};']); | ||
| 450 | + testMe.complete('obj.', common.mustCall(function(error, data) { | ||
| 451 | + assert.strictEqual(data[0].includes('obj.__defineGetter__'), false); | ||
| 452 | + assert.strictEqual(data[0].includes('obj.__defineSetter__'), false); | ||
| 453 | + assert.strictEqual(data[0].includes('obj.__lookupGetter__'), false); | ||
| 454 | + assert.strictEqual(data[0].includes('obj.__lookupSetter__'), false); | ||
| 455 | + assert.strictEqual(data[0].includes('obj.__proto__'), true); | ||
| 456 | + })); | ||
| 457 | + | ||
| 446 | 458 | // Tab completion for files/directories | |
| 447 | 459 | { | |
| 448 | 460 | putIn.run(['.clear']); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments