summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js')
-rw-r--r--Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js b/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js
new file mode 100644
index 0000000000..177bb2d675
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js
@@ -0,0 +1,21 @@
+test("infinite recursion", () => {
+ function infiniteRecursion() {
+ infiniteRecursion();
+ }
+
+ try {
+ infiniteRecursion();
+ } catch (e) {
+ expect(e).toBeInstanceOf(Error);
+ expect(e.name).toBe("RuntimeError");
+ expect(e.message).toBe("Call stack size limit exceeded");
+ }
+
+ expect(() => {
+ JSON.stringify({}, () => ({ foo: "bar" }));
+ }).toThrowWithMessage(Error, "Call stack size limit exceeded");
+
+ expect(() => {
+ new Proxy({}, { get: (_, __, p) => p.foo }).foo;
+ }).toThrowWithMessage(Error, "Call stack size limit exceeded");
+});