Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make resizableArrayBufferUtils not depend on syntax that may not be supported #4165

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions harness/resizableArrayBufferUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ defines:
features: [BigInt]
---*/

class MyUint8Array extends Uint8Array {
}

class MyFloat32Array extends Float32Array {
}

class MyBigInt64Array extends BigInt64Array {
}
// Using new Function()(); instead of just 'class x extends Y' as to not bomb out when `class` isn't supported
const MyUint8Array = new Function('return class MyUint8Array extends Uint8Array {}')();
const MyFloat32Array = new Function('return class MyFloat32Array extends Float32Array {}')();
const MyBigInt64Array = new Function('return class MyBigInt64Array extends BigInt64Array {}')();
Comment on lines +21 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok that these exceptions aren't caught?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, no, they are not. I'm sorry, juggling too many things at once and trying to rush it through, shouldn't have done that...

Will send an additional PR tomorrow... Sorry again for keeping you all occupied...


const builtinCtors = [
Uint8Array,
Expand All @@ -39,15 +35,18 @@ const builtinCtors = [
Uint8ClampedArray,
];

// BigInt and Float16Array are newer features adding them above unconditionally
// Big(U)int64Array and Float16Array are newer features adding them above unconditionally
// would cause implementations lacking it to fail every test which uses it.
if (typeof Float16Array !== 'undefined') {
builtinCtors.push(Float16Array);
}

if (typeof BigInt !== 'undefined') {
builtinCtors.push(BigUint64Array);
builtinCtors.push(BigInt64Array);
if (typeof BigUint64Array !== 'undefined') {
builtinCtors.push(BigUint64Array);
}

if (typeof BigInt64Array !== 'undefined') {
builtinCtors.push(BigInt64Array);
}

const floatCtors = [
Expand All @@ -60,13 +59,9 @@ if (typeof Float16Array !== 'undefined') {
floatCtors.push(Float16Array);
}

const ctors = [
...builtinCtors,
MyUint8Array,
MyFloat32Array
];
const ctors = builtinCtors.concat(MyUint8Array, MyFloat32Array);

if (typeof BigInt !== 'undefined') {
if (typeof MyBigInt64Array !== 'undefined') {
ctors.push(MyBigInt64Array);
}

Expand Down Expand Up @@ -125,7 +120,7 @@ function TestIterationAndResize(iterable, expected, rab, resizeAfter, newByteLen
let resized = false;
var arrayValues = false;

for (const value of iterable) {
for (let value of iterable) {
if (Array.isArray(value)) {
arrayValues = true;
values.push([
Expand Down
Loading