proto-from-ctor-realm.js 868 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2016 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-length
  5. description: Default [[Prototype]] value derived from realm of the newTarget
  6. info: |
  7. [...]
  8. 5. Return ? AllocateArrayBuffer(NewTarget, byteLength).
  9. 9.1.14 GetPrototypeFromConstructor
  10. [...]
  11. 3. Let proto be ? Get(constructor, "prototype").
  12. 4. If Type(proto) is not Object, then
  13. a. Let realm be ? GetFunctionRealm(constructor).
  14. b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
  15. [...]
  16. features: [cross-realm, Reflect]
  17. ---*/
  18. var other = $262.createRealm().global;
  19. var C = new other.Function();
  20. C.prototype = null;
  21. var o = Reflect.construct(ArrayBuffer, [], C);
  22. assert.sameValue(Object.getPrototypeOf(o), other.ArrayBuffer.prototype);