| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5856c83 commit 363091d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const vm = require('vm'); | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + | ||
| 7 | + const sym1 = Symbol('1'); | ||
| 8 | + const sym2 = Symbol('2'); | ||
| 9 | + const sandbox = { | ||
| 10 | + a: true, | ||
| 11 | + [sym1]: true | ||
| 12 | + }; | ||
| 13 | + Object.defineProperty(sandbox, 'b', { value: true }); | ||
| 14 | + Object.defineProperty(sandbox, sym2, { value: true }); | ||
| 15 | + | ||
| 16 | + const ctx = vm.createContext(sandbox); | ||
| 17 | + | ||
| 18 | + // Sanity check | ||
| 19 | + // Please uncomment these when the test is no longer broken | ||
| 20 | + // assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); | ||
| 21 | + // assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); | ||
| 22 | + // assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); | ||
| 23 | + | ||
| 24 | + const nativeKeys = vm.runInNewContext('Reflect.ownKeys(this);'); | ||
| 25 | + const ownKeys = vm.runInContext('Reflect.ownKeys(this);', ctx); | ||
| 26 | + const restKeys = ownKeys.filter((key) => !nativeKeys.includes(key)); | ||
| 27 | + // this should not fail | ||
| 28 | + assert.deepStrictEqual(Array.from(restKeys), ['a', 'b', sym1, sym2]); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const vm = require('vm'); | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + | ||
| 7 | + const sym1 = Symbol('1'); | ||
| 8 | + const sym2 = Symbol('2'); | ||
| 9 | + const sandbox = { | ||
| 10 | + a: true, | ||
| 11 | + [sym1]: true | ||
| 12 | + }; | ||
| 13 | + Object.defineProperty(sandbox, 'b', { value: true }); | ||
| 14 | + Object.defineProperty(sandbox, sym2, { value: true }); | ||
| 15 | + | ||
| 16 | + const ctx = vm.createContext(sandbox); | ||
| 17 | + | ||
| 18 | + // Sanity check | ||
| 19 | + // Please uncomment these when the test is no longer broken | ||
| 20 | + // assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); | ||
| 21 | + // assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); | ||
| 22 | + // assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); | ||
| 23 | + | ||
| 24 | + const nativeNames = vm.runInNewContext('Object.getOwnPropertyNames(this);'); | ||
| 25 | + const ownNames = vm.runInContext('Object.getOwnPropertyNames(this);', ctx); | ||
| 26 | + const restNames = ownNames.filter((name) => !nativeNames.includes(name)); | ||
| 27 | + // this should not fail | ||
| 28 | + assert.deepStrictEqual(Array.from(restNames), ['a', 'b']); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const vm = require('vm'); | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + | ||
| 7 | + const sym1 = Symbol('1'); | ||
| 8 | + const sym2 = Symbol('2'); | ||
| 9 | + const sandbox = { | ||
| 10 | + a: true, | ||
| 11 | + [sym1]: true | ||
| 12 | + }; | ||
| 13 | + Object.defineProperty(sandbox, 'b', { value: true }); | ||
| 14 | + Object.defineProperty(sandbox, sym2, { value: true }); | ||
| 15 | + | ||
| 16 | + const ctx = vm.createContext(sandbox); | ||
| 17 | + | ||
| 18 | + // Sanity check | ||
| 19 | + // Please uncomment these when the test is no longer broken | ||
| 20 | + // assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); | ||
| 21 | + // assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); | ||
| 22 | + // assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); | ||
| 23 | + | ||
| 24 | + const nativeSym = vm.runInNewContext('Object.getOwnPropertySymbols(this);'); | ||
| 25 | + const ownSym = vm.runInContext('Object.getOwnPropertySymbols(this);', ctx); | ||
| 26 | + const restSym = ownSym.filter((sym) => !nativeSym.includes(sym)); | ||
| 27 | + // this should not fail | ||
| 28 | + assert.deepStrictEqual(Array.from(restSym), [sym1, sym2]); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments