Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/proto-from-ctor-realm.js

raw
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-promise-executor
5 es6id: 25.4.3.1
6 description: Default [[Prototype]] value derived from realm of the newTarget
7 info: |
8 [...]
9 3. Let promise be ? OrdinaryCreateFromConstructor(NewTarget,
10 "%PromisePrototype%", « [[PromiseState]], [[PromiseResult]],
11 [[PromiseFulfillReactions]], [[PromiseRejectReactions]],
12 [[PromiseIsHandled]] »).
13 [...]
14
15 9.1.14 GetPrototypeFromConstructor
16
17 [...]
18 3. Let proto be ? Get(constructor, "prototype").
19 4. If Type(proto) is not Object, then
20 a. Let realm be ? GetFunctionRealm(constructor).
21 b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
22 [...]
23 features: [cross-realm, Reflect]
24 ---*/
25
26 var other = $262.createRealm().global;
27 var C = new other.Function();
28 C.prototype = null;
29
30 var o = Reflect.construct(Promise, [function() {}], C);
31
32 assert.sameValue(Object.getPrototypeOf(o), other.Promise.prototype);