summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js
blob: 3b91df85264c862b6c372b9c8d5934d94e74e305 (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
25
26
27
// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-arraybuffer.prototype.bytelength
description: Throws a TypeError exception when `this` is a SharedArrayBuffer
features: [align-detached-buffer-semantics-with-web-reality, SharedArrayBuffer]
---*/

var byteLength = Object.getOwnPropertyDescriptor(
  ArrayBuffer.prototype, "byteLength"
);

var getter = byteLength.get;
var sab = new SharedArrayBuffer(4);

assert.throws(TypeError, function() {
  getter.call(sab);
}, "`this` cannot be a SharedArrayBuffer");

assert.throws(TypeError, function() {
  Object.defineProperties(sab, { byteLength });
  sab.byteLength;
}, "`this` cannot be a SharedArrayBuffer");

reportCompare(0, 0);