1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/saved-stacks/getters-on-invalid-objects.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,21 @@ 1.4 +// Test that you can't call the SavedFrame constructor and can only use 1.5 +// SavedFrame's getters on SavedFrame instances. 1.6 + 1.7 +load(libdir + "asserts.js"); 1.8 + 1.9 +let proto = Object.getPrototypeOf(saveStack()); 1.10 + 1.11 +// Can't create new SavedFrame instances by hand. 1.12 +assertThrowsInstanceOf(() => { 1.13 + new proto.constructor(); 1.14 +}, TypeError); 1.15 + 1.16 +for (let p of ["source", "line", "column", "functionDisplayName", "parent"]) { 1.17 + // The getters shouldn't work on the prototype. 1.18 + assertThrowsInstanceOf(() => proto[p], TypeError); 1.19 + 1.20 + // Nor should they work on random objects. 1.21 + let o = {}; 1.22 + Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(proto, p)); 1.23 + assertThrowsInstanceOf(() => o[p], TypeError); 1.24 +}