summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/Array-of-length-setter-2.js
blob: 4dc95549efe3ece0c5cd967d38fcdd641d501a99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Array.of does a strict assignment to the new object's .length.
// The assignment is strict even if the code we're calling from is not strict.

load(libdir + "asserts.js");

function Empty() {}
Empty.of = Array.of;
Object.defineProperty(Empty.prototype, "length", {get: () => 0});

var nothing = new Empty;
nothing.length = 2;  // no exception; this is not a strict mode assignment

assertThrowsInstanceOf(() => Empty.of(), TypeError);