summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable')
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/detached-buffer.js37
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js20
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-func.js26
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/length.js35
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/name.js27
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/prop-desc.js28
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/return-resizable.js32
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/shell.js18
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js42
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-not-object.js51
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js36
12 files changed, 352 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/browser.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/browser.js
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/detached-buffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/detached-buffer.js
new file mode 100644
index 0000000000..ddc2643173
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/detached-buffer.js
@@ -0,0 +1,37 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: Unaffected by buffer's attachedness
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ 3. If IsSharedArrayBuffer(O) is true, 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.
+includes: [detachArrayBuffer.js]
+features: [resizable-arraybuffer]
+---*/
+
+var ab1 = new ArrayBuffer(1);
+
+$DETACHBUFFER(ab1);
+
+assert.sameValue(ab1.resizable, false);
+
+var ab2 = new ArrayBuffer(1, {maxByteLength: 1});
+
+$DETACHBUFFER(ab2);
+
+assert.sameValue(ab2.resizable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js
new file mode 100644
index 0000000000..c07a5d9e22
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js
@@ -0,0 +1,20 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: Requires this value to have a [[ArrayBufferData]] internal slot
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ [...]
+features: [resizable-arraybuffer]
+---*/
+
+assert.throws(TypeError, function() {
+ ArrayBuffer.prototype.resizable;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-func.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-func.js
new file mode 100644
index 0000000000..0c960b4ea3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/invoked-as-func.js
@@ -0,0 +1,26 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: Throws a TypeError exception when invoked as a function
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ [...]
+features: [resizable-arraybuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ ArrayBuffer.prototype, 'resizable'
+).get;
+
+assert.sameValue(typeof getter, 'function');
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/length.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/length.js
new file mode 100644
index 0000000000..17f160d642
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/length.js
@@ -0,0 +1,35 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: >
+ get ArrayBuffer.prototype.resizable.length is 0.
+info: |
+ get ArrayBuffer.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(ArrayBuffer.prototype, 'resizable');
+
+verifyProperty(desc.get, 'length', {
+ value: 0,
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/name.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/name.js
new file mode 100644
index 0000000000..7fc235ee7f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/name.js
@@ -0,0 +1,27 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: >
+ get ArrayBuffer.prototype.resizable
+
+ 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(ArrayBuffer.prototype, 'resizable');
+
+verifyProperty(desc.get, 'name', {
+ value: 'get resizable',
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/prop-desc.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/prop-desc.js
new file mode 100644
index 0000000000..2363aac288
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/prop-desc.js
@@ -0,0 +1,28 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: >
+ "resizable" property of ArrayBuffer.prototype
+info: |
+ ArrayBuffer.prototype.resizable 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(ArrayBuffer.prototype, 'resizable');
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, 'function');
+
+verifyProperty(ArrayBuffer.prototype, 'resizable', {
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/return-resizable.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/return-resizable.js
new file mode 100644
index 0000000000..7833c24306
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/return-resizable.js
@@ -0,0 +1,32 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: Return value according to [[ArrayBufferMaxByteLength]] internal slot
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ 3. If IsSharedArrayBuffer(O) is true, 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 ab1 = new ArrayBuffer(1);
+
+assert.sameValue(ab1.resizable, false);
+
+var ab2 = new ArrayBuffer(1, {maxByteLength: 1});
+
+assert.sameValue(ab2.resizable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/shell.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/shell.js
new file mode 100644
index 0000000000..06f65290b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/shell.js
@@ -0,0 +1,18 @@
+// GENERATED, DO NOT EDIT
+// file: detachArrayBuffer.js
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ A function used in the process of asserting correctness of TypedArray objects.
+
+ $262.detachArrayBuffer is defined by a host.
+defines: [$DETACHBUFFER]
+---*/
+
+function $DETACHBUFFER(buffer) {
+ if (!$262 || typeof $262.detachArrayBuffer !== "function") {
+ throw new Test262Error("No method available to detach an ArrayBuffer");
+ }
+ $262.detachArrayBuffer(buffer);
+}
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js
new file mode 100644
index 0000000000..8994ca071a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js
@@ -0,0 +1,42 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: >
+ Throws a TypeError exception when `this` does not have a [[ArrayBufferData]]
+ internal slot
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ [...]
+features: [DataView, Int8Array, resizable-arraybuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ ArrayBuffer.prototype, "resizable"
+).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 ArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-not-object.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-not-object.js
new file mode 100644
index 0000000000..f28019bade
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-not-object.js
@@ -0,0 +1,51 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ [...]
+features: [Symbol, resizable-arraybuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ ArrayBuffer.prototype, "resizable"
+).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");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js
new file mode 100644
index 0000000000..cb9e219929
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js
@@ -0,0 +1,36 @@
+// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- SharedArrayBuffer,resizable-arraybuffer is not enabled unconditionally, requires shell-options
+// 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-arraybuffer.prototype.resizable
+description: Throws a TypeError exception when `this` is a SharedArrayBuffer
+info: |
+ get ArrayBuffer.prototype.resizable
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
+ 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception.
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var resizable = Object.getOwnPropertyDescriptor(
+ ArrayBuffer.prototype, "resizable"
+);
+
+var getter = resizable.get;
+var sab = new SharedArrayBuffer(4);
+
+assert.sameValue(typeof getter, "function");
+
+assert.throws(TypeError, function() {
+ getter.call(sab);
+}, "`this` cannot be a SharedArrayBuffer");
+
+Object.defineProperties(sab, { resizable: resizable });
+
+assert.throws(TypeError, function() {
+ sab.resizable;
+}, "`this` cannot be a SharedArrayBuffer");
+
+reportCompare(0, 0);