mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00:00
fix(cli/rt): make some web API constructors illegal at runtime (#7468)
This commit is contained in:
parent
79e5b57663
commit
aaa5e6613a
9 changed files with 106 additions and 15 deletions
|
@ -9,6 +9,19 @@ function assertEquals(left, right) {
|
|||
assert(left === right);
|
||||
}
|
||||
|
||||
function assertThrows(fn) {
|
||||
let error = null;
|
||||
try {
|
||||
fn();
|
||||
} catch (error_) {
|
||||
error = error_;
|
||||
}
|
||||
if (error == null) {
|
||||
throw new Error("Didn't throw.");
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
function basicAbortController() {
|
||||
controller = new AbortController();
|
||||
assert(controller);
|
||||
|
@ -64,12 +77,19 @@ function controllerHasProperToString() {
|
|||
assertEquals(actual, "[object AbortController]");
|
||||
}
|
||||
|
||||
function abortSignalIllegalConstructor() {
|
||||
const error = assertThrows(() => new AbortSignal());
|
||||
assert(error instanceof TypeError);
|
||||
assertEquals(error.message, "Illegal constructor.");
|
||||
}
|
||||
|
||||
function main() {
|
||||
basicAbortController();
|
||||
signalCallsOnabort();
|
||||
signalEventListener();
|
||||
onlyAbortsOnce();
|
||||
controllerHasProperToString();
|
||||
abortSignalIllegalConstructor();
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue