Skip to content

Commit

Permalink
Follow-up to #4165
Browse files Browse the repository at this point in the history
Added catch to achieve the entire goal of the previous PR to prevent the
harness from loading if 'class' syntax isn't supported
  • Loading branch information
p-bakker authored and ptomato committed Jul 25, 2024
1 parent 18ebac8 commit e7d9c0d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions harness/resizableArrayBufferUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ defines:
- TestIterationAndResize
features: [BigInt]
---*/
// Helper to create subclasses without bombing out when `class` isn't supported
function subClass(type) {
try {
return new Function('return class My' + type + ' extends ' + type + ' {}')();
} catch (e) {}
}

// 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 {}')();
const MyUint8Array = subClass('Uint8Array');
const MyFloat32Array = subClass('Float32Array');
const MyBigInt64Array = subClass('BigInt64Array');

const builtinCtors = [
Uint8Array,
Expand Down

0 comments on commit e7d9c0d

Please sign in to comment.