tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Object-getOwnPropertyNames-01.js (1036B)


      1 // Basic getOwnPropertyNames tests.
      2 
      3 var g = newGlobal({newCompartment: true});
      4 var dbg = Debugger();
      5 var gobj = dbg.addDebuggee(g);
      6 
      7 function test(code) {
      8    code = "(" + code + ");";
      9    var expected = Object.getOwnPropertyNames(eval(code));
     10    g.eval("obj = " + code);
     11    var actual = gobj.getOwnPropertyDescriptor("obj").value.getOwnPropertyNames();
     12    assertEq(JSON.stringify(actual.sort()), JSON.stringify(expected.sort()));
     13 }
     14 
     15 test("{}");
     16 test("{a: 0, b: 1}");
     17 test("{'name with space': 0}");
     18 test("{get x() {}, set y(v) {}}");
     19 test("{get x() { throw 'fit'; }}");
     20 test("Object.create({a: 1})");
     21 test("Object.create({get a() {}, set a(v) {}})");
     22 test("(function () { var x = {a: 0, b: 1}; delete a; return x; })()");
     23 test("Object.create(null, {x: {value: 0}})");
     24 test("[]");
     25 test("[0, 1, 2]");
     26 test("[,,,,,]");
     27 test("/a*a/");
     28 test("function () {}");
     29 test("(function () {\n" +
     30     "    var x = {};\n" +
     31     "    x[Symbol()] = 1; x[Symbol.for('moon')] = 2; x[Symbol.iterator] = 3;\n" +
     32     "    return x;\n" + 
     33     "})()");