mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 08:39:09 -05:00
chore: align some Web API type definitions to lib.dom.d.ts (#15219)
This commit is contained in:
parent
b8e1250500
commit
27a72a12b7
7 changed files with 44 additions and 5 deletions
|
@ -818,6 +818,14 @@ Deno.test(function responseRedirect() {
|
|||
assertEquals(redir.type, "default");
|
||||
});
|
||||
|
||||
Deno.test(function responseRedirectTakeURLObjectAsParameter() {
|
||||
const redir = Response.redirect(new URL("https://example.com/"));
|
||||
assertEquals(
|
||||
redir.headers.get("Location"),
|
||||
"https://example.com/",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test(async function responseWithoutBody() {
|
||||
const response = new Response();
|
||||
assertEquals(await response.arrayBuffer(), new ArrayBuffer(0));
|
||||
|
|
|
@ -68,3 +68,10 @@ Deno.test(function customInspectFunction() {
|
|||
);
|
||||
assertStringIncludes(Deno.inspect(Request.prototype), "Request");
|
||||
});
|
||||
|
||||
Deno.test(function requestConstructorTakeURLObjectAsParameter() {
|
||||
assertEquals(
|
||||
new Request(new URL("http://foo/")).url,
|
||||
"http://foo/",
|
||||
);
|
||||
});
|
||||
|
|
|
@ -494,3 +494,15 @@ Deno.test(function urlSearchParamsIdentityPreserved() {
|
|||
const sp2 = u.searchParams;
|
||||
assertStrictEquals(sp1, sp2);
|
||||
});
|
||||
|
||||
Deno.test(function urlTakeURLObjectAsParameter() {
|
||||
const url = new URL(
|
||||
new URL(
|
||||
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat",
|
||||
),
|
||||
);
|
||||
assertEquals(
|
||||
url.href,
|
||||
"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat",
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
import { assertThrows } from "./test_util.ts";
|
||||
import { assertEquals, assertThrows, deferred, fail } from "./test_util.ts";
|
||||
|
||||
Deno.test({ permissions: "none" }, function websocketPermissionless() {
|
||||
assertThrows(
|
||||
|
@ -7,3 +7,15 @@ Deno.test({ permissions: "none" }, function websocketPermissionless() {
|
|||
Deno.errors.PermissionDenied,
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test(async function websocketConstructorTakeURLObjectAsParameter() {
|
||||
const promise = deferred();
|
||||
const ws = new WebSocket(new URL("ws://localhost:4242/"));
|
||||
assertEquals(ws.url, "ws://localhost:4242/");
|
||||
ws.onerror = () => fail();
|
||||
ws.onopen = () => ws.close();
|
||||
ws.onclose = () => {
|
||||
promise.resolve();
|
||||
};
|
||||
await promise;
|
||||
});
|
||||
|
|
4
ext/fetch/lib.deno_fetch.d.ts
vendored
4
ext/fetch/lib.deno_fetch.d.ts
vendored
|
@ -252,7 +252,7 @@ interface RequestInit {
|
|||
|
||||
/** This Fetch API interface represents a resource request. */
|
||||
declare class Request implements Body {
|
||||
constructor(input: RequestInfo, init?: RequestInit);
|
||||
constructor(input: RequestInfo | URL, init?: RequestInit);
|
||||
|
||||
/**
|
||||
* Returns the cache mode associated with request, which is a string
|
||||
|
@ -385,7 +385,7 @@ declare class Response implements Body {
|
|||
constructor(body?: BodyInit | null, init?: ResponseInit);
|
||||
static json(data: unknown, init?: ResponseInit): Response;
|
||||
static error(): Response;
|
||||
static redirect(url: string, status?: number): Response;
|
||||
static redirect(url: string | URL, status?: number): Response;
|
||||
|
||||
readonly headers: Headers;
|
||||
readonly ok: boolean;
|
||||
|
|
2
ext/url/lib.deno_url.d.ts
vendored
2
ext/url/lib.deno_url.d.ts
vendored
|
@ -153,7 +153,7 @@ declare class URLSearchParams {
|
|||
|
||||
/** The URL interface represents an object providing static methods used for creating object URLs. */
|
||||
declare class URL {
|
||||
constructor(url: string, base?: string | URL);
|
||||
constructor(url: string | URL, base?: string | URL);
|
||||
static createObjectURL(blob: Blob): string;
|
||||
static revokeObjectURL(url: string): void;
|
||||
|
||||
|
|
2
ext/websocket/lib.deno_websocket.d.ts
vendored
2
ext/websocket/lib.deno_websocket.d.ts
vendored
|
@ -40,7 +40,7 @@ interface WebSocketEventMap {
|
|||
* If you are looking to create a WebSocket server, please take a look at `Deno.upgradeWebSocket()`.
|
||||
*/
|
||||
declare class WebSocket extends EventTarget {
|
||||
constructor(url: string, protocols?: string | string[]);
|
||||
constructor(url: string | URL, protocols?: string | string[]);
|
||||
|
||||
static readonly CLOSED: number;
|
||||
static readonly CLOSING: number;
|
||||
|
|
Loading…
Reference in a new issue