Bug 1485601 [wpt PR 12639] - Fetch/XHR/Beacon: test locked/disturbed ReadableStream, a=testonly

Automatic update from web-platform-testsFetch/XHR/Beacon: test locked/disturbed ReadableStream

See https://github.com/whatwg/fetch/pull/801 for context.
--

wpt-commits: aecdb30fdb5bb87179aa572cbf3d3f33db69f89e
wpt-pr: 12639
This commit is contained in:
Anne van Kesteren 2018-08-24 13:07:57 +00:00 коммит произвёл moz-wptsync-bot
Родитель 7d6b843889
Коммит b23356fc01
5 изменённых файлов: 176 добавлений и 0 удалений

Просмотреть файл

@ -323544,6 +323544,12 @@
}
]
],
"beacon/beacon-readablestream.window.js": [
[
"/beacon/beacon-readablestream.window.html",
{}
]
],
"beacon/beacon-redirect.window.js": [
[
"/beacon/beacon-redirect.window.html",
@ -352264,6 +352270,24 @@
{}
]
],
"fetch/api/request/request-init-stream.any.js": [
[
"/fetch/api/request/request-init-stream.any.html",
{}
],
[
"/fetch/api/request/request-init-stream.any.serviceworker.html",
{}
],
[
"/fetch/api/request/request-init-stream.any.sharedworker.html",
{}
],
[
"/fetch/api/request/request-init-stream.any.worker.html",
{}
]
],
"fetch/api/request/request-keepalive-quota.html": [
[
"/fetch/api/request/request-keepalive-quota.html?include=fast",
@ -352360,6 +352384,24 @@
{}
]
],
"fetch/api/response/response-from-stream.any.js": [
[
"/fetch/api/response/response-from-stream.any.html",
{}
],
[
"/fetch/api/response/response-from-stream.any.serviceworker.html",
{}
],
[
"/fetch/api/response/response-from-stream.any.sharedworker.html",
{}
],
[
"/fetch/api/response/response-from-stream.any.worker.html",
{}
]
],
"fetch/api/response/response-init-001.html": [
[
"/fetch/api/response/response-init-001.html",
@ -403654,6 +403696,20 @@
{}
]
],
"xhr/send-data-readablestream.any.js": [
[
"/xhr/send-data-readablestream.any.html",
{}
],
[
"/xhr/send-data-readablestream.any.sharedworker.html",
{}
],
[
"/xhr/send-data-readablestream.any.worker.html",
{}
]
],
"xhr/send-data-unexpected-tostring.htm": [
[
"/xhr/send-data-unexpected-tostring.htm",
@ -433971,6 +434027,10 @@
"5df13905978dad65dea1f42606317897061d4aa4",
"testharness"
],
"beacon/beacon-readablestream.window.js": [
"fc7f81f884bdf47b6eb76f6d9b237bc38556efa4",
"testharness"
],
"beacon/beacon-redirect.window.js": [
"659759baa3f5c58b26b9ed042047348b67a23e44",
"testharness"
@ -587155,6 +587215,10 @@
"79c91cdfe82af4723707822be204b32941a118ca",
"testharness"
],
"fetch/api/request/request-init-stream.any.js": [
"22e3f41bc2d8a38dd097e61145e213e3febbd108",
"testharness"
],
"fetch/api/request/request-keepalive-quota.html": [
"f71b1b2996a388367a4c89d7613f788f57376c4a",
"testharness"
@ -587339,6 +587403,10 @@
"1e68f6d01c6c763fa46427e31c6f1229ed000ccc",
"testharness"
],
"fetch/api/response/response-from-stream.any.js": [
"93b29b42867f47f4472c6820ff9d4a1a343e84cf",
"testharness"
],
"fetch/api/response/response-init-001.html": [
"cd89448bbbef388e69a2ef4b2aecf04bafb728f2",
"testharness"
@ -657967,6 +658035,10 @@
"9456aa77c53585f0c13bac628770521428e6022a",
"testharness"
],
"xhr/send-data-readablestream.any.js": [
"cca6e76a042cc8a5b55e1ead306ddaf9467b8c09",
"testharness"
],
"xhr/send-data-unexpected-tostring.htm": [
"b8a3b4ae6902357cfe392c484e8413bff1729061",
"testharness"

Просмотреть файл

@ -0,0 +1,3 @@
test(() => {
assert_throws(new TypeError(), () => navigator.sendBeacon("...", new ReadableStream()));
}, "sendBeacon() with a stream does not work due to the keepalive flag being set");

Просмотреть файл

@ -0,0 +1,51 @@
// META: global=window,worker
"use strict";
async function assert_request(input, init) {
assert_throws(new TypeError(), () => new Request(input, init), "new Request()");
assert_throws(new TypeError(), async () => await fetch(input, init), "fetch()");
}
promise_test(async () => {
const stream = new ReadableStream();
stream.getReader();
await assert_request("...", { method:"POST", body: stream });
}, "Constructing a Request with a stream on which getReader() is called");
promise_test(async () => {
const stream = new ReadableStream();
stream.getReader().read();
await assert_request("...", { method:"POST", body: stream });
}, "Constructing a Request with a stream on which read() is called");
promise_test(async () => {
const stream = new ReadableStream({ pull: c => c.enqueue(new Uint8Array()) }),
reader = stream.getReader();
await reader.read();
reader.releaseLock();
await assert_request("...", { method:"POST", body: stream });
}, "Constructing a Request with a stream on which read() and releaseLock() are called");
promise_test(async () => {
const request = new Request("...", { method: "POST", body: "..." });
request.body.getReader();
await assert_request(request);
assert_class_string(new Request(request, { body: "..." }), "Request");
}, "Constructing a Request with a Request on which body.getReader() is called");
promise_test(async () => {
const request = new Request("...", { method: "POST", body: "..." });
request.body.getReader().read();
await assert_request(request);
assert_class_string(new Request(request, { body: "..." }), "Request");
}, "Constructing a Request with a Request on which body.getReader().read() is called");
promise_test(async () => {
const request = new Request("...", { method: "POST", body: "..." }),
reader = request.body.getReader();
await reader.read();
reader.releaseLock();
await assert_request(request);
assert_class_string(new Request(request, { body: "..." }), "Request");
}, "Constructing a Request with a Request on which read() and releaseLock() are called");

Просмотреть файл

@ -0,0 +1,23 @@
// META: global=window,worker
"use strict";
test(() => {
const stream = new ReadableStream();
stream.getReader();
assert_throws(new TypeError(), () => new Response(stream));
}, "Constructing a Response with a stream on which getReader() is called");
test(() => {
const stream = new ReadableStream();
stream.getReader().read();
assert_throws(new TypeError(), () => new Response(stream));
}, "Constructing a Response with a stream on which read() is called");
promise_test(async () => {
const stream = new ReadableStream({ pull: c => c.enqueue(new Uint8Array()) }),
reader = stream.getReader();
await reader.read();
reader.releaseLock();
assert_throws(new TypeError(), () => new Response(stream));
}, "Constructing a Response with a stream on which read() and releaseLock() are called");

Просмотреть файл

@ -0,0 +1,27 @@
// META: global=window,dedicatedworker,sharedworker
function assert_xhr(stream) {
const client = new XMLHttpRequest();
client.open("POST", "...");
assert_throws(new TypeError(), () => client.send(stream));
}
test(() => {
const stream = new ReadableStream();
stream.getReader();
assert_xhr(stream);
}, "XMLHttpRequest: send() with a stream on which getReader() is called");
test(() => {
const stream = new ReadableStream();
stream.getReader().read();
assert_xhr(stream);
}, "XMLHttpRequest: send() with a stream on which read() is called");
promise_test(async () => {
const stream = new ReadableStream({ pull: c => c.enqueue(new Uint8Array()) }),
reader = stream.getReader();
await reader.read();
reader.releaseLock();
assert_xhr(stream);
}, "XMLHttpRequest: send() with a stream on which read() and releaseLock() are called");