summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Object-name-03.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/debug/Object-name-03.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/jit-test/tests/debug/Object-name-03.js49
1 files changed, 49 insertions, 0 deletions
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");
+}