mirror of
https://github.com/servo/servo.git
synced 2025-09-12 07:58:20 +01:00
Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444
This commit is contained in:
parent
25e8bf69e6
commit
665817d2a6
35333 changed files with 1818077 additions and 16036 deletions
|
@ -424,4 +424,38 @@ promise_test(() => {
|
|||
|
||||
}, 'Closing must be propagated forward: shutdown must not occur until the final write completes');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
const rs = recordingReadableStream();
|
||||
|
||||
let resolveWritePromise;
|
||||
const ws = recordingWritableStream({
|
||||
write() {
|
||||
return new Promise(resolve => {
|
||||
resolveWritePromise = resolve;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let pipeComplete = false;
|
||||
const pipePromise = rs.pipeTo(ws, { preventClose: true }).then(() => {
|
||||
pipeComplete = true;
|
||||
});
|
||||
|
||||
rs.controller.enqueue('a');
|
||||
rs.controller.close();
|
||||
|
||||
// Flush async events and verify that no shutdown occurs.
|
||||
return flushAsyncEvents().then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a'],
|
||||
'the chunk must have been written, but close must not have happened yet');
|
||||
assert_equals(pipeComplete, false, 'the pipe must not be complete');
|
||||
|
||||
resolveWritePromise();
|
||||
|
||||
return pipePromise;
|
||||
});
|
||||
|
||||
}, 'Closing must be propagated forward: shutdown must not occur until the final write completes; preventClose = true');
|
||||
|
||||
done();
|
||||
|
|
|
@ -124,6 +124,52 @@ promise_test(() => {
|
|||
}, 'Piping from an empty ReadableStream into a WritableStream that does not desire chunks, but then the readable ' +
|
||||
'stream becomes non-empty and the writable stream starts desiring chunks');
|
||||
|
||||
promise_test(() => {
|
||||
const unreadChunks = ['b', 'c', 'd'];
|
||||
|
||||
const rs = recordingReadableStream({
|
||||
pull(controller) {
|
||||
controller.enqueue(unreadChunks.shift());
|
||||
if (unreadChunks.length === 0) {
|
||||
controller.close();
|
||||
}
|
||||
}
|
||||
}, new CountQueuingStrategy({ highWaterMark: 0 }));
|
||||
|
||||
let resolveWritePromise;
|
||||
const ws = recordingWritableStream({
|
||||
write() {
|
||||
if (!resolveWritePromise) {
|
||||
// first write
|
||||
return new Promise(resolve => {
|
||||
resolveWritePromise = resolve;
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}, new CountQueuingStrategy({ highWaterMark: 3 }));
|
||||
|
||||
const writer = ws.getWriter();
|
||||
const firstWritePromise = writer.write('a');
|
||||
assert_equals(writer.desiredSize, 2, 'after writing the writer\'s desiredSize must be 2');
|
||||
writer.releaseLock();
|
||||
|
||||
// firstWritePromise won't settle until we call resolveWritePromise.
|
||||
|
||||
const pipePromise = rs.pipeTo(ws);
|
||||
|
||||
return flushAsyncEvents().then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a']);
|
||||
assert_equals(unreadChunks.length, 1, 'chunks should continue to be enqueued until the HWM is reached');
|
||||
}).then(() => resolveWritePromise())
|
||||
.then(() => Promise.all([firstWritePromise, pipePromise]))
|
||||
.then(() => {
|
||||
assert_array_equals(rs.events, ['pull', 'pull', 'pull']);
|
||||
assert_array_equals(ws.events, ['write', 'a', 'write', 'b','write', 'c','write', 'd', 'close']);
|
||||
});
|
||||
|
||||
}, 'Piping from a ReadableStream to a WritableStream that desires more chunks before finishing with previous ones');
|
||||
|
||||
promise_test(() => {
|
||||
|
||||
const desiredSizes = [];
|
||||
|
|
|
@ -155,7 +155,7 @@ promise_test(() => {
|
|||
}, 'Piping from a ReadableStream for which a chunk becomes asynchronously readable after the pipeTo');
|
||||
|
||||
for (const preventAbort of [true, false]) {
|
||||
promise_test(t => {
|
||||
promise_test(() => {
|
||||
|
||||
const rs = new ReadableStream({
|
||||
pull() {
|
||||
|
@ -171,7 +171,7 @@ for (const preventAbort of [true, false]) {
|
|||
}
|
||||
|
||||
for (const preventCancel of [true, false]) {
|
||||
promise_test(t => {
|
||||
promise_test(() => {
|
||||
|
||||
const rs = new ReadableStream({
|
||||
pull(controller) {
|
||||
|
|
|
@ -71,19 +71,48 @@ promise_test(t => {
|
|||
});
|
||||
const ws = recordingWritableStream();
|
||||
const writer = ws.getWriter();
|
||||
writer.close();
|
||||
const closePromise = writer.close();
|
||||
writer.releaseLock();
|
||||
|
||||
return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the readable stream\'s error').then(() => {
|
||||
assert_array_equals(rs.events, []);
|
||||
assert_array_equals(ws.events, ['close']);
|
||||
assert_array_equals(ws.events, ['abort', error1]);
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1'),
|
||||
ws.getWriter().closed
|
||||
promise_rejects(t, new TypeError(), ws.getWriter().closed,
|
||||
'closed must reject with a TypeError indicating the writable stream was aborted'),
|
||||
promise_rejects(t, new TypeError(), closePromise,
|
||||
'close() must reject with a TypeError indicating the writable stream was aborted'),
|
||||
]);
|
||||
});
|
||||
|
||||
}, 'Piping from an errored readable stream to a closing writable stream');
|
||||
|
||||
promise_test(t => {
|
||||
const rs = recordingReadableStream({
|
||||
start(c) {
|
||||
c.error(error1);
|
||||
}
|
||||
});
|
||||
const ws = recordingWritableStream();
|
||||
const writer = ws.getWriter();
|
||||
const closePromise = writer.close();
|
||||
writer.releaseLock();
|
||||
|
||||
return flushAsyncEvents().then(() => {
|
||||
return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the readable stream\'s error').then(() => {
|
||||
assert_array_equals(rs.events, []);
|
||||
assert_array_equals(ws.events, ['close']);
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1'),
|
||||
ws.getWriter().closed,
|
||||
closePromise
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
}, 'Piping from an errored readable stream to a closed writable stream');
|
||||
|
||||
promise_test(t => {
|
||||
|
|
|
@ -37,7 +37,7 @@ promise_test(() => {
|
|||
assert_array_equals(chunks, [1, 2, 3, 4, 5]), 'chunks should match');
|
||||
}, 'Piping through a duck-typed pass-through transform stream should work');
|
||||
|
||||
promise_test(t => {
|
||||
promise_test(() => {
|
||||
const transform = {
|
||||
writable: new WritableStream({
|
||||
start(c) {
|
||||
|
@ -77,7 +77,7 @@ test(() => {
|
|||
|
||||
test(() => {
|
||||
const dummy = {
|
||||
pipeTo(args) {
|
||||
pipeTo() {
|
||||
return { not: 'a promise' };
|
||||
}
|
||||
};
|
||||
|
@ -90,7 +90,7 @@ test(() => {
|
|||
|
||||
test(() => {
|
||||
const dummy = {
|
||||
pipeTo(args) {
|
||||
pipeTo() {
|
||||
return {
|
||||
then() {},
|
||||
this: 'is not a real promise'
|
||||
|
@ -104,4 +104,44 @@ test(() => {
|
|||
|
||||
}, 'pipeThrough can handle calling a pipeTo that returns a non-promise thenable object');
|
||||
|
||||
promise_test(() => {
|
||||
const dummy = {
|
||||
pipeTo() {
|
||||
return Promise.reject(new Error('this rejection should not be reported as unhandled'));
|
||||
}
|
||||
};
|
||||
|
||||
ReadableStream.prototype.pipeThrough.call(dummy, { });
|
||||
|
||||
// The test harness should complain about unhandled rejections by then.
|
||||
return flushAsyncEvents();
|
||||
|
||||
}, 'pipeThrough should mark a real promise from a fake readable as handled');
|
||||
|
||||
test(() => {
|
||||
let thenCalled = false
|
||||
let catchCalled = false;
|
||||
const dummy = {
|
||||
pipeTo() {
|
||||
const fakePromise = Object.create(Promise.prototype);
|
||||
fakePromise.then = () => {
|
||||
thenCalled = true;
|
||||
};
|
||||
fakePromise.catch = () => {
|
||||
catchCalled = true;
|
||||
};
|
||||
assert_true(fakePromise instanceof Promise, 'fakePromise fools instanceof');
|
||||
return fakePromise;
|
||||
}
|
||||
};
|
||||
|
||||
// An incorrect implementation which uses an internal method to mark the promise as handled will throw or crash here.
|
||||
ReadableStream.prototype.pipeThrough.call(dummy, { });
|
||||
|
||||
// An incorrect implementation that tries to mark the promise as handled by calling .then() or .catch() on the object
|
||||
// will fail these tests.
|
||||
assert_false(thenCalled, 'then should not be called');
|
||||
assert_false(catchCalled, 'catch should not be called');
|
||||
}, 'pipeThrough should not be fooled by an object whose instanceof Promise returns true');
|
||||
|
||||
done();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue