Bug 1459853 [wpt PR 10886] - ReadableStreamBytesConsumer should check read results, a=testonly

Automatic update from web-platform-testsReadableStreamBytesConsumer should check read results

ReadableStreamBytesConsumer expected that the results from
ReadableStreamReaderDefaultRead should be Promise<Object> because that
is provided from ReadableStream provided by blink, but it's possible to
inject arbitrary values with the promise assimilation.

This CL adds additional checks for such injection.

Bug: 840320
Change-Id: I7b3c6a8bfcf563dd860b133ff0295dd7a5d5fea5
Reviewed-on: https://chromium-review.googlesource.com/1049413
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556751}

--

wpt-commits: fc03b170c13c2377f852b35854682c573067d8d8
wpt-pr: 10886
This commit is contained in:
Yutaka Hirano 2018-05-10 18:53:54 +00:00 коммит произвёл moz-wptsync-bot
Родитель c6bbad4910
Коммит e1277119d7
2 изменённых файлов: 89 добавлений и 0 удалений

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

@ -331273,6 +331273,16 @@
{}
]
],
"fetch/api/response/response-stream-with-broken-then.any.js": [
[
"/fetch/api/response/response-stream-with-broken-then.any.html",
{}
],
[
"/fetch/api/response/response-stream-with-broken-then.any.worker.html",
{}
]
],
"fetch/api/response/response-trailer.html": [
[
"/fetch/api/response/response-trailer.html",
@ -560824,6 +560834,10 @@
"af3dcd2f8918b5c1365191490d127dcf2cc35cd9",
"testharness"
],
"fetch/api/response/response-stream-with-broken-then.any.js": [
"5fa2f4b55656018f60021a8060f0b7f5f8dcd503",
"testharness"
],
"fetch/api/response/response-trailer.html": [
"aba9a9168c083a18a85336948c1ba72ca827562f",
"testharness"

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

@ -0,0 +1,75 @@
// META: script=../resources/utils.js
promise_test(async () => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const bye = new TextEncoder().encode('bye');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled({done: false, value: bye});
};
const text = await resp.text();
assert_equals(text, 'bye', 'The valud should be replaced with "bye".');
}, 'Inject {done: false, value: bye} via Object.prototype.then.');
promise_test(async (t) => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled({done: false, value: undefined});
};
promise_rejects(t, TypeError(), resp.text(),
'The value should be replaced with undefined.');
}, 'Inject {done: false, value: undefined} via Object.prototype.then.');
promise_test(async (t) => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled(undefined);
};
promise_rejects(t, TypeError(), resp.text(),
'The read result should be replaced with undefined.');
}, 'Inject undefined via Object.prototype.then.');
promise_test(async (t) => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled(8.2);
};
promise_rejects(t, TypeError(), resp.text(),
'The read result should be replaced with a number.');
}, 'Inject 8.2 via Object.prototype.then.');