Skip to content

Commit

Permalink
test: add test for a vm indexed property
Browse files Browse the repository at this point in the history
Adds a single test for a vm with an indexed property.

PR-URL: #23318
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: John-David Dalton <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
  • Loading branch information
conectado authored and MylesBorins committed Nov 29, 2018
1 parent d08d252 commit 6493e01
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-vm-context-property-forwarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ assert.strictEqual(vm.runInContext('x;', ctx), 3);
vm.runInContext('y = 4;', ctx);
assert.strictEqual(sandbox.y, 4);
assert.strictEqual(ctx.y, 4);

// Test `IndexedPropertyGetterCallback` and `IndexedPropertyDeleterCallback`
const x = { get 1() { return 5; } };
const pd_expected = Object.getOwnPropertyDescriptor(x, 1);
const ctx2 = vm.createContext(x);
const pd_actual = Object.getOwnPropertyDescriptor(ctx2, 1);

assert.deepStrictEqual(pd_actual, pd_expected);
assert.strictEqual(ctx2[1], 5);
delete ctx2[1];
assert.strictEqual(ctx2[1], undefined);

0 comments on commit 6493e01

Please sign in to comment.