Debian Codegraph @

js/src/tests/test262/built-ins/String/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-string-constructor-string-value
5 description: Default [[Prototype]] value derived from realm of the newTarget
6 info: |
7 [...]
8 4. Return ? StringCreate(s, ? GetPrototypeFromConstructor(NewTarget,
9 "%StringPrototype%")).
10
11 9.1.14 GetPrototypeFromConstructor
12
13 [...]
14 3. Let proto be ? Get(constructor, "prototype").
15 4. If Type(proto) is not Object, then
16 a. Let realm be ? GetFunctionRealm(constructor).
17 b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
18 [...]
19 features: [cross-realm, Reflect]
20 ---*/
21
22 var other = $262.createRealm().global;
23 var C = new other.Function();
24 C.prototype = null;
25
26 var o = Reflect.construct(String, [], C);
27
28 assert.sameValue(Object.getPrototypeOf(o), other.String.prototype);
29
30 reportCompare(0, 0);