diff options
Diffstat (limited to 'js/src/jit-test/tests/errors')
-rw-r--r-- | js/src/jit-test/tests/errors/bug1745907.js | 12 | ||||
-rw-r--r-- | js/src/jit-test/tests/errors/bug1802100.js | 17 | ||||
-rw-r--r-- | js/src/jit-test/tests/errors/bug1810711.js | 11 | ||||
-rw-r--r-- | js/src/jit-test/tests/errors/error-report.js | 51 | ||||
-rw-r--r-- | js/src/jit-test/tests/errors/error-sourceURL-disable.js | 8 | ||||
-rw-r--r-- | js/src/jit-test/tests/errors/overrecursed-double-fault-1.js | 8 |
6 files changed, 107 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/errors/bug1745907.js b/js/src/jit-test/tests/errors/bug1745907.js new file mode 100644 index 0000000000..8e5ed634bf --- /dev/null +++ b/js/src/jit-test/tests/errors/bug1745907.js @@ -0,0 +1,12 @@ +var global; + +function foo() { + var x = BigInt(-1.7e+308); + try { + global = BigInt.asUintN(100000000, x); + } catch {} +} +for (var i = 0; i < 100; i++) { + foo() +} +assertEq(global, undefined) diff --git a/js/src/jit-test/tests/errors/bug1802100.js b/js/src/jit-test/tests/errors/bug1802100.js new file mode 100644 index 0000000000..2b0a1bd1f8 --- /dev/null +++ b/js/src/jit-test/tests/errors/bug1802100.js @@ -0,0 +1,17 @@ +// |jit-test| exitstatus: 3 + +// Throw an object as an exception from the interrupt handler. +setInterruptCallback(function() { + throw {}; +}); + +// Cause a second exception while trying to report the first exception. +Object.prototype[Symbol.toPrimitive] = function () { return {} } + +// Trigger an interrupt in the prologue of a baseline function. +function b() { + var c; + interruptIf(true); + b(); +} +b(); diff --git a/js/src/jit-test/tests/errors/bug1810711.js b/js/src/jit-test/tests/errors/bug1810711.js new file mode 100644 index 0000000000..ef04251a05 --- /dev/null +++ b/js/src/jit-test/tests/errors/bug1810711.js @@ -0,0 +1,11 @@ +var g = newGlobal({newCompartment: true}); + +try { + undef() +} catch (err) { + const handler = { "getPrototypeOf": (x) => () => x }; + const proxy = new g.Proxy(err, handler); + try { + proxy.stack + } catch {} +} diff --git a/js/src/jit-test/tests/errors/error-report.js b/js/src/jit-test/tests/errors/error-report.js new file mode 100644 index 0000000000..978c25f9b8 --- /dev/null +++ b/js/src/jit-test/tests/errors/error-report.js @@ -0,0 +1,51 @@ +{ + // Plain-old Error object + let error = new Error("foobar"); + + let report = createErrorReport(error); + assertEq(report.toStringResult, "Error: foobar"); + assertEq(report.name, "Error"); + assertEq(report.message, "foobar"); +} + +{ + // Error object with overwritten properties + let error = new Error("foobar"); + error.name = "MyError"; + error.message = "here"; + + let report = createErrorReport(error); + assertEq(report.toStringResult, "MyError: here"); + assertEq(report.name, "Error"); + assertEq(report.message, "here"); +} + +{ + // Plain object, which doesn't quack (enough) like an Error + let obj = {name: "foo", message: "bar"}; + + let report = createErrorReport(obj); + assertEq(report.toStringResult, "uncaught exception: [object Object]"); + assertEq(report.name, ""); + assertEq(report.message, "uncaught exception: [object Object]"); +} + +{ + // Duck-typed error object + let obj = {name: "foo", message: "bar", fileName: "test", lineNumber: 0}; + + let report = createErrorReport(obj); + assertEq(report.toStringResult, "foo: bar"); + assertEq(report.name, ""); + assertEq(report.message, "foo: bar"); +} + +{ + // toString failure + let obj = {toString() { throw "haha"; }}; + + let report = createErrorReport(obj); + assertEq(report.toStringResult, "uncaught exception: unknown (can't convert to string)"); + assertEq(report.name, ""); + assertEq(report.message, "uncaught exception: unknown (can't convert to string)"); +} diff --git a/js/src/jit-test/tests/errors/error-sourceURL-disable.js b/js/src/jit-test/tests/errors/error-sourceURL-disable.js new file mode 100644 index 0000000000..d9c17876fa --- /dev/null +++ b/js/src/jit-test/tests/errors/error-sourceURL-disable.js @@ -0,0 +1,8 @@ +// |jit-test| --no-source-pragmas + +const stack = evaluate(` + new Error('test').stack; + //# sourceURL=file.js +`, { fileName: "test.js"}); + +assertEq(stack.split("\n")[0], "@test.js:2:3"); diff --git a/js/src/jit-test/tests/errors/overrecursed-double-fault-1.js b/js/src/jit-test/tests/errors/overrecursed-double-fault-1.js new file mode 100644 index 0000000000..634f97e8db --- /dev/null +++ b/js/src/jit-test/tests/errors/overrecursed-double-fault-1.js @@ -0,0 +1,8 @@ +// |jit-test| allow-overrecursed; allow-unhandlable-oom; skip-if: getBuildConfiguration()['android'] +// Disabled on Android due to harness problems (Bug 1532654) + +enableShellAllocationMetadataBuilder(); +function a() { + a(); +} +new a; |