Debian Codegraph @

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

raw
1 // Assigning to a proxy with no set handler calls the defineProperty handler
2 // when an existing own data property already exists on the target.
3
4 var t = {x: 1};
5 var p = new Proxy(t, {
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, 42);
14 return true;
15 }
16 });
17 var hits = 0;
18 p.x = 42;
19 assertEq(hits, 1);
20 assertEq(t.x, 1);