Debian Codegraph @

js/src/tests/test262/intl402/DisplayNames/proto-from-ctor-realm.js

raw
1 // Copyright (C) 2019 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-Intl.DisplayNames
5 description: Default [[Prototype]] value derived from realm of the newTarget
6 info: |
7 Intl.DisplayNames ( locales , options )
8
9 1. If NewTarget is undefined, throw a TypeError exception.
10 2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
11 « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
12 ...
13 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).
14 13. If type is undefined, throw a TypeError exception.
15
16 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
17
18 ...
19 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
20 3. Return ObjectCreate(proto, internalSlotsList).
21
22 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
23
24 ...
25 3. Let proto be ? Get(constructor, "prototype").
26 4. If Type(proto) is not Object, then
27 a. Let realm be ? GetFunctionRealm(constructor).
28 b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
29 5. Return proto.
30 features: [Intl.DisplayNames, cross-realm, Reflect]
31 ---*/
32
33 var other = $262.createRealm().global;
34 var C = new other.Function();
35 C.prototype = null;
36
37 var o = Reflect.construct(Intl.DisplayNames, [undefined, {type: 'language'}], C);
38
39 assert.sameValue(Object.getPrototypeOf(o), other.Intl.DisplayNames.prototype);
40
41 reportCompare(0, 0);