Debugger-findObjects-classObj-basic.js (1532B)
1 const g = newGlobal({ newCompartment: true }); 2 3 g.eval(` 4 var arr = []; 5 `); 6 7 const dbg = new Debugger(); 8 const gDO = dbg.addDebuggee(g); 9 10 const arrDO = gDO.makeDebuggeeValue(g.arr); 11 12 // The direct ctor/proto should match. 13 const ArrayDO = gDO.makeDebuggeeValue(g.Array); 14 assertEq(dbg.findObjects({ class: ArrayDO }).includes(arrDO), true); 15 const ArrayProtoDO = gDO.makeDebuggeeValue(g.Array.prototype); 16 assertEq(dbg.findObjects({ class: ArrayProtoDO }).includes(arrDO), true); 17 18 // The ctor/proto in the prototype chain should match. 19 const ObjectDO = gDO.makeDebuggeeValue(g.Object); 20 assertEq(dbg.findObjects({ class: ObjectDO }).includes(arrDO), true); 21 const ObjectProtoDO = gDO.makeDebuggeeValue(g.Object.prototype); 22 assertEq(dbg.findObjects({ class: ObjectProtoDO }).includes(arrDO), true); 23 24 // Unrelated ctor/proto shouldn't match. 25 const RegExpDO = gDO.makeDebuggeeValue(g.RegExp); 26 assertEq(dbg.findObjects({ class: RegExpDO }).includes(arrDO), false); 27 const RegExpProtoDO = gDO.makeDebuggeeValue(g.RegExp.prototype); 28 assertEq(dbg.findObjects({ class: RegExpProtoDO }).includes(arrDO), false); 29 30 // The object itself shouldn't match. 31 assertEq(dbg.findObjects({ class: arrDO }).includes(arrDO), false); 32 33 // The ctor/proto from different global shouldn't match. 34 const OtherArrayDO = gDO.makeDebuggeeValue(Array); 35 assertEq(dbg.findObjects({ class: OtherArrayDO }).includes(arrDO), false); 36 const OtherArrayProtoDO = gDO.makeDebuggeeValue(Array.prototype); 37 assertEq(dbg.findObjects({ class: OtherArrayProtoDO }).includes(arrDO), false);