| 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-generator-function-definitions-runtime-semantics-evaluatebody |
| 5 |
es6id: 14.4.11 |
| 6 |
description: > |
| 7 |
Default [[Prototype]] value derived from realm of the generator function |
| 8 |
info: | |
| 9 |
1. Let G be ? OrdinaryCreateFromConstructor(functionObject, |
| 10 |
"%GeneratorPrototype%", « [[GeneratorState]], [[GeneratorContext]] »). |
| 11 |
[...] |
| 12 |
|
| 13 |
9.1.14 GetPrototypeFromConstructor |
| 14 |
|
| 15 |
[...] |
| 16 |
3. Let proto be ? Get(constructor, "prototype"). |
| 17 |
4. If Type(proto) is not Object, then |
| 18 |
a. Let realm be ? GetFunctionRealm(constructor). |
| 19 |
b. Let proto be realm's intrinsic object named intrinsicDefaultProto. |
| 20 |
[...] |
| 21 |
features: [generators, cross-realm] |
| 22 |
---*/ |
| 23 |
|
| 24 |
var other = $262.createRealm().global; |
| 25 |
var g = other.eval('(0, function*() {})'); |
| 26 |
var GeneratorPrototype = Object.getPrototypeOf(g.prototype); |
| 27 |
g.prototype = null; |
| 28 |
var instance; |
| 29 |
|
| 30 |
instance = g(); |
| 31 |
|
| 32 |
assert.sameValue(Object.getPrototypeOf(instance), GeneratorPrototype); |