data-allocation-after-object-creation.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2015 André Bargull. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-arraybuffer-length
  5. description: >
  6. The new ArrayBuffer instance is created prior to allocating the Data Block.
  7. info: |
  8. ArrayBuffer( length )
  9. ...
  10. 6. Return AllocateArrayBuffer(NewTarget, byteLength).
  11. AllocateArrayBuffer( constructor, byteLength )
  12. 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%",
  13. «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).
  14. 2. ReturnIfAbrupt(obj).
  15. ...
  16. 4. Let block be CreateByteDataBlock(byteLength).
  17. 5. ReturnIfAbrupt(block).
  18. ...
  19. features: [Reflect.construct]
  20. ---*/
  21. function DummyError() {}
  22. var newTarget = function() {}.bind(null);
  23. Object.defineProperty(newTarget, "prototype", {
  24. get: function() {
  25. throw new DummyError();
  26. }
  27. });
  28. assert.throws(DummyError, function() {
  29. // Allocating 7 PiB should fail with a RangeError.
  30. // Math.pow(1024, 5) = 1125899906842624
  31. Reflect.construct(ArrayBuffer, [7 * 1125899906842624], newTarget);
  32. });