mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Add test for shadow realms wrapped function behavior on throw
This commit is contained in:
parent
af00d69c39
commit
04cd6da021
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (C) 2021 Igalia SL. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-wrapped-function-exotic-objects-call-thisargument-argumentslist
|
||||||
|
description: >
|
||||||
|
WrappedFunction throws a TypeError if the wrapped function throws.
|
||||||
|
features: [ShadowRealm]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof ShadowRealm.prototype.evaluate,
|
||||||
|
'function',
|
||||||
|
'This test must fail if ShadowRealm.prototype.evaluate is not a function'
|
||||||
|
);
|
||||||
|
|
||||||
|
const r = new ShadowRealm();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
r.evaluate(`(f) => {
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof TypeError) {
|
||||||
|
return 'ok';
|
||||||
|
} else {
|
||||||
|
return e.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'normal exit';
|
||||||
|
}`)(() => { throw Error("ahh"); }),
|
||||||
|
'ok',
|
||||||
|
'WrappedFunction throws TypeError (from the calling realm) if the wrapped callable throws any exception'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
TypeError,
|
||||||
|
() => r.evaluate('() => { throw new Error("ahh"); }')(),
|
||||||
|
'WrappedFunction throws TypeError if the wrapped callable throws any exception'
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user