summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/typedarray/define-property-oob.js
blob: a4afac3a57ad87549916d6176ab530dc1afa3c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const ta = new Int32Array(1);
const desc = {value: 0, writable: true, enumerable: true, configurable: true};

// Out-of-bounds with an int32 index.
for (let i = 0; i < 1000; ++i) {
  let didThrow = false;
  try {
    Object.defineProperty(ta, 10, desc);
  } catch {
    didThrow = true;
  }
  assertEq(didThrow, true);
}

// Out-of-bounds with a non-int32 index.
for (let i = 0; i < 1000; ++i) {
  let didThrow = false;
  try {
    Object.defineProperty(ta, 12.3, desc);
  } catch {
    didThrow = true;
  }
  assertEq(didThrow, true);
}