js/src/jit-test/tests/saved-stacks/getters-on-invalid-objects.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial