0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(op_crates/fetch): check fetch() argument length (#10474)

This commit is contained in:
Anonymous 2021-05-03 00:05:42 -07:00 committed by GitHub
parent ea917384fe
commit 688557e226
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -9,6 +9,16 @@ import {
} from "./test_util.ts";
import { Buffer } from "../../../test_util/std/io/buffer.ts";
unitTest(
{ perms: { net: true } },
async function fetchRequiresOneArgument(): Promise<void> {
await assertThrowsAsync(
fetch as unknown as () => Promise<void>,
TypeError,
);
},
);
unitTest({ perms: { net: true } }, async function fetchProtocolError(): Promise<
void
> {

View file

@ -273,6 +273,7 @@
*/
async function fetch(input, init = {}) {
const prefix = "Failed to call 'fetch'";
webidl.requiredArguments(arguments.length, 1, { prefix });
input = webidl.converters["RequestInfo"](input, {
prefix,
context: "Argument 1",

View file

@ -1014,7 +1014,6 @@
"Response interface: operation json()",
"Response interface: operation text()",
"Response interface: calling redirect(USVString, optional unsigned short) on new Response() with too few arguments must throw TypeError",
"Window interface: calling fetch(RequestInfo, optional RequestInit) on window with too few arguments must throw TypeError",
"Window interface: operation fetch(RequestInfo, optional RequestInit)"
]
},
@ -1101,4 +1100,4 @@
"set.any.js": true
}
}
}
}