From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/debug/Object-name-03.js | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 js/src/jit-test/tests/debug/Object-name-03.js (limited to 'js/src/jit-test/tests/debug/Object-name-03.js') diff --git a/js/src/jit-test/tests/debug/Object-name-03.js b/js/src/jit-test/tests/debug/Object-name-03.js new file mode 100644 index 0000000000..3ce08918c5 --- /dev/null +++ b/js/src/jit-test/tests/debug/Object-name-03.js @@ -0,0 +1,49 @@ +// Test `name` and `displayName` getters on a bound function Debugger.Object. + +var g = newGlobal({newCompartment: true}); +var hits = 0; +var dbg = new Debugger(g); + +var nameResults = []; +var displayNameResults = []; +dbg.onDebuggerStatement = function (frame) { + nameResults.push(frame.arguments[0].name); + displayNameResults.push(frame.arguments[0].displayName); +}; +g.eval(` +function f(val) { debugger; } + +function foo() {}; +let bound1 = foo.bind(null); +let bound2 = bound1.bind(); +let bound3 = bound2.bind(); +f(bound1); +f(bound2); +f(bound3); + +// Change bound1.name to "bar". +Object.defineProperty(bound1, "name", {value: "bar", configurable: true, writable: true}); +f(bound1); + +// Change bound1.name to 123. Not a string so now "bound" will be returned. +bound1.name = 123; +f(bound1); + +// Delete bound2.name so now "bound" will be used. +delete bound2.name; +f(bound2); + +// Binding a native function. +f(print.bind().bind().bind()); +`) + +for (let res of [nameResults, displayNameResults]) { + assertEq(res.length, 7); + assertEq(res[0], "bound foo"); + assertEq(res[1], "bound bound foo"); + assertEq(res[2], "bound bound bound foo"); + assertEq(res[3], "bar"); + assertEq(res[4], "bound"); + assertEq(res[5], "bound"); + assertEq(res[6], "bound bound bound print"); +} -- cgit v1.2.3