summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/DataView/prototype/byteOffset
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/DataView/prototype/byteOffset
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/DataView/prototype/byteOffset')
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/detached-buffer.js26
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-accessor.js22
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-func.js25
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js33
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js29
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/prop-desc.js25
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-auto.js54
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-fixed.js48
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js33
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset.js30
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js44
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal.js42
-rw-r--r--js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-is-not-object.js49
15 files changed, 460 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/browser.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/browser.js
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/detached-buffer.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/detached-buffer.js
new file mode 100644
index 0000000000..c151c15d43
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/detached-buffer.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: Throws a TypeError if the instance has a detached buffer
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ ...
+ 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 6. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [detachArrayBuffer.js]
+---*/
+
+var buffer = new ArrayBuffer(1);
+var sample = new DataView(buffer, 0);
+
+$DETACHBUFFER(buffer);
+
+assert.throws(TypeError, function() {
+ sample.byteOffset;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-accessor.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-accessor.js
new file mode 100644
index 0000000000..62736ba675
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-accessor.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ Requires this value to have a [[DataView]] internal slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+---*/
+
+assert.throws(TypeError, function() {
+ DataView.prototype.byteOffset;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-func.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-func.js
new file mode 100644
index 0000000000..7ce651f30a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/invoked-as-func.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, 'byteOffset'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js
new file mode 100644
index 0000000000..6565d89280
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ get DataView.prototype.byteOffset.length is 0.
+info: |
+ get DataView.prototype.byteOffset
+
+ 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]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(DataView.prototype, "byteOffset");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js
new file mode 100644
index 0000000000..e77dc91d09
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ get DataView.prototype.byteOffset
+
+ 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]
+---*/
+
+var descriptor = Object.getOwnPropertyDescriptor(
+ DataView.prototype, 'byteOffset'
+);
+
+assert.sameValue(
+ descriptor.get.name, 'get byteOffset',
+ 'The value of `descriptor.get.name` is `"get byteOffset"`'
+);
+
+verifyNotEnumerable(descriptor.get, 'name');
+verifyNotWritable(descriptor.get, 'name');
+verifyConfigurable(descriptor.get, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/prop-desc.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/prop-desc.js
new file mode 100644
index 0000000000..a52f1fe7d6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/prop-desc.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ "byteOffset" property of DataView.prototype
+info: |
+ DataView.prototype.byteOffset 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]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(DataView.prototype, "byteOffset");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(DataView.prototype, "byteOffset");
+verifyConfigurable(DataView.prototype, "byteOffset");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..f80d175bc4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-auto.js
@@ -0,0 +1,54 @@
+// |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-dataview.prototype.byteoffset
+description: |
+ throws a TypeError if the underlying ArrayBuffer is resized beyond the
+ boundary of the dynamically-sized DataView instance
+features: [resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+var ab = new ArrayBuffer(4, {maxByteLength: 5});
+var dataView = new DataView(ab, 1);
+
+assert.sameValue(dataView.byteOffset, 1);
+
+try {
+ ab.resize(5);
+} catch (_) {}
+
+assert.sameValue(dataView.byteOffset, 1, "following grow");
+
+try {
+ ab.resize(3);
+} catch (_) {}
+
+assert.sameValue(dataView.byteOffset, 1, "following shrink (within bounds)");
+
+try {
+ ab.resize(1);
+} catch (_) {}
+
+assert.sameValue(dataView.byteOffset, 1, "following shrink (on boundary)");
+
+var expectedError;
+try {
+ ab.resize(0);
+ expectedError = TypeError;
+} catch (_) {
+ expectedError = Test262Error;
+}
+
+assert.throws(expectedError, function() {
+ dataView.byteOffset;
+ throw new Test262Error('the operation completed successfully');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..5790d1689f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/resizable-array-buffer-fixed.js
@@ -0,0 +1,48 @@
+// |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-dataview.prototype.byteoffset
+description: |
+ throws a TypeError if the underlying ArrayBuffer is resized beyond the
+ boundary of the fixed-sized DataView instance
+features: [resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+var ab = new ArrayBuffer(4, {maxByteLength: 5});
+var dataView = new DataView(ab, 1, 2);
+
+assert.sameValue(dataView.byteOffset, 1);
+
+try {
+ ab.resize(5);
+} catch (_) {}
+
+assert.sameValue(dataView.byteOffset, 1, "following grow");
+
+try {
+ ab.resize(BPE * 3);
+} catch (_) {}
+
+assert.sameValue(dataView.byteOffset, 1, "following shrink (within bounds)");
+
+var expectedError;
+try {
+ ab.resize(2);
+ expectedError = TypeError;
+} catch (_) {
+ expectedError = Test262Error;
+}
+
+assert.throws(expectedError, function() {
+ dataView.byteOffset;
+ throw new Test262Error('the operation completed successfully');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js
new file mode 100644
index 0000000000..e0184f2a5b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js
@@ -0,0 +1,33 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ Return value from [[ByteOffset]] internal slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ ...
+ 7. Let offset be the value of O's [[ByteOffset]] internal slot.
+ 8. Return offset.
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(12);
+
+var sample1 = new DataView(buffer, 0);
+var sample2 = new DataView(buffer, 4);
+var sample3 = new DataView(buffer, 6, 4);
+var sample4 = new DataView(buffer, 12);
+var sample5 = new DataView(buffer, 0, 2);
+
+assert.sameValue(sample1.byteOffset, 0);
+assert.sameValue(sample2.byteOffset, 4);
+assert.sameValue(sample3.byteOffset, 6);
+assert.sameValue(sample4.byteOffset, 12);
+assert.sameValue(sample5.byteOffset, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset.js
new file mode 100644
index 0000000000..b7f3c201a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/return-byteoffset.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ Return value from [[ByteOffset]] internal slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ ...
+ 7. Let offset be the value of O's [[ByteOffset]] internal slot.
+ 8. Return offset.
+---*/
+
+var buffer = new ArrayBuffer(12);
+
+var sample1 = new DataView(buffer, 0);
+var sample2 = new DataView(buffer, 4);
+var sample3 = new DataView(buffer, 6, 4);
+var sample4 = new DataView(buffer, 12);
+var sample5 = new DataView(buffer, 0, 2);
+
+assert.sameValue(sample1.byteOffset, 0);
+assert.sameValue(sample2.byteOffset, 4);
+assert.sameValue(sample3.byteOffset, 6);
+assert.sameValue(sample4.byteOffset, 12);
+assert.sameValue(sample5.byteOffset, 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/shell.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/shell.js
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js
new file mode 100644
index 0000000000..792463509c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js
@@ -0,0 +1,44 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ Throws a TypeError exception when `this` does not have a [[DataView]] internal
+ slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteOffset"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+}, "[]");
+
+var ab = new SharedArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+}, "ArrayBuffer");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ getter.call(ta);
+}, "TypedArray");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal.js
new file mode 100644
index 0000000000..ad3f8d1503
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: >
+ Throws a TypeError exception when `this` does not have a [[DataView]] internal
+ slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [Int8Array]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteOffset"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+}, "[]");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+}, "ArrayBuffer");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ getter.call(ta);
+}, "TypedArray");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-is-not-object.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-is-not-object.js
new file mode 100644
index 0000000000..6a78b8f234
--- /dev/null
+++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/this-is-not-object.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-dataview.prototype.byteoffset
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+features: [Symbol]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteOffset"
+).get;
+
+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);