summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Proxy/proxy-for-in.js
blob: 4332bfbbaddc267dd1c25e9112988a45b3b2f464 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
"use strict";

let steps = [];

const object = {
    __proto__: {
        "xyz": 42
    }
};
const proxy = new Proxy(object, {
    ownKeys(target) {
        steps.push("ownKeys")
        return ["a", "b"];
    },

    getOwnPropertyDescriptor(target, property) {
        steps.push("getOwn-" + property);
        return {
            value: undefined,
            configurable: true,
            writable: true,
            enumerable: (property === "a")
        };
    }
});

let iterated = [];
for (let x in proxy)
    iterated.push(x);

assertEq(iterated.toString(), "a,xyz");
assertEq(steps.toString(), "ownKeys,getOwn-a,getOwn-b");

if (typeof reportCompare === "function")
    reportCompare(true, true);