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

const otherGlobal = newGlobal({newCompartment: true});
assertEq(TypeError !== otherGlobal.TypeError, true);

async function *gen() {}

gen().every().then(() => assertEq(true, false, 'expected error'), err => {
  assertEq(err instanceof TypeError, true);
});

otherGlobal.AsyncIterator.prototype.every.call(gen()).then(() => assertEq(true, false, 'expected error'), err => {
  assertEq(
    err instanceof otherGlobal.TypeError,
    true,
    'TypeError comes from the realm of the method.',
  );
});

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