Debian Codegraph @

js/src/jit-test/tests/proxy/testDirectProxySetArray3.js

raw
1 // Assigning to the length property of a proxy to an array
2 // calls the proxy's defineProperty handler.
3
4 var a = [0, 1, 2, 3];
5 var p = new Proxy(a, {
6 defineProperty(t, id, desc) {
7 hits++;
8
9 // ES6 draft rev 28 (2014 Oct 14) 9.1.9 step 5.e.i.
10 // Since the property already exists, the system only changes
11 // the value. desc is otherwise empty.
12 assertEq(Object.getOwnPropertyNames(desc).join(","), "value");
13 assertEq(desc.value, 2);
14 return true;
15 }
16 });
17 var hits = 0;
18 p.length = 2;
19 assertEq(hits, 1);
20 assertEq(a.length, 4);
21 assertEq(a[2], 2);