Skip to content

Commit 3c4d316

Browse files
conectadojasnell
authored andcommitted
test: add test for a vm indexed property
Adds a single test for a vm with an indexed property. PR-URL: #23318 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 70ba041 commit 3c4d316

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/parallel/test-vm-context-property-forwarding.js

+11
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,14 @@ assert.strictEqual(vm.runInContext('x;', ctx), 3);
3232
vm.runInContext('y = 4;', ctx);
3333
assert.strictEqual(sandbox.y, 4);
3434
assert.strictEqual(ctx.y, 4);
35+
36+
// Test `IndexedPropertyGetterCallback` and `IndexedPropertyDeleterCallback`
37+
const x = { get 1() { return 5; } };
38+
const pd_expected = Object.getOwnPropertyDescriptor(x, 1);
39+
const ctx2 = vm.createContext(x);
40+
const pd_actual = Object.getOwnPropertyDescriptor(ctx2, 1);
41+
42+
assert.deepStrictEqual(pd_actual, pd_expected);
43+
assert.strictEqual(ctx2[1], 5);
44+
delete ctx2[1];
45+
assert.strictEqual(ctx2[1], undefined);

0 commit comments

Comments
 (0)