options-maxbytelength-excessive.js 968 B

12345678910111213141516171819202122232425262728
  1. // Copyright (C) 2021 the V8 project authors. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-arraybuffer-constructor
  5. description: |
  6. Invoked with an options object whose `maxByteLength` property exceeds the
  7. maximum length value
  8. info: |
  9. ArrayBuffer( length [ , options ] )
  10. 1. If NewTarget is undefined, throw a TypeError exception.
  11. 2. Let byteLength be ? ToIndex(length).
  12. 3. Let requestedMaxByteLength be ? GetArrayBufferMaxByteLengthOption(options).
  13. [...]
  14. 1.1.5 GetArrayBufferMaxByteLengthOption ( options )
  15. 1. If Type(options) is not Object, return empty.
  16. 2. Let maxByteLength be ? Get(options, "maxByteLength").
  17. 3. If maxByteLength is undefined, return empty.
  18. 4. Return ? ToIndex(maxByteLength).
  19. features: [resizable-arraybuffer]
  20. ---*/
  21. assert.throws(RangeError, function() {
  22. // Math.pow(2, 53) = 9007199254740992
  23. new ArrayBuffer(0, { maxByteLength: 9007199254740992 });
  24. });