summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/AsyncIterator/prototype/toArray/create-in-current-realm.js
blob: 6f0b69f8adf91a721fe3ab40efe13ff906ee5b69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) 

const otherGlobal = newGlobal({newCompartment: true});

async function* gen() {
  yield 1;
  yield 2;
  yield 3;
}

gen().toArray().then(array => {
  assertEq(array instanceof Array, true);
  assertEq(array instanceof otherGlobal.Array, false);
});

otherGlobal.AsyncIterator.prototype.toArray.call(gen()).then(array => {
  assertEq(array instanceof Array, false);
  assertEq(array instanceof otherGlobal.Array, true);
});

if (typeof reportCompare === 'function')
  reportCompare(0, 0);