michael@0: // getOwnPropertyDescriptor works with simple data properties. michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = Debugger(g); michael@0: var hits; michael@0: var expected; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: var args = frame.arguments; michael@0: var obj = args[0], id = args[1]; michael@0: var desc = obj.getOwnPropertyDescriptor(id); michael@0: if (expected === undefined) { michael@0: assertEq(desc, undefined); michael@0: } else { michael@0: assertEq(desc instanceof Object, true); michael@0: assertEq(desc.enumerable, expected.enumerable); michael@0: assertEq(desc.configurable, expected.configurable); michael@0: assertEq(desc.hasOwnProperty("value"), true); michael@0: assertEq(desc.value, expected.value); michael@0: assertEq(desc.writable, expected.writable === undefined ? true : expected.writable); michael@0: assertEq("get" in desc, false); michael@0: assertEq("set" in desc, false); michael@0: } michael@0: hits++; michael@0: }; michael@0: michael@0: g.eval("function f(obj, id) { debugger; }"); michael@0: michael@0: function test(obj, id, desc) { michael@0: expected = desc; michael@0: hits = 0; michael@0: g.f(obj, id); michael@0: assertEq(hits, 1); michael@0: } michael@0: michael@0: var obj = g.eval("({a: 1, ' ': undefined, '0': 0})"); michael@0: test(obj, "a", {value: 1, enumerable: true, configurable: true}); michael@0: test(obj, " ", {value: undefined, enumerable: true, configurable: true}); michael@0: test(obj, "b", undefined); michael@0: test(obj, "0", {value: 0, enumerable: true, configurable: true}); michael@0: test(obj, 0, {value: 0, enumerable: true, configurable: true}); michael@0: michael@0: var arr = g.eval("[7,,]"); michael@0: test(arr, 'length', {value: 2, enumerable: false, configurable: false}); michael@0: test(arr, 0, {value: 7, enumerable: true, configurable: true}); michael@0: test(arr, "0", {value: 7, enumerable: true, configurable: true}); michael@0: test(arr, 1, undefined); michael@0: test(arr, "1", undefined); michael@0: test(arr, 2, undefined); michael@0: test(arr, "2", undefined); michael@0: test(arr, "argelfraster", undefined); michael@0: michael@0: var re = g.eval("/erwe/"); michael@0: test(re, 'lastIndex', {value: 0, enumerable: false, configurable: false}); michael@0: michael@0: // String objects have a well-behaved resolve hook. michael@0: var str = g.eval("new String('hello world')"); michael@0: test(str, 'length', {value: 11, enumerable: false, configurable: false, writable: false}); michael@0: test(str, 0, {value: 'h', enumerable: true, configurable: false, writable: false}); michael@0: test(str, "0", {value: 'h', enumerable: true, configurable: false, writable: false});