Debian Codegraph @

js/src/tests/test262/built-ins/Iterator/proto-from-ctor-realm.js

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