summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow')
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/descriptor.js25
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/extensible.js18
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-larger-size.js50
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-same-size.js50
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js50
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/length.js33
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/name.js30
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-excessive.js27
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-negative.js27
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-non-number.js39
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/nonconstructor.js28
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-arraybuffer-object.js31
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-object.js47
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-resizable-arraybuffer-object.js41
-rw-r--r--js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-sharedarraybuffer.js23
17 files changed, 519 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/browser.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/browser.js
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/descriptor.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/descriptor.js
new file mode 100644
index 0000000000..b7d3f5ac72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/descriptor.js
@@ -0,0 +1,25 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ SharedArrayBuffer.prototype.grow has default data property attributes.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every other data property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+verifyProperty(SharedArrayBuffer.prototype, 'grow', {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/extensible.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/extensible.js
new file mode 100644
index 0000000000..3465ce0753
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/extensible.js
@@ -0,0 +1,18 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: SharedArrayBuffer.prototype.grow is extensible.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Unless specified otherwise, the [[Extensible]] internal slot
+ of a built-in object initially has the value true.
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+assert(Object.isExtensible(SharedArrayBuffer.prototype.grow));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-larger-size.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-larger-size.js
new file mode 100644
index 0000000000..fadedb4797
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-larger-size.js
@@ -0,0 +1,50 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Behavior when attempting to grow a growable array buffer to a larger size
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false throw a TypeError exception.
+ 4. Let newByteLength be ? ToIntegerOrInfinity(newLength).
+ 5. Let hostHandled be ? HostGrowSharedArrayBuffer(O, newByteLength).
+ 6. If hostHandled is handled, return undefined.
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var sab = new SharedArrayBuffer(4, {maxByteLength: 5});
+var result;
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where
+// `SharedArrayBuffer.prototype.grow` has not been implemented. The following
+// assertion prevents this test from passing in runtimes which have not
+// implemented the method.
+assert.sameValue(typeof sab.grow, 'function');
+
+try {
+ result = ab.grow(5);
+} catch (_) {}
+
+// One of the following three conditions must be met:
+//
+// - HostGrowSharedArrayBuffer returns an abrupt completion
+// - HostGrowSharedArrayBuffer handles the grow operation, and the `grow`
+// method returns early
+// - HostGrowSharedArrayBuffer does not handle the grow operation, and the
+// `grow` method executes its final steps
+//
+// All three conditions have the same effect on the value of `result`.
+assert.sameValue(result, undefined, 'normal completion value');
+
+// Neither the length nor the contents of the SharedArrayBuffer are guaranteed
+// by the host-defined abstract operation, so they are not asserted in this
+// test.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-same-size.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-same-size.js
new file mode 100644
index 0000000000..9148d630a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-same-size.js
@@ -0,0 +1,50 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Behavior when attempting to grow a growable array buffer to its current size
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false throw a TypeError exception.
+ 4. Let newByteLength be ? ToIntegerOrInfinity(newLength).
+ 5. Let hostHandled be ? HostGrowSharedArrayBuffer(O, newByteLength).
+ 6. If hostHandled is handled, return undefined.
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var sab = new SharedArrayBuffer(4, {maxByteLength: 5});
+var result;
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where
+// `SharedArrayBuffer.prototype.grow` has not been implemented. The following
+// assertion prevents this test from passing in runtimes which have not
+// implemented the method.
+assert.sameValue(typeof sab.grow, 'function');
+
+try {
+ result = ab.grow(4);
+} catch (_) {}
+
+// One of the following three conditions must be met:
+//
+// - HostGrowSharedArrayBuffer returns an abrupt completion
+// - HostGrowSharedArrayBuffer handles the grow operation, and the `grow`
+// method returns early
+// - HostGrowSharedArrayBuffer does not handle the grow operation, and the
+// `grow` method executes its final steps
+//
+// All three conditions have the same effect on the value of `result`.
+assert.sameValue(result, undefined, 'normal completion value');
+
+// Neither the length nor the contents of the SharedArrayBuffer are guaranteed
+// by the host-defined abstract operation, so they are not asserted in this
+// test.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js
new file mode 100644
index 0000000000..1c2b7a193d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/grow-smaller-size.js
@@ -0,0 +1,50 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Behavior when attempting to grow a growable array buffer to a smaller size
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false throw a TypeError exception.
+ 4. Let newByteLength be ? ToIntegerOrInfinity(newLength).
+ 5. Let hostHandled be ? HostGrowSharedArrayBuffer(O, newByteLength).
+ 6. If hostHandled is handled, return undefined.
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var sab = new SharedArrayBuffer(4, {maxByteLength: 5});
+var result;
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where
+// `SharedArrayBuffer.prototype.grow` has not been implemented. The following
+// assertion prevents this test from passing in runtimes which have not
+// implemented the method.
+assert.sameValue(typeof sab.grow, 'function');
+
+try {
+ result = ab.grow(3);
+} catch (_) {}
+
+// One of the following three conditions must be met:
+//
+// - HostGrowSharedArrayBuffer returns an abrupt completion
+// - HostGrowSharedArrayBuffer handles the grow operation, and the `grow`
+// method returns early
+// - HostGrowSharedArrayBuffer does not handle the grow operation, and the
+// `grow` method executes its final steps
+//
+// All three conditions have the same effect on the value of `result`.
+assert.sameValue(result, undefined, 'normal completion value');
+
+// Neither the length nor the contents of the SharedArrayBuffer are guaranteed
+// by the host-defined abstract operation, so they are not asserted in this
+// test.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/length.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/length.js
new file mode 100644
index 0000000000..19c62cddb6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/length.js
@@ -0,0 +1,33 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ SharedArrayBuffer.prototype.grow.length is 1.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 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: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+verifyProperty(SharedArrayBuffer.prototype.grow, 'length', {
+ value: 1,
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/name.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/name.js
new file mode 100644
index 0000000000..56fccca7ea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/name.js
@@ -0,0 +1,30 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ SharedArrayBuffer.prototype.grow.name is "grow".
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+features: [SharedArrayBuffer, resizable-arraybuffer]
+includes: [propertyHelper.js]
+---*/
+
+verifyProperty(SharedArrayBuffer.prototype.grow, 'name', {
+ value: 'grow',
+ enumerable: false,
+ wrtiable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-excessive.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-excessive.js
new file mode 100644
index 0000000000..d66f1bd919
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-excessive.js
@@ -0,0 +1,27 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Throws a RangeError the newLength value is larger than the max byte length
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
+ 4. Let newByteLength be ? ToIntegerOrInfinity(newLength).
+ 5. If newByteLength < 0 or newByteLength > O.[[ArrayBufferMaxByteLength]],
+ throw a RangeError exception.
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var ab = new SharedArrayBuffer(4, {maxByteLength: 4});
+
+assert.throws(RangeError, function() {
+ ab.grow(5);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-negative.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-negative.js
new file mode 100644
index 0000000000..0c03abb4ea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-negative.js
@@ -0,0 +1,27 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Throws a RangeError the newLength value is less than zero
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
+ 4. Let newByteLength be ? ToIntegerOrInfinity(newLength).
+ 5. If newByteLength < 0 or newByteLength > O.[[ArrayBufferMaxByteLength]],
+ throw a RangeError exception.
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var ab = new SharedArrayBuffer(4, {maxByteLength: 4});
+
+assert.throws(RangeError, function() {
+ ab.grow(-1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-non-number.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-non-number.js
new file mode 100644
index 0000000000..a2ead72460
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/new-length-non-number.js
@@ -0,0 +1,39 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: Throws a TypeError if provided length cannot be coerced to a number
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
+ 4. Let newByteLength be ? ToIntegerOrInfinity(newLength).
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var log = [];
+var newLength = {
+ toString: function() {
+ log.push('toString');
+ return {};
+ },
+ valueOf: function() {
+ log.push('valueOf');
+ return {};
+ }
+};
+var ab = new SharedArrayBuffer(0, {maxByteLength: 4});
+
+assert.throws(TypeError, function() {
+ ab.grow(newLength);
+});
+
+assert.sameValue(log.length, 2);
+assert.sameValue(log[0], 'valueOf');
+assert.sameValue(log[1], 'toString');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/nonconstructor.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/nonconstructor.js
new file mode 100644
index 0000000000..ae4b722e57
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/nonconstructor.js
@@ -0,0 +1,28 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ SharedArrayBuffer.prototype.grow is not a constructor function.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified
+ in the description of a particular function.
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ Object.prototype.hasOwnProperty.call(SharedArrayBuffer.prototype.grow, 'prototype'),
+ false
+);
+
+var arrayBuffer = new SharedArrayBuffer(8);
+assert.throws(TypeError, function() {
+ new arrayBuffer.grow();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/shell.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/shell.js
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-arraybuffer-object.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-arraybuffer-object.js
new file mode 100644
index 0000000000..271064ba5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-arraybuffer-object.js
@@ -0,0 +1,31 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Throws a TypeError if `this` does not have an [[ArrayBufferData]] internal slot.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+assert.sameValue(typeof SharedArrayBuffer.prototype.grow, 'function');
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow();
+}, '`this` value is the SharedArrayBuffer prototype');
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call({});
+}, '`this` value is an object');
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call([]);
+}, '`this` value is an array');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-object.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-object.js
new file mode 100644
index 0000000000..cfcdbbfa69
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-object.js
@@ -0,0 +1,47 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: Throws a TypeError if `this` valueis not an object.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ [...]
+features: [BigInt, SharedArrayBuffer, Symbol, resizable-arraybuffer]
+---*/
+
+assert.sameValue(typeof SharedArrayBuffer.prototype.grow, "function");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(undefined);
+}, "`this` value is undefined");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(null);
+}, "`this` value is null");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(true);
+}, "`this` value is Boolean");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call("");
+}, "`this` value is String");
+
+var symbol = Symbol();
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(symbol);
+}, "`this` value is Symbol");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(1);
+}, "`this` value is Number");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(1n);
+}, "`this` value is bigint");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-resizable-arraybuffer-object.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-resizable-arraybuffer-object.js
new file mode 100644
index 0000000000..34ccedf879
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-not-resizable-arraybuffer-object.js
@@ -0,0 +1,41 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: >
+ Throws a TypeError if `this` does not have an [[ArrayBufferMaxByteLength]] internal slot.
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ [...]
+features: [SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var ab;
+
+assert.sameValue(typeof SharedArrayBuffer.prototype.grow, 'function');
+
+ab = new SharedArrayBuffer(4);
+assert.throws(TypeError, function() {
+ ab.grow(0);
+}, 'zero byte length');
+
+ab = new SharedArrayBuffer(4);
+assert.throws(TypeError, function() {
+ ab.grow(3);
+}, 'smaller byte length');
+
+ab = new SharedArrayBuffer(4);
+assert.throws(TypeError, function() {
+ ab.grow(4);
+}, 'same byte length');
+
+ab = new SharedArrayBuffer(4);
+assert.throws(TypeError, function() {
+ ab.grow(5);
+}, 'larger byte length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-sharedarraybuffer.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-sharedarraybuffer.js
new file mode 100644
index 0000000000..09f7eafe01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/grow/this-is-sharedarraybuffer.js
@@ -0,0 +1,23 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// 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-sharedarraybuffer.prototype.grow
+description: Throws a TypeError if `this` value is an ArrayBuffer
+info: |
+ SharedArrayBuffer.prototype.grow ( newLength )
+
+ 1. Let O be the this value.
+ 2. Perform ? RequireInternalSlot(O, [[ArrayBufferMaxByteLength]]).
+ 3. If IsSharedArrayBuffer(O) is false, throw a TypeError exception.
+ [...]
+features: [ArrayBuffer, SharedArrayBuffer, resizable-arraybuffer]
+---*/
+
+var ab = new ArrayBuffer(0);
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.grow.call(ab);
+}, '`this` value cannot be an ArrayBuffer');
+
+reportCompare(0, 0);