Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/fixtures/wpt/fetch/api/idlharness.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// META: global=window,worker
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long

idl_test(
['fetch'],
['referrer-policy', 'html', 'dom'],
idl_array => {
idl_array.add_objects({
Headers: ["new Headers()"],
Request: ["new Request('about:blank')"],
Response: ["new Response()"],
});
if (self.GLOBAL.isWindow()) {
idl_array.add_objects({ Window: ['window'] });
} else if (self.GLOBAL.isWorker()) {
idl_array.add_objects({ WorkerGlobalScope: ['self'] });
}
}
);
133 changes: 133 additions & 0 deletions test/fixtures/wpt/interfaces/fetch.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// GENERATED CONTENT - DO NOT EDIT
// Content was automatically extracted by Reffy into webref
// (https://github.com/w3c/webref)
// Source: Fetch Standard (https://fetch.spec.whatwg.org/)

typedef (sequence<sequence<ByteString>> or record<ByteString, ByteString>) HeadersInit;

[Exposed=(Window,Worker)]
interface Headers {
constructor(optional HeadersInit init);

undefined append(ByteString name, ByteString value);
undefined delete(ByteString name);
ByteString? get(ByteString name);
sequence<ByteString> getSetCookie();
boolean has(ByteString name);
undefined set(ByteString name, ByteString value);
iterable<ByteString, ByteString>;
};

typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) XMLHttpRequestBodyInit;

typedef (ReadableStream or XMLHttpRequestBodyInit) BodyInit;
interface mixin Body {
readonly attribute ReadableStream? body;
readonly attribute boolean bodyUsed;
[NewObject] Promise<ArrayBuffer> arrayBuffer();
[NewObject] Promise<Blob> blob();
[NewObject] Promise<Uint8Array> bytes();
[NewObject] Promise<FormData> formData();
[NewObject] Promise<any> json();
[NewObject] Promise<USVString> text();
[NewObject] ReadableStream textStream();
};
typedef (Request or USVString) RequestInfo;

[Exposed=(Window,Worker)]
interface Request {
constructor(RequestInfo input, optional RequestInit init = {});

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 boolean isHistoryNavigation;
readonly attribute AbortSignal signal;
readonly attribute RequestDuplex duplex;

[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;
RequestDuplex duplex;
RequestPriority priority;
any window; // can only be set to null
};

enum RequestDestination { "", "audio", "audioworklet", "document", "embed", "font", "frame", "iframe", "image", "json", "manifest", "object", "paintworklet", "report", "script", "sharedworker", "style", "text", "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" };
enum RequestDuplex { "half" };
enum RequestPriority { "high", "low", "auto" };

[Exposed=(Window,Worker)]
interface Response {
constructor(optional BodyInit? body = null, optional ResponseInit init = {});

[NewObject] static Response error();
[NewObject] static Response redirect(USVString url, optional unsigned short status = 302);
[NewObject] static Response json(any data, optional ResponseInit init = {});

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;

[NewObject] Response clone();
};
Response includes Body;

dictionary ResponseInit {
unsigned short status = 200;
ByteString statusText = "";
HeadersInit headers;
};

enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" };

partial interface mixin WindowOrWorkerGlobalScope {
[NewObject] Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
};

dictionary DeferredRequestInit : RequestInit {
DOMHighResTimeStamp activateAfter;
};

[Exposed=Window]
interface FetchLaterResult {
readonly attribute boolean activated;
};

partial interface Window {
[NewObject, SecureContext] FetchLaterResult fetchLater(RequestInfo input, optional DeferredRequestInit init = {});
};
16 changes: 16 additions & 0 deletions test/fixtures/wpt/interfaces/referrer-policy.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// GENERATED CONTENT - DO NOT EDIT
// Content was automatically extracted by Reffy into webref
// (https://github.com/w3c/webref)
// Source: Referrer Policy (https://w3c.github.io/webappsec-referrer-policy/)

enum ReferrerPolicy {
"",
"no-referrer",
"no-referrer-when-downgrade",
"same-origin",
"origin",
"strict-origin",
"origin-when-cross-origin",
"strict-origin-when-cross-origin",
"unsafe-url"
};
4 changes: 4 additions & 0 deletions test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"commit": "1ac8deee082ecfb5d3b6f9c56cf9d1688a2fc218",
"path": "encoding"
},
"fetch/api": {
"commit": "3f15e5c09448b8e917c9128d3b07cc78f044c83a",
"path": "fetch/api"
},
"fetch/data-urls/resources": {
"commit": "7c79d998ff42e52de90290cb847d1b515b3b58f7",
"path": "fetch/data-urls/resources"
Expand Down
25 changes: 25 additions & 0 deletions test/wpt/status/fetch/api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"idlharness.https.any.html": {
"fail": {
"note": "fetchLater() and FetchLaterResult are not implemented",
"expected": [
"FetchLaterResult interface: existence and properties of interface object",
"FetchLaterResult interface object length",
"FetchLaterResult interface object name",
"FetchLaterResult interface: existence and properties of interface prototype object",
"FetchLaterResult interface: existence and properties of interface prototype object's \"constructor\" property",
"FetchLaterResult interface: existence and properties of interface prototype object's @@unscopables property",
"FetchLaterResult interface: attribute activated",
"Window interface: operation fetchLater(RequestInfo, optional DeferredRequestInit)"
]
}
},
"idlharness.https.any.worker.html": {
"fail": {
"note": "fetch is an own property of the worker global, not of WorkerGlobalScope.prototype",
"expected": [
"WorkerGlobalScope interface: operation fetch(RequestInfo, optional RequestInit)"
]
}
}
}
13 changes: 13 additions & 0 deletions test/wpt/test-fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

const { WPTRunner } = require('../common/wpt');

const runner = new WPTRunner('fetch/api');

runner.pretendGlobalThisAs('Window');
// The window harness does not define GLOBAL.isWorker(). The idlharness
// setup calls it when isWindow() is false.
runner.setInitScript(
'globalThis.GLOBAL.isWorker = function() { return false; };',
);
runner.runJsTests();
Loading