mirror of https://github.com/tc39/test262.git
Resizable ArrayBuffer: SharedArrayBuffer accessors (#3025)
* Add "feature" for "Resizable ArrayBuffer" proposal * Resizable ArrayBuffer: SharedArrayBuffer accessors * fixup! Resizable ArrayBuffer: SharedArrayBuffer accessors
This commit is contained in:
parent
a82aeaa391
commit
884ed7f6f8
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: Requires this value to have a [[ArrayBufferData]] internal slot
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
SharedArrayBuffer.prototype.growable;
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: Throws a TypeError exception when invoked as a function
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var getter = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, 'growable'
|
||||
).get;
|
||||
|
||||
assert.sameValue(typeof getter, 'function');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter();
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: >
|
||||
get SharedArrayBuffer.prototype.growable.length is 0.
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.resizeable
|
||||
|
||||
17 ECMAScript Standard Built-in Objects:
|
||||
Every built-in Function object, including constructors, has a length
|
||||
property whose value is an integer. Unless otherwise specified, this
|
||||
value is equal to the largest number of named arguments shown in the
|
||||
subclause headings for the function description, including optional
|
||||
parameters. However, rest parameters shown using the form “...name”
|
||||
are not included in the default argument count.
|
||||
|
||||
Unless otherwise specified, the length property of a built-in Function
|
||||
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||
[[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'growable');
|
||||
|
||||
verifyProperty(desc.get, 'length', {
|
||||
value: 0,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: >
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in
|
||||
properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'growable');
|
||||
|
||||
verifyProperty(desc.get, 'name', {
|
||||
value: 'get growable',
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: >
|
||||
"growable" property of SharedArrayBuffer.prototype
|
||||
info: |
|
||||
SharedArrayBuffer.prototype.growable is an accessor property whose set accessor
|
||||
function is undefined.
|
||||
|
||||
Section 17: Every accessor property described in clauses 18 through 26 and in
|
||||
Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
|
||||
includes: [propertyHelper.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'growable');
|
||||
|
||||
assert.sameValue(desc.set, undefined);
|
||||
assert.sameValue(typeof desc.get, 'function');
|
||||
|
||||
verifyProperty(SharedArrayBuffer.prototype, 'growable', {
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: Return value according to [[ArrayBufferMaxByteLength]] internal slot
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
4. Return IsResizableArrayBuffer(O).
|
||||
|
||||
IsResizableArrayBuffer ( arrayBuffer )
|
||||
|
||||
1. Assert: Type(arrayBuffer) is Object and arrayBuffer has an
|
||||
[[ArrayBufferData]] internal slot.
|
||||
2. If buffer has an [[ArrayBufferMaxByteLength]] internal slot, return true.
|
||||
3. Return false.
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var sab1 = new SharedArrayBuffer(1);
|
||||
|
||||
assert.sameValue(sab1.growable, false);
|
||||
|
||||
var sab2 = new SharedArrayBuffer(1, {maxByteLength: 1});
|
||||
|
||||
assert.sameValue(sab2.growable, true);
|
39
test/built-ins/SharedArrayBuffer/prototype/growable/this-has-no-arraybufferdata-internal.js
vendored
Normal file
39
test/built-ins/SharedArrayBuffer/prototype/growable/this-has-no-arraybufferdata-internal.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: >
|
||||
Throws a TypeError exception when `this` does not have a [[ArrayBufferData]]
|
||||
internal slot
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [DataView, Int8Array, resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var getter = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, "growable"
|
||||
).get;
|
||||
|
||||
assert.sameValue(typeof getter, "function");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call({});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call([]);
|
||||
});
|
||||
|
||||
var ta = new Int8Array(8);
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(ta);
|
||||
});
|
||||
|
||||
var dv = new DataView(new SharedArrayBuffer(8), 0);
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(dv);
|
||||
});
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: Throws a TypeError exception when `this` is an SharedArrayBuffer
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
[...]
|
||||
features: [SharedArrayBuffer, resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var growable = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, "growable"
|
||||
);
|
||||
|
||||
var getter = growable.get;
|
||||
var ab = new SharedArrayBuffer(4);
|
||||
|
||||
assert.sameValue(typeof getter, "function");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(ab);
|
||||
}, "`this` cannot be an SharedArrayBuffer");
|
||||
|
||||
Object.defineProperties(ab, { growable: growable });
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
ab.growable;
|
||||
}, "`this` cannot be an SharedArrayBuffer");
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.growable
|
||||
description: Throws a TypeError exception when `this` is not Object
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.growable
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [Symbol, resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var getter = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, "growable"
|
||||
).get;
|
||||
|
||||
assert.sameValue(typeof getter, "function");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(undefined);
|
||||
}, "this is undefined");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(null);
|
||||
}, "this is null");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(42);
|
||||
}, "this is 42");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call("1");
|
||||
}, "this is a string");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(true);
|
||||
}, "this is true");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(false);
|
||||
}, "this is false");
|
||||
|
||||
var s = Symbol("s");
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(s);
|
||||
}, "this is a Symbol");
|
17
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/invoked-as-accessor.js
vendored
Normal file
17
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/invoked-as-accessor.js
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: Requires this value to have a [[ArrayBufferData]] internal slot
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
SharedArrayBuffer.prototype.maxByteLength;
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: Throws a TypeError exception when invoked as a function
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var getter = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, 'maxByteLength'
|
||||
).get;
|
||||
|
||||
assert.sameValue(typeof getter, 'function');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter();
|
||||
});
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: >
|
||||
get SharedArrayBuffer.prototype.maxByteLength.length is 0.
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
17 ECMAScript Standard Built-in Objects:
|
||||
Every built-in Function object, including constructors, has a length
|
||||
property whose value is an integer. Unless otherwise specified, this
|
||||
value is equal to the largest number of named arguments shown in the
|
||||
subclause headings for the function description, including optional
|
||||
parameters. However, rest parameters shown using the form “...name”
|
||||
are not included in the default argument count.
|
||||
|
||||
Unless otherwise specified, the length property of a built-in Function
|
||||
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||
[[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'maxByteLength');
|
||||
|
||||
verifyProperty(desc.get, 'length', {
|
||||
value: 0,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: >
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in
|
||||
properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'maxByteLength');
|
||||
|
||||
verifyProperty(desc.get, 'name', {
|
||||
value: 'get maxByteLength',
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: >
|
||||
"maxByteLength" property of SharedArrayBuffer.prototype
|
||||
info: |
|
||||
SharedArrayBuffer.prototype.maxByteLength is an accessor property whose set
|
||||
accessor function is undefined.
|
||||
|
||||
Section 17: Every accessor property described in clauses 18 through 26 and in
|
||||
Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
|
||||
includes: [propertyHelper.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'maxByteLength');
|
||||
|
||||
assert.sameValue(desc.set, undefined);
|
||||
assert.sameValue(typeof desc.get, 'function');
|
||||
|
||||
verifyProperty(SharedArrayBuffer.prototype, 'maxByteLength', {
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
27
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/return-maxbytelength-growable.js
vendored
Normal file
27
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/return-maxbytelength-growable.js
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: Return value from [[ArrayBufferMaxByteLength]] internal slot
|
||||
info: |
|
||||
24.1.4.1 get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
4. If IsResizableArrayBuffer(O) is true, then
|
||||
a. Let length be O.[[ArrayBufferMaxByteLength]].
|
||||
5. Else,
|
||||
[...]
|
||||
6. Return 𝔽(length).
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var ab1 = new SharedArrayBuffer(0, { maxByteLength: 0 });
|
||||
assert.sameValue(ab1.maxByteLength, 0);
|
||||
|
||||
var ab2 = new SharedArrayBuffer(0, { maxByteLength: 23 });
|
||||
assert.sameValue(ab2.maxByteLength, 23);
|
||||
|
||||
var ab3 = new SharedArrayBuffer(42, { maxByteLength: 42 });
|
||||
assert.sameValue(ab3.maxByteLength, 42);
|
24
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-growable.js
vendored
Normal file
24
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-growable.js
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: Return value from [[ArrayBufferByteLength]] internal slot
|
||||
info: |
|
||||
24.1.4.1 get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
4. If IsResizableArrayBuffer(O) is true, then
|
||||
[...]
|
||||
5. Else,
|
||||
a. Let length be O.[[ArrayBufferByteLength]].
|
||||
6. Return 𝔽(length).
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var ab1 = new SharedArrayBuffer(0);
|
||||
assert.sameValue(ab1.maxByteLength, 0);
|
||||
|
||||
var ab2 = new SharedArrayBuffer(42);
|
||||
assert.sameValue(ab2.maxByteLength, 42);
|
39
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/this-has-no-arraybufferdata-internal.js
vendored
Normal file
39
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/this-has-no-arraybufferdata-internal.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: >
|
||||
Throws a TypeError exception when `this` does not have a [[ArrayBufferData]]
|
||||
internal slot
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [DataView, Int8Array, resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var getter = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, "maxByteLength"
|
||||
).get;
|
||||
|
||||
assert.sameValue(typeof getter, "function");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call({});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call([]);
|
||||
});
|
||||
|
||||
var ta = new Int8Array(8);
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(ta);
|
||||
});
|
||||
|
||||
var dv = new DataView(new SharedArrayBuffer(8), 0);
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(dv);
|
||||
});
|
33
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/this-is-arraybuffer.js
vendored
Normal file
33
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/this-is-arraybuffer.js
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: Throws a TypeError exception when `this` is an ArrayBuffer
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
|
||||
[...]
|
||||
features: [ArrayBuffer, resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var maxByteLength = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, "maxByteLength"
|
||||
);
|
||||
|
||||
var getter = maxByteLength.get;
|
||||
var ab = new ArrayBuffer(4);
|
||||
|
||||
assert.sameValue(typeof getter, "function");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(ab);
|
||||
}, "`this` cannot be an ArrayBuffer");
|
||||
|
||||
Object.defineProperties(sab, { maxByteLength: maxByteLength });
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
ab.maxByteLength;
|
||||
}, "`this` cannot be an ArrayBuffer");
|
48
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/this-is-not-object.js
vendored
Normal file
48
test/built-ins/SharedArrayBuffer/prototype/maxByteLength/this-is-not-object.js
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-get-sharedarraybuffer.prototype.maxbytelength
|
||||
description: Throws a TypeError exception when `this` is not Object
|
||||
info: |
|
||||
get SharedArrayBuffer.prototype.maxByteLength
|
||||
|
||||
1. Let O be the this value.
|
||||
2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
[...]
|
||||
features: [Symbol, resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
var getter = Object.getOwnPropertyDescriptor(
|
||||
SharedArrayBuffer.prototype, "maxByteLength"
|
||||
).get;
|
||||
|
||||
assert.sameValue(typeof getter, "function");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(undefined);
|
||||
}, "this is undefined");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(null);
|
||||
}, "this is null");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(42);
|
||||
}, "this is 42");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call("1");
|
||||
}, "this is a string");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(true);
|
||||
}, "this is true");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(false);
|
||||
}, "this is false");
|
||||
|
||||
var s = Symbol("s");
|
||||
assert.throws(TypeError, function() {
|
||||
getter.call(s);
|
||||
}, "this is a Symbol");
|
Loading…
Reference in New Issue