summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/error-cause-not-copied-when-redefined-to-accessor.js
blob: a5f089217ea411a6e5c275c3be0132f8f90c48f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Test that the ErrorCopier doesn't copy the optional "cause" property when it
// has been redefined to an accessor property.

var g = newGlobal({newCompartment: true});

var obj = g.eval(`
new Proxy({}, {
  isExtensible() {
    // Create an error object with an initial cause.
    let error = new Error("message", {cause: "initial cause"});

    // Ensure the "cause" property is correctly installed.
    assertEq(error.cause, "initial cause");

    // Redefine the "cause" data property to an accessor property.
    Object.defineProperty(error, "cause", { get() {} });

    // Throw the error.
    throw error;
  }
});
`);

var dbg = new Debugger();
var gw = dbg.addDebuggee(g);
var objw = gw.makeDebuggeeValue(obj);

var err;
try {
  objw.isExtensible();
} catch (e) {
  err = e;
}

assertEq(err.cause, undefined);