summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/dataview/create-out-of-bounds-ccw.js
blob: 11ca180064a6c43e97743078235e53b0ddb5a611 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize

// RangeError is from the correct global when resizable ArrayBuffer gets out-of-bounds.

let g = newGlobal();

let rab = new g.ArrayBuffer(10, {maxByteLength: 10});

let newTarget = Object.defineProperty(function(){}.bind(), "prototype", {
  get() {
    rab.resize(0);
    return DataView.prototype;
  }
});

let err;
try {
  Reflect.construct(DataView, [rab, 10], newTarget);
} catch (e) {
  err = e;
}

assertEq(err instanceof RangeError, true);