Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch: align IDL testing with other standards
See whatwg/fetch#719.
- Loading branch information
Showing
5 changed files
with
115 additions
and
193 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// META: global=window,worker | ||
// META: script=/resources/WebIDLParser.js | ||
// META: script=/resources/idlharness.js | ||
|
||
promise_test(async() => { | ||
const text = await (await fetch("/interfaces/fetch.idl")).text(); | ||
const idl_array = new IdlArray(); | ||
idl_array.add_idls(text); | ||
idl_array.add_untested_idls("[Exposed=(Window,Worker)] interface AbortSignal {};"); | ||
idl_array.add_untested_idls("[Exposed=(Window,Worker)] interface ReadableStream {};"); | ||
idl_array.add_untested_idls("enum ReferrerPolicy {};"); | ||
idl_array.add_objects({ | ||
Headers: ["new Headers()"], | ||
Request: ["new Request('about:blank')"], | ||
Response: ["new Response()"], | ||
}); | ||
idl_array.test(); | ||
}, "Fetch Standard IDL"); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
typedef (sequence<sequence<ByteString>> or record<ByteString, ByteString>) HeadersInit; | ||
|
||
[Constructor(optional HeadersInit init), | ||
Exposed=(Window,Worker)] | ||
interface Headers { | ||
void append(ByteString name, ByteString value); | ||
void delete(ByteString name); | ||
ByteString? get(ByteString name); | ||
boolean has(ByteString name); | ||
void set(ByteString name, ByteString value); | ||
iterable<ByteString, ByteString>; | ||
}; | ||
typedef (Blob or BufferSource or FormData or URLSearchParams or ReadableStream or USVString) BodyInit; | ||
interface mixin Body { | ||
readonly attribute ReadableStream? body; | ||
readonly attribute boolean bodyUsed; | ||
[NewObject] Promise<ArrayBuffer> arrayBuffer(); | ||
[NewObject] Promise<Blob> blob(); | ||
[NewObject] Promise<FormData> formData(); | ||
[NewObject] Promise<any> json(); | ||
[NewObject] Promise<USVString> text(); | ||
}; | ||
typedef (Request or USVString) RequestInfo; | ||
|
||
[Constructor(RequestInfo input, optional RequestInit init), | ||
Exposed=(Window,Worker)] | ||
interface Request { | ||
readonly attribute ByteString method; | ||
readonly attribute USVString url; | ||
[SameObject] readonly attribute Headers headers; | ||
|
||
readonly attribute RequestDestination destination; | ||
readonly attribute USVString referrer; | ||
readonly attribute ReferrerPolicy referrerPolicy; | ||
readonly attribute RequestMode mode; | ||
readonly attribute RequestCredentials credentials; | ||
readonly attribute RequestCache cache; | ||
readonly attribute RequestRedirect redirect; | ||
readonly attribute DOMString integrity; | ||
readonly attribute boolean keepalive; | ||
readonly attribute boolean isReloadNavigation; | ||
readonly attribute AbortSignal signal; | ||
|
||
[NewObject] Request clone(); | ||
}; | ||
Request includes Body; | ||
|
||
dictionary RequestInit { | ||
ByteString method; | ||
HeadersInit headers; | ||
BodyInit? body; | ||
USVString referrer; | ||
ReferrerPolicy referrerPolicy; | ||
RequestMode mode; | ||
RequestCredentials credentials; | ||
RequestCache cache; | ||
RequestRedirect redirect; | ||
DOMString integrity; | ||
boolean keepalive; | ||
AbortSignal? signal; | ||
any window; // can only be set to null | ||
}; | ||
|
||
enum RequestDestination { "", "audio", "audioworklet", "document", "embed", "font", "image", "manifest", "object", "paintworklet", "report", "script", "sharedworker", "style", "track", "video", "worker", "xslt" }; | ||
enum RequestMode { "navigate", "same-origin", "no-cors", "cors" }; | ||
enum RequestCredentials { "omit", "same-origin", "include" }; | ||
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" }; | ||
enum RequestRedirect { "follow", "error", "manual" }; | ||
[Constructor(optional BodyInit? body = null, optional ResponseInit init), Exposed=(Window,Worker)] | ||
interface Response { | ||
[NewObject] static Response error(); | ||
[NewObject] static Response redirect(USVString url, optional unsigned short status = 302); | ||
|
||
readonly attribute ResponseType type; | ||
|
||
readonly attribute USVString url; | ||
readonly attribute boolean redirected; | ||
readonly attribute unsigned short status; | ||
readonly attribute boolean ok; | ||
readonly attribute ByteString statusText; | ||
[SameObject] readonly attribute Headers headers; | ||
readonly attribute Promise<Headers> trailer; | ||
|
||
[NewObject] Response clone(); | ||
}; | ||
Response includes Body; | ||
|
||
dictionary ResponseInit { | ||
unsigned short status = 200; | ||
ByteString statusText = "OK"; | ||
HeadersInit headers; | ||
}; | ||
|
||
enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" }; | ||
partial interface mixin WindowOrWorkerGlobalScope { | ||
[NewObject] Promise<Response> fetch(RequestInfo input, optional RequestInit init); | ||
}; |