tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

error-cause-not-copied-when-redefined-to-accessor.js (819B)


      1 // Test that the ErrorCopier doesn't copy the optional "cause" property when it
      2 // has been redefined to an accessor property.
      3 
      4 var g = newGlobal({newCompartment: true});
      5 
      6 var obj = g.eval(`
      7 new Proxy({}, {
      8  isExtensible() {
      9    // Create an error object with an initial cause.
     10    let error = new Error("message", {cause: "initial cause"});
     11 
     12    // Ensure the "cause" property is correctly installed.
     13    assertEq(error.cause, "initial cause");
     14 
     15    // Redefine the "cause" data property to an accessor property.
     16    Object.defineProperty(error, "cause", { get() {} });
     17 
     18    // Throw the error.
     19    throw error;
     20  }
     21 });
     22 `);
     23 
     24 var dbg = new Debugger();
     25 var gw = dbg.addDebuggee(g);
     26 var objw = gw.makeDebuggeeValue(obj);
     27 
     28 var err;
     29 try {
     30  objw.isExtensible();
     31 } catch (e) {
     32  err = e;
     33 }
     34 
     35 assertEq(err.cause, undefined);