proto-from-ctor-realm.js (1309B)
1 // Copyright (C) 2020 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-iterator 6 description: Default [[Prototype]] value derived from realm of the NewTarget. 7 features: [cross-realm, iterator-helpers, Reflect, Symbol] 8 ---*/ 9 10 let other = $262.createRealm().global; 11 let newTarget = new other.Function(); 12 let ai; 13 14 newTarget.prototype = undefined; 15 ai = Reflect.construct(Iterator, [1], newTarget); 16 assert.sameValue(Object.getPrototypeOf(ai), other.Iterator.prototype); 17 18 newTarget.prototype = null; 19 ai = Reflect.construct(Iterator, [1], newTarget); 20 assert.sameValue(Object.getPrototypeOf(ai), other.Iterator.prototype); 21 22 newTarget.prototype = true; 23 ai = Reflect.construct(Iterator, [1], newTarget); 24 assert.sameValue(Object.getPrototypeOf(ai), other.Iterator.prototype); 25 26 newTarget.prototype = ''; 27 ai = Reflect.construct(Iterator, [1], newTarget); 28 assert.sameValue(Object.getPrototypeOf(ai), other.Iterator.prototype); 29 30 newTarget.prototype = Symbol(); 31 ai = Reflect.construct(Iterator, [1], newTarget); 32 assert.sameValue(Object.getPrototypeOf(ai), other.Iterator.prototype); 33 34 newTarget.prototype = 0; 35 ai = Reflect.construct(Iterator, [1], newTarget); 36 assert.sameValue(Object.getPrototypeOf(ai), other.Iterator.prototype); 37 38 reportCompare(0, 0);