summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/debug')
-rw-r--r--js/src/jit-test/tests/debug/Debugger-dead-global.js26
-rw-r--r--js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js57
-rw-r--r--js/src/jit-test/tests/debug/bug1891662.js24
-rw-r--r--js/src/jit-test/tests/debug/bug1893554.js31
4 files changed, 138 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Debugger-dead-global.js b/js/src/jit-test/tests/debug/Debugger-dead-global.js
new file mode 100644
index 0000000000..abcb370be0
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Debugger-dead-global.js
@@ -0,0 +1,26 @@
+var g1 = newGlobal({newCompartment: true});
+
+const dbg = new Debugger();
+
+function assertThrowsDeadWrapper(f) {
+ let caught = false;
+ try {
+ f();
+ } catch (e) {
+ assertEq(e.message, "can't access dead object");
+ caught = true;
+ }
+ assertEq(caught, true);
+}
+
+nukeAllCCWs();
+
+// Debugger methods should throw explicit error for dead global object.
+assertThrowsDeadWrapper(() => dbg.addDebuggee(g1));
+assertThrowsDeadWrapper(() => dbg.removeDebuggee(g1));
+assertThrowsDeadWrapper(() => dbg.findScripts({global: g1}));
+assertThrowsDeadWrapper(() => dbg.makeGlobalObjectReference(g1));
+assertThrowsDeadWrapper(() => dbg.enableAsyncStack(g1));
+assertThrowsDeadWrapper(() => dbg.disableAsyncStack(g1));
+assertThrowsDeadWrapper(() => dbg.enableUnlimitedStacksCapturing(g1));
+assertThrowsDeadWrapper(() => dbg.disableUnlimitedStacksCapturing(g1));
diff --git a/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js b/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js
new file mode 100644
index 0000000000..62d6693d4e
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js
@@ -0,0 +1,57 @@
+// Test shouldAvoidSideEffects flag.
+
+const g = newGlobal({newCompartment: true});
+const dbg = Debugger(g);
+const gdbg = dbg.addDebuggee(g);
+
+gdbg.executeInGlobal(`
+var obj, result, reachedNextLine;
+`);
+
+dbg.shouldAvoidSideEffects = false;
+assertEq(dbg.shouldAvoidSideEffects, false);
+
+let result = gdbg.executeInGlobal(`
+result = undefined;
+reachedNextLine = false;
+
+obj = createSideEffectfulResolveObject();
+result = obj.test;
+reachedNextLine = true;
+"finished";
+`);
+assertEq(g.result, 42);
+assertEq(g.reachedNextLine, true);
+assertEq(result.return, "finished");
+
+dbg.shouldAvoidSideEffects = true;
+assertEq(dbg.shouldAvoidSideEffects, true);
+
+result = gdbg.executeInGlobal(`
+result = undefined;
+reachedNextLine = false;
+
+obj = createSideEffectfulResolveObject();
+result = obj.test;
+reachedNextLine = true;
+"finished";
+`);
+assertEq(g.result, undefined);
+assertEq(g.reachedNextLine, false);
+assertEq(result, null);
+
+// Resolve after abort.
+dbg.shouldAvoidSideEffects = false;
+assertEq(dbg.shouldAvoidSideEffects, false);
+
+result = gdbg.executeInGlobal(`
+result = undefined;
+reachedNextLine = false;
+
+result = obj.test;
+reachedNextLine = true;
+"finished";
+`);
+assertEq(g.result, 42);
+assertEq(g.reachedNextLine, true);
+assertEq(result.return, "finished");
diff --git a/js/src/jit-test/tests/debug/bug1891662.js b/js/src/jit-test/tests/debug/bug1891662.js
new file mode 100644
index 0000000000..0a68f33d0c
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1891662.js
@@ -0,0 +1,24 @@
+// |jit-test| --baseline-eager
+
+var src = "";
+for (var i = 0; i < 100; i++) {
+ src += "function foo" + i + "() { foo" + (i+1) + "(); }"
+}
+eval(src);
+
+function foo100() {
+ let g = newGlobal({newCompartment: true});
+ let d = new g.Debugger(this);
+
+ // When we set this debugger hook, we will trigger 100
+ // baseline recompilations. We want an OOM to occur
+ // during one of those recompilations. We allocate
+ // about 400 times before starting recompilation, and
+ // about 30000 times total. This number is picked to
+ // leave a healthy margin on either side.
+ oomAtAllocation(5000);
+ d.onEnterFrame = () => {}
+}
+try {
+ foo0();
+} catch {}
diff --git a/js/src/jit-test/tests/debug/bug1893554.js b/js/src/jit-test/tests/debug/bug1893554.js
new file mode 100644
index 0000000000..dfe76c8b41
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1893554.js
@@ -0,0 +1,31 @@
+let g = newGlobal({ newCompartment: true });
+g.parent = this;
+g.eval(
+ "(" +
+ function () {
+ Debugger(parent).onExceptionUnwind = function (frame) {
+ frame.older;
+ };
+ } +
+ ")()"
+);
+function f(x, y) {
+ try {
+ Object.setPrototypeOf(
+ y,
+ new Proxy(Object.getPrototypeOf(y), {
+ get(a, b, c) {
+ return undefined;
+ },
+ })
+ );
+ } catch (e) {}
+}
+function h(x, y) {
+ f(x, y);
+}
+oomTest(function () {
+ h("", undefined);
+ h("", "");
+ "".replaceAll();
+});