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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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