tor-browser

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

Debugger-findObjects-classObj-ctor-getter.js (823B)


      1 const g = newGlobal({ newCompartment: true });
      2 
      3 g.eval(`
      4 var c1 = class C1 {
      5 };
      6 
      7 var x1 = {
      8  __proto__: {
      9    constructor: c1,
     10  },
     11 };
     12 var getterCalled = false;
     13 var x2 = {
     14  __proto__: {
     15    get constructor() {
     16      getterCalled = true;
     17      return c1;
     18    },
     19  },
     20 };
     21 `);
     22 
     23 const dbg = new Debugger();
     24 const gDO = dbg.addDebuggee(g);
     25 
     26 const x1DO = gDO.makeDebuggeeValue(g.x1);
     27 const x2DO = gDO.makeDebuggeeValue(g.x2);
     28 
     29 // An object where __proto__.constructor matches the query should match.
     30 const c1DO = gDO.makeDebuggeeValue(g.c1);
     31 assertEq(dbg.findObjects({ class: c1DO }).includes(x1DO), true);
     32 
     33 // An object where __proto__.constructor is an accessor shouldn't match.
     34 assertEq(dbg.findObjects({ class: c1DO }).includes(x2DO), false);
     35 
     36 // The constructor getter shouldn't be called.
     37 assertEq(g.getterCalled, false);