mirror of https://github.com/tc39/test262.git
Add coverage on ShadowRealm.prototype.importValue onRejected
This commit is contained in:
parent
04cd6da021
commit
2000e858ff
4
test/built-ins/ShadowRealm/prototype/importValue/import-value_FIXTURE_syntax_error.js
vendored
Normal file
4
test/built-ins/ShadowRealm/prototype/importValue/import-value_FIXTURE_syntax_error.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
This is an invalid JavaScript Module file.
|
4
test/built-ins/ShadowRealm/prototype/importValue/import-value_FIXTURE_throws.js
vendored
Normal file
4
test/built-ins/ShadowRealm/prototype/importValue/import-value_FIXTURE_throws.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
throw new Error('foobar');
|
34
test/built-ins/ShadowRealm/prototype/importValue/throws-typeerror-import-syntax-error.js
vendored
Normal file
34
test/built-ins/ShadowRealm/prototype/importValue/throws-typeerror-import-syntax-error.js
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-realmimportvalue
|
||||||
|
description: >
|
||||||
|
ShadowRealm.prototype.importValue rejects with TypeError when the imported script unable to be parsed.
|
||||||
|
info: |
|
||||||
|
RealmImportValue ( specifierString, exportNameString, callerRealm, evalRealm, evalContext )
|
||||||
|
|
||||||
|
...
|
||||||
|
17. Return ! PerformPromiseThen(innerCapability.[[Promise]], onFulfilled, callerRealm.[[Intrinsics]].[[%ThrowTypeError%]], promiseCapability).
|
||||||
|
|
||||||
|
flags: [async, module]
|
||||||
|
features: [ShadowRealm]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof ShadowRealm.prototype.importValue,
|
||||||
|
'function',
|
||||||
|
'This test must fail if ShadowRealm.prototype.importValue is not a function'
|
||||||
|
);
|
||||||
|
|
||||||
|
const r = new ShadowRealm();
|
||||||
|
|
||||||
|
r.importValue('./import-value_FIXTURE_syntax_error.js', 'y')
|
||||||
|
.then(
|
||||||
|
() => {
|
||||||
|
throw "(unreachable)";
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
assert.sameValue(Object.getPrototypeOf(err), TypeError.prototype, 'should be rejected with TypeError');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then($DONE, $DONE);
|
34
test/built-ins/ShadowRealm/prototype/importValue/throws-typeerror-import-throws.js
vendored
Normal file
34
test/built-ins/ShadowRealm/prototype/importValue/throws-typeerror-import-throws.js
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-realmimportvalue
|
||||||
|
description: >
|
||||||
|
ShadowRealm.prototype.importValue rejects with TypeError when the imported script throws.
|
||||||
|
info: |
|
||||||
|
RealmImportValue ( specifierString, exportNameString, callerRealm, evalRealm, evalContext )
|
||||||
|
|
||||||
|
...
|
||||||
|
17. Return ! PerformPromiseThen(innerCapability.[[Promise]], onFulfilled, callerRealm.[[Intrinsics]].[[%ThrowTypeError%]], promiseCapability).
|
||||||
|
|
||||||
|
flags: [async, module]
|
||||||
|
features: [ShadowRealm]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof ShadowRealm.prototype.importValue,
|
||||||
|
'function',
|
||||||
|
'This test must fail if ShadowRealm.prototype.importValue is not a function'
|
||||||
|
);
|
||||||
|
|
||||||
|
const r = new ShadowRealm();
|
||||||
|
|
||||||
|
r.importValue('./import-value_FIXTURE_throws.js', 'y')
|
||||||
|
.then(
|
||||||
|
() => {
|
||||||
|
throw "(unreachable)";
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
assert.sameValue(Object.getPrototypeOf(err), TypeError.prototype, 'should be rejected with TypeError');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then($DONE, $DONE);
|
Loading…
Reference in New Issue