Remove unnecessary tests if $262.detachArrayBuffer is defined

This commit is contained in:
André Bargull 2025-04-30 14:16:12 +02:00 committed by Philip Chimento
parent 11c8fe0a99
commit 61286de40c
9 changed files with 475 additions and 493 deletions

View File

@ -8,6 +8,7 @@ description: |
pending
esid: pending
---*/
var buffer = new ArrayBuffer(2);
var view = new DataView(buffer);
@ -30,7 +31,6 @@ for (let fun of ['getInt8', 'getInt16']) {
assert.sameValue(view[fun](NaN), 0);
}
if ('$262.detachArrayBuffer' in this) {
// ToIndex is called before detachment check, so we can tell the difference
// between a ToIndex failure and a real out of bounds failure.
$262.detachArrayBuffer(buffer);
@ -41,5 +41,3 @@ if ('$262.detachArrayBuffer' in this) {
assert.throws(TypeError, () => view.setInt8(0, 0));
assert.throws(TypeError, () => view.getInt8(Math.pow(2, 53) - 1));
assert.throws(TypeError, () => view.setInt8(Math.pow(2, 53) - 1, 0));
}

View File

@ -9,17 +9,15 @@ description: |
pending
esid: pending
---*/
function checkResult(actual, expected)
{
assert.sameValue(actual.value, expected.value);
assert.sameValue(actual.done, expected.done);
}
if (typeof $262.detachArrayBuffer === "function")
{
var iteratorFunction = Uint8Array.prototype[Symbol.iterator];
var thisGlobal = this;
var otherGlobal = $262.createRealm().global;
@ -78,5 +76,3 @@ if (typeof $262.detachArrayBuffer === "function")
assert.throws(TypeError, () => thisNext.call(iterator));
}
}
}

View File

@ -8,6 +8,7 @@ description: |
pending
esid: pending
---*/
// Tests for detached ArrayBuffer checks in %TypedArray%.prototype.set(array|typedArray, offset).
function* createTypedArrays(lengths = [0, 1, 4, 4096]) {
@ -19,7 +20,6 @@ function* createTypedArrays(lengths = [0, 1, 4, 4096]) {
}
}
if (typeof $262.detachArrayBuffer === "function") {
class ExpectedError extends Error {}
// No detached check on function entry.
@ -269,5 +269,3 @@ if (typeof $262.detachArrayBuffer === "function") {
assert.sameValue(accessed, true);
}
}
}

View File

@ -24,9 +24,7 @@ for (var constructor of anyTypedArrayConstructors) {
assert.sameValue(Object.hasOwn(receiver, 10), false);
// Detached
if (typeof $262.detachArrayBuffer === "function" &&
!isSharedConstructor(constructor))
{
if (!isSharedConstructor(constructor)) {
$262.detachArrayBuffer(ta.buffer)
assert.sameValue(ta[0], undefined);

View File

@ -9,6 +9,7 @@ description: |
pending
esid: pending
---*/
// Test %TypedArray%.prototype.set(typedArray, offset) when called with wrapped
// typed array.
@ -35,7 +36,7 @@ for (var TA of anyTypedArrayConstructors) {
}
// Detachment checks are also applied correctly for wrapped typed arrays.
if (typeof $262.detachArrayBuffer === "function") {
// Create typed array from different global (explicit constructor call).
for (var TA of typedArrayConstructors) {
var target = new TA(4);
@ -84,4 +85,3 @@ if (typeof $262.detachArrayBuffer === "function") {
};
assert.throws(TypeError, () => target.set(source, offset));
}
}

View File

@ -8,6 +8,7 @@ description: |
pending
esid: pending
---*/
// Tests for detached ArrayBuffer checks in %TypedArray%.prototype.slice ( start, end ).
function* createTypedArrays(lengths = [0, 1, 4, 4096]) {
@ -27,7 +28,6 @@ function* createTypedArrays(lengths = [0, 1, 4, 4096]) {
}
}
if (typeof $262.detachArrayBuffer === "function") {
// ArrayBuffer is detached when entering slice().
for (let {typedArray, buffer} of createTypedArrays()) {
$262.detachArrayBuffer(buffer());
@ -107,5 +107,3 @@ if (typeof $262.detachArrayBuffer === "function") {
}
assert.sameValue(detached, true, "$262.detachArrayBuffer was called");
}
}

View File

@ -8,18 +8,17 @@ description: |
pending
esid: pending
---*/
// Ensure that TypedArrays throw when attempting to sort a detached ArrayBuffer
if (typeof $262.detachArrayBuffer === "function") {
assert.throws(TypeError, () => {
let buffer = new ArrayBuffer(32);
let array = new Int32Array(buffer);
$262.detachArrayBuffer(buffer);
array.sort();
});
}
// Ensure detaching buffer in comparator doesn't throw an error.
if (typeof $262.detachArrayBuffer === "function") {
{
let detached = false;
let ta = new Int32Array(3);
ta.sort(function(a, b) {
@ -43,7 +42,7 @@ let otherGlobal = $262.createRealm().global;
}
// Ensure detaching buffer in comparator doesn't throw an error when the typed array is wrapped.
if (typeof $262.detachArrayBuffer === "function") {
{
let detached = false;
let ta = new Int32Array(3);
otherGlobal.Int32Array.prototype.sort.call(ta, function(a,b) {

View File

@ -9,8 +9,7 @@ description: |
pending
esid: pending
---*/
// Bug 1291003
if (typeof $262.detachArrayBuffer === "function") {
for (let constructor of typedArrayConstructors) {
const elementSize = constructor.BYTES_PER_ELEMENT;
@ -34,5 +33,3 @@ if (typeof $262.detachArrayBuffer === "function") {
assert.sameValue(targetOffset, 1 * elementSize);
}
}

View File

@ -9,7 +9,7 @@ description: |
pending
esid: pending
---*/
if (typeof $262.detachArrayBuffer === "function") {
const originalNumberToLocaleString = Number.prototype.toLocaleString;
// Throws if array buffer is detached.
@ -43,5 +43,3 @@ if (typeof $262.detachArrayBuffer === "function") {
assert.sameValue(detached, true);
}
Number.prototype.toLocaleString = originalNumberToLocaleString;
}