diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-01.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-01.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-01.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-01.js b/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-01.js new file mode 100644 index 0000000000..a39faeb2f2 --- /dev/null +++ b/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-01.js @@ -0,0 +1,59 @@ +// getOwnPropertyDescriptor works with simple data properties. + +var g = newGlobal({newCompartment: true}); +var dbg = Debugger(g); +var hits; +var expected; +dbg.onDebuggerStatement = function (frame) { + var args = frame.arguments; + var obj = args[0], id = args[1]; + var desc = obj.getOwnPropertyDescriptor(id); + if (expected === undefined) { + assertEq(desc, undefined); + } else { + assertEq(desc instanceof Object, true); + assertEq(desc.enumerable, expected.enumerable); + assertEq(desc.configurable, expected.configurable); + assertEq(desc.hasOwnProperty("value"), true); + assertEq(desc.value, expected.value); + assertEq(desc.writable, expected.writable === undefined ? true : expected.writable); + assertEq("get" in desc, false); + assertEq("set" in desc, false); + } + hits++; +}; + +g.eval("function f(obj, id) { debugger; }"); + +function test(obj, id, desc) { + expected = desc; + hits = 0; + g.f(obj, id); + assertEq(hits, 1); +} + +var obj = g.eval("({a: 1, ' ': undefined, '0': 0})"); +test(obj, "a", {value: 1, enumerable: true, configurable: true}); +test(obj, " ", {value: undefined, enumerable: true, configurable: true}); +test(obj, "b", undefined); +test(obj, "0", {value: 0, enumerable: true, configurable: true}); +test(obj, 0, {value: 0, enumerable: true, configurable: true}); + +var arr = g.eval("[7,,]"); +test(arr, 'length', {value: 2, enumerable: false, configurable: false}); +test(arr, 0, {value: 7, enumerable: true, configurable: true}); +test(arr, "0", {value: 7, enumerable: true, configurable: true}); +test(arr, 1, undefined); +test(arr, "1", undefined); +test(arr, 2, undefined); +test(arr, "2", undefined); +test(arr, "argelfraster", undefined); + +var re = g.eval("/erwe/"); +test(re, 'lastIndex', {value: 0, enumerable: false, configurable: false}); + +// String objects have a well-behaved resolve hook. +var str = g.eval("new String('hello world')"); +test(str, 'length', {value: 11, enumerable: false, configurable: false, writable: false}); +test(str, 0, {value: 'h', enumerable: true, configurable: false, writable: false}); +test(str, "0", {value: 'h', enumerable: true, configurable: false, writable: false}); |