tor-browser

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

getters-on-invalid-objects.js (755B)


      1 // Test that you can't call the SavedFrame constructor and can only use
      2 // SavedFrame's getters on SavedFrame instances.
      3 
      4 load(libdir + "asserts.js");
      5 
      6 let proto = Object.getPrototypeOf(saveStack());
      7 
      8 // Can't create new SavedFrame instances by hand.
      9 print("Testing constructor");
     10 assertThrowsInstanceOf(() => {
     11  new proto.constructor();
     12 }, TypeError);
     13 
     14 for (let p of ["source", "line", "column", "functionDisplayName", "parent"]) {
     15  print("Testing getter: " + p);
     16  // The getters shouldn't work on the prototype.
     17  assertThrowsInstanceOf(() => proto[p], TypeError);
     18 
     19  // Nor should they work on random objects.
     20  let o = {};
     21  Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(proto, p));
     22  assertThrowsInstanceOf(() => o[p], TypeError);
     23 }