Debian Codegraph @

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

raw
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 }