mirror of
https://github.com/servo/servo.git
synced 2025-08-17 03:15:34 +01:00
Update web-platform-tests to revision 83b0a62af874eaf20e9d97d2fb9e15e91f3d109f
This commit is contained in:
parent
95f9e14e67
commit
3f33c72bb4
193 changed files with 1605 additions and 458 deletions
|
@ -548,7 +548,7 @@ promise_test(() => {
|
|||
return rs.pipeTo(ws).then(
|
||||
() => assert_unreached('the promise must not fulfill'),
|
||||
err => {
|
||||
assert_equals(err.name, 'TypeError', 'the promise must reject with a TypeError (_not_ with error1)');
|
||||
assert_equals(err, error1, 'the promise must reject with error1');
|
||||
|
||||
assert_array_equals(rs.eventsWithoutPulls, ['cancel', err]);
|
||||
assert_array_equals(ws.events, ['abort', error1]);
|
||||
|
@ -575,7 +575,7 @@ promise_test(t => {
|
|||
return ws.getWriter().closed.then(
|
||||
() => assert_unreached('the promise must not fulfill'),
|
||||
err => {
|
||||
assert_equals(err.name, 'TypeError', 'the promise must reject with a TypeError (_not_ with error1)');
|
||||
assert_equals(err, error1, 'the promise must reject with error1');
|
||||
|
||||
assert_array_equals(rs.eventsWithoutPulls, ['cancel', err]);
|
||||
assert_array_equals(ws.events, ['abort', error1]);
|
||||
|
@ -594,7 +594,7 @@ promise_test(t => {
|
|||
|
||||
ws.abort(error1);
|
||||
|
||||
return promise_rejects(t, new TypeError(), rs.pipeTo(ws, { preventCancel: true })).then(() => {
|
||||
return promise_rejects(t, error1, rs.pipeTo(ws, { preventCancel: true })).then(() => {
|
||||
assert_array_equals(rs.eventsWithoutPulls, []);
|
||||
assert_array_equals(ws.events, ['abort', error1]);
|
||||
});
|
||||
|
|
|
@ -80,10 +80,10 @@ promise_test(t => {
|
|||
|
||||
return Promise.all([
|
||||
promise_rejects(t, error1, rs.getReader().closed, 'the readable stream must be errored with error1'),
|
||||
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'),
|
||||
promise_rejects(t, error1, ws.getWriter().closed,
|
||||
'closed must reject with error1'),
|
||||
promise_rejects(t, error1, closePromise,
|
||||
'close() must reject with error1')
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
abortPromise,
|
||||
cancelPromise,
|
||||
promise_rejects(t, new TypeError(), writer.closed, 'writer.closed should reject with a TypeError')]);
|
||||
promise_rejects(t, thrownError, writer.closed, 'writer.closed should reject with thrownError')]);
|
||||
}, 'abort should set the close reason for the writable when it happens before cancel during start, but cancel should ' +
|
||||
'still succeed');
|
||||
|
||||
|
@ -229,7 +229,7 @@ promise_test(t => {
|
|||
writePromise,
|
||||
abortPromise,
|
||||
cancelPromise,
|
||||
promise_rejects(t, new TypeError(), writer.closed, 'writer.closed should reject with a TypeError')]);
|
||||
promise_rejects(t, thrownError, writer.closed, 'writer.closed should reject with thrownError')]);
|
||||
});
|
||||
}, 'abort should set the close reason for the writable when it happens before cancel during underlying sink write, ' +
|
||||
'but cancel should still succeed');
|
||||
|
@ -269,9 +269,9 @@ promise_test(t => {
|
|||
controller = c;
|
||||
}
|
||||
});
|
||||
return ts.writable.abort().then(() => {
|
||||
return ts.writable.abort(thrownError).then(() => {
|
||||
controller.error(ignoredError);
|
||||
return promise_rejects(t, new TypeError(), ts.writable.getWriter().closed, 'closed should reject with a TypeError');
|
||||
return promise_rejects(t, thrownError, ts.writable.getWriter().closed, 'closed should reject with thrownError');
|
||||
});
|
||||
}, 'controller.error() should do nothing after writable.abort() has completed');
|
||||
|
||||
|
@ -325,15 +325,22 @@ promise_test(t => {
|
|||
// write should start synchronously
|
||||
const writePromise = writer.write(0);
|
||||
// The underlying sink's abort() is not called until the write() completes.
|
||||
const abortPromise = writer.abort();
|
||||
const abortPromise = writer.abort(thrownError);
|
||||
// Perform a read to relieve backpressure and permit the write() to complete.
|
||||
const readPromise = ts.readable.getReader().read();
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), readPromise, 'read() should reject'),
|
||||
promise_rejects(t, new TypeError(), writePromise, 'write() should reject'),
|
||||
promise_rejects(t, thrownError, readPromise, 'read() should reject'),
|
||||
promise_rejects(t, thrownError, writePromise, 'write() should reject'),
|
||||
abortPromise
|
||||
]);
|
||||
});
|
||||
}, 'a write() that was waiting for backpressure should reject if the writable is aborted');
|
||||
|
||||
promise_test(t => {
|
||||
const ts = new TransformStream();
|
||||
ts.writable.abort(thrownError);
|
||||
const reader = ts.readable.getReader();
|
||||
return promise_rejects(t, thrownError, reader.read(), 'read() should reject with thrownError');
|
||||
}, 'the readable should be errored with the reason passed to the writable abort() method');
|
||||
|
||||
done();
|
||||
|
|
|
@ -317,7 +317,7 @@ promise_test(t => {
|
|||
// call to TransformStreamDefaultSink.
|
||||
return delay(0).then(() => {
|
||||
controller.enqueue('a');
|
||||
return Promise.all([promise_rejects(t, new TypeError(), reader.read(), 'read() should reject'), abortPromise]);
|
||||
return Promise.all([promise_rejects(t, error1, reader.read(), 'read() should reject'), abortPromise]);
|
||||
});
|
||||
}, 'writer.abort() inside size() should work');
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ promise_test(t => {
|
|||
assert_equals(writer.ready, readyPromise, 'the ready promise property should not change');
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), readyPromise, 'the ready promise should reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writePromise, 'the write() promise should reject with a TypeError')
|
||||
promise_rejects(t, error1, readyPromise, 'the ready promise should reject with error1'),
|
||||
promise_rejects(t, error1, writePromise, 'the write() promise should reject with error1')
|
||||
]);
|
||||
}, 'Aborting a WritableStream before it starts should cause the writer\'s unsettled ready promise to reject');
|
||||
|
||||
|
@ -44,7 +44,7 @@ promise_test(t => {
|
|||
writer.abort(error1);
|
||||
|
||||
assert_not_equals(writer.ready, readyPromise, 'the ready promise property should change');
|
||||
return promise_rejects(t, new TypeError(), writer.ready, 'the ready promise should reject with a TypeError');
|
||||
return promise_rejects(t, error1, writer.ready, 'the ready promise should reject with error1');
|
||||
});
|
||||
}, 'Aborting a WritableStream should cause the writer\'s fulfilled ready promise to reset to a rejected one');
|
||||
|
||||
|
@ -64,16 +64,16 @@ promise_test(t => {
|
|||
.then(() => {
|
||||
const writer = ws.getWriter();
|
||||
|
||||
const abortPromise = writer.abort();
|
||||
const abortPromise = writer.abort(error1);
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writer.write(1), 'write(1) must reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writer.write(2), 'write(2) must reject with a TypeError'),
|
||||
promise_rejects(t, error1, writer.write(1), 'write(1) must reject with error1'),
|
||||
promise_rejects(t, error1, writer.write(2), 'write(2) must reject with error1'),
|
||||
abortPromise
|
||||
]);
|
||||
})
|
||||
.then(() => {
|
||||
assert_array_equals(ws.events, ['abort', undefined]);
|
||||
assert_array_equals(ws.events, ['abort', error1]);
|
||||
});
|
||||
}, 'Aborting a WritableStream immediately prevents future writes');
|
||||
|
||||
|
@ -87,20 +87,20 @@ promise_test(t => {
|
|||
|
||||
results.push(
|
||||
writer.write(1),
|
||||
promise_rejects(t, new TypeError(), writer.write(2), 'write(2) must reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writer.write(3), 'write(3) must reject with a TypeError')
|
||||
promise_rejects(t, error1, writer.write(2), 'write(2) must reject with error1'),
|
||||
promise_rejects(t, error1, writer.write(3), 'write(3) must reject with error1')
|
||||
);
|
||||
|
||||
const abortPromise = writer.abort();
|
||||
const abortPromise = writer.abort(error1);
|
||||
|
||||
results.push(
|
||||
promise_rejects(t, new TypeError(), writer.write(4), 'write(4) must reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writer.write(5), 'write(5) must reject with a TypeError')
|
||||
promise_rejects(t, error1, writer.write(4), 'write(4) must reject with error1'),
|
||||
promise_rejects(t, error1, writer.write(5), 'write(5) must reject with error1')
|
||||
);
|
||||
|
||||
return abortPromise;
|
||||
}).then(() => {
|
||||
assert_array_equals(ws.events, ['write', 1, 'abort', undefined]);
|
||||
assert_array_equals(ws.events, ['write', 1, 'abort', error1]);
|
||||
|
||||
return Promise.all(results);
|
||||
});
|
||||
|
@ -209,26 +209,26 @@ promise_test(t => {
|
|||
|
||||
return Promise.all([
|
||||
abortPromise,
|
||||
promise_rejects(t, new TypeError(), writer.write(), 'writing should reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writer.close(), 'closing should reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writer.ready, 'ready should reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), writer.closed, 'closed should reject with a TypeError')
|
||||
promise_rejects(t, error1, writer.write(), 'writing should reject with error1'),
|
||||
promise_rejects(t, error1, writer.close(), 'closing should reject with error1'),
|
||||
promise_rejects(t, error1, writer.ready, 'ready should reject with error1'),
|
||||
promise_rejects(t, error1, writer.closed, 'closed should reject with error1')
|
||||
]).then(() => {
|
||||
assert_array_equals(['ready', 'closed'], events, 'ready should reject before closed');
|
||||
});
|
||||
}, 'Aborting a WritableStream puts it in an errored state, with a TypeError as the stored error');
|
||||
}, 'Aborting a WritableStream puts it in an errored state with the error passed to abort()');
|
||||
|
||||
promise_test(t => {
|
||||
const ws = new WritableStream();
|
||||
const writer = ws.getWriter();
|
||||
|
||||
const writePromise = promise_rejects(t, new TypeError(), writer.write('a'),
|
||||
'writing should reject with a TypeError');
|
||||
const writePromise = promise_rejects(t, error1, writer.write('a'),
|
||||
'writing should reject with error1');
|
||||
|
||||
writer.abort(error1);
|
||||
|
||||
return writePromise;
|
||||
}, 'Aborting a WritableStream causes any outstanding write() promises to be rejected with a TypeError');
|
||||
}, 'Aborting a WritableStream causes any outstanding write() promises to be rejected with the reason supplied');
|
||||
|
||||
promise_test(t => {
|
||||
const ws = recordingWritableStream();
|
||||
|
@ -238,8 +238,8 @@ promise_test(t => {
|
|||
const abortPromise = writer.abort(error1);
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writer.closed, 'closed should reject with a TypeError'),
|
||||
promise_rejects(t, new TypeError(), closePromise, 'close() should reject with a TypeError'),
|
||||
promise_rejects(t, error1, writer.closed, 'closed should reject with error1'),
|
||||
promise_rejects(t, error1, closePromise, 'close() should reject with error1'),
|
||||
abortPromise
|
||||
]).then(() => {
|
||||
assert_array_equals(ws.events, ['abort', error1]);
|
||||
|
@ -293,9 +293,9 @@ promise_test(t => {
|
|||
|
||||
const writer = ws.getWriter();
|
||||
|
||||
writer.abort();
|
||||
writer.abort(error1);
|
||||
|
||||
return promise_rejects(t, new TypeError(), writer.closed, 'closed should reject with a TypeError').then(() => {
|
||||
return promise_rejects(t, error1, writer.closed, 'closed should reject with error1').then(() => {
|
||||
assert_false(closeCalled, 'close must not have been called');
|
||||
});
|
||||
}, 'WritableStream should NOT call underlying sink\'s close if no abort is supplied (historical)');
|
||||
|
@ -329,7 +329,7 @@ promise_test(t => {
|
|||
let closedRejected = false;
|
||||
return Promise.all([
|
||||
writePromise.then(() => assert_false(closedRejected, '.closed should not resolve before write()')),
|
||||
promise_rejects(t, new TypeError(), writer.closed, '.closed should reject').then(() => {
|
||||
promise_rejects(t, error1, writer.closed, '.closed should reject').then(() => {
|
||||
closedRejected = true;
|
||||
})
|
||||
]);
|
||||
|
@ -350,7 +350,7 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
promise_rejects(t, error1, writePromise, 'write() should reject')
|
||||
.then(() => assert_false(closedRejected, '.closed should not resolve before write()')),
|
||||
promise_rejects(t, new TypeError(), writer.closed, '.closed should reject')
|
||||
promise_rejects(t, error2, writer.closed, '.closed should reject')
|
||||
.then(() => {
|
||||
closedRejected = true;
|
||||
}),
|
||||
|
@ -370,9 +370,9 @@ promise_test(t => {
|
|||
const settlementOrder = [];
|
||||
return Promise.all([
|
||||
writer.write('1').then(() => settlementOrder.push(1)),
|
||||
promise_rejects(t, new TypeError(), writer.write('2'), 'first queued write should be rejected')
|
||||
promise_rejects(t, error1, writer.write('2'), 'first queued write should be rejected')
|
||||
.then(() => settlementOrder.push(2)),
|
||||
promise_rejects(t, new TypeError(), writer.write('3'), 'second queued write should be rejected')
|
||||
promise_rejects(t, error1, writer.write('3'), 'second queued write should be rejected')
|
||||
.then(() => settlementOrder.push(3)),
|
||||
writer.abort(error1)
|
||||
]).then(() => assert_array_equals([1, 2, 3], settlementOrder, 'writes should be satisfied in order'));
|
||||
|
@ -391,9 +391,9 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
promise_rejects(t, error1, writer.write('1'), 'in-flight write should be rejected')
|
||||
.then(() => settlementOrder.push(1)),
|
||||
promise_rejects(t, new TypeError(), writer.write('2'), 'first queued write should be rejected')
|
||||
promise_rejects(t, error2, writer.write('2'), 'first queued write should be rejected')
|
||||
.then(() => settlementOrder.push(2)),
|
||||
promise_rejects(t, new TypeError(), writer.write('3'), 'second queued write should be rejected')
|
||||
promise_rejects(t, error2, writer.write('3'), 'second queued write should be rejected')
|
||||
.then(() => settlementOrder.push(3)),
|
||||
writer.abort(error2)
|
||||
]).then(() => assert_array_equals([1, 2, 3], settlementOrder, 'writes should be satisfied in order'));
|
||||
|
@ -410,12 +410,12 @@ promise_test(t => {
|
|||
return writer.ready.then(() => {
|
||||
return Promise.all([
|
||||
promise_rejects(t, error1, writer.write('a'), 'writer.write() should reject with error from underlying write()'),
|
||||
promise_rejects(t, new TypeError(), writer.close(),
|
||||
promise_rejects(t, error2, writer.close(),
|
||||
'writer.close() should reject with error from underlying write()'),
|
||||
writer.abort()
|
||||
writer.abort(error2)
|
||||
]);
|
||||
});
|
||||
}, 'close() should reject with TypeError when abort() is first error');
|
||||
}, 'close() should reject with abort reason why abort() is first error');
|
||||
|
||||
promise_test(() => {
|
||||
let resolveWrite;
|
||||
|
@ -510,14 +510,14 @@ promise_test(t => {
|
|||
return writer.ready.then(() => {
|
||||
writer.write('a');
|
||||
const closePromise = writer.close();
|
||||
const abortPromise = writer.abort('b');
|
||||
const abortPromise = writer.abort(error1);
|
||||
|
||||
return flushAsyncEvents().then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a'], 'abort should not be called while write is in-flight');
|
||||
resolveWrite();
|
||||
return abortPromise.then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a', 'abort', 'b'], 'abort should be called after write completes');
|
||||
return promise_rejects(t, new TypeError(), closePromise, 'promise returned by close() should be rejected');
|
||||
assert_array_equals(ws.events, ['write', 'a', 'abort', error1], 'abort should be called after write completes');
|
||||
return promise_rejects(t, error1, closePromise, 'promise returned by close() should be rejected');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -533,13 +533,13 @@ promise_test(t => {
|
|||
const writer = ws.getWriter();
|
||||
return writer.ready.then(() => {
|
||||
writer.write('a');
|
||||
writer.abort();
|
||||
writer.abort(error1);
|
||||
writer.releaseLock();
|
||||
const writer2 = ws.getWriter();
|
||||
return promise_rejects(t, new TypeError(), writer2.ready,
|
||||
'ready of the second writer should be rejected with a TypeError');
|
||||
return promise_rejects(t, error1, writer2.ready,
|
||||
'ready of the second writer should be rejected with error1');
|
||||
});
|
||||
}, 'if a writer is created for a stream with a pending abort, its ready should be rejected with a TypeError');
|
||||
}, 'if a writer is created for a stream with a pending abort, its ready should be rejected with the abort error');
|
||||
|
||||
promise_test(() => {
|
||||
const ws = new WritableStream();
|
||||
|
@ -607,8 +607,8 @@ promise_test(t => {
|
|||
const writePromise2 = writer.write('a');
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writePromise2, 'writePromise2 must reject with an error indicating abort'),
|
||||
promise_rejects(t, new TypeError(), writer.ready, 'writer.ready must reject with an error indicating abort'),
|
||||
promise_rejects(t, error1, writePromise2, 'writePromise2 must reject with the error from abort'),
|
||||
promise_rejects(t, error1, writer.ready, 'writer.ready must reject with the error from abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -620,8 +620,8 @@ promise_test(t => {
|
|||
promise_rejects(t, error2, writePromise,
|
||||
'writePromise must reject with the error returned from the sink\'s write method'),
|
||||
abortPromise,
|
||||
promise_rejects(t, new TypeError(), writer.closed,
|
||||
'writer.closed must reject with an error indicating abort'),
|
||||
promise_rejects(t, error1, writer.closed,
|
||||
'writer.closed must reject with the error from abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -631,9 +631,9 @@ promise_test(t => {
|
|||
const writePromise3 = writer.write('a');
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writePromise3,
|
||||
'writePromise3 must reject with an error indicating abort'),
|
||||
promise_rejects(t, new TypeError(), writer.ready,
|
||||
promise_rejects(t, error1, writePromise3,
|
||||
'writePromise3 must reject with the error from abort'),
|
||||
promise_rejects(t, error1, writer.ready,
|
||||
'writer.ready must be still rejected with the error indicating abort')
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -686,8 +686,8 @@ promise_test(t => {
|
|||
const writePromise2 = writer.write('a');
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writePromise2, 'writePromise2 must reject with an error indicating abort'),
|
||||
promise_rejects(t, new TypeError(), writer.ready, 'writer.ready must reject with an error indicating abort'),
|
||||
promise_rejects(t, error1, writePromise2, 'writePromise2 must reject with the error from abort'),
|
||||
promise_rejects(t, error1, writer.ready, 'writer.ready must reject with the error from abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -699,9 +699,9 @@ promise_test(t => {
|
|||
const writePromise3 = writer.write('a');
|
||||
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writePromise3,
|
||||
'writePromise3 must reject with an error indicating abort'),
|
||||
promise_rejects(t, new TypeError(), writer.ready,
|
||||
promise_rejects(t, error1, writePromise3,
|
||||
'writePromise3 must reject with the error from abort'),
|
||||
promise_rejects(t, error1, writer.ready,
|
||||
'writer.ready must be still rejected with the error indicating abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
|
@ -716,8 +716,8 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
writePromise,
|
||||
abortPromise,
|
||||
promise_rejects(t, new TypeError(), writer.closed,
|
||||
'writer.closed must reject with an error indicating abort'),
|
||||
promise_rejects(t, error1, writer.closed,
|
||||
'writer.closed must reject with the error from abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -728,9 +728,9 @@ promise_test(t => {
|
|||
|
||||
return Promise.all([
|
||||
writePromise,
|
||||
promise_rejects(t, new TypeError(), writePromise4,
|
||||
'writePromise4 must reject with an error indicating abort'),
|
||||
promise_rejects(t, new TypeError(), writer.ready,
|
||||
promise_rejects(t, error1, writePromise4,
|
||||
'writePromise4 must reject with the error from abort'),
|
||||
promise_rejects(t, error1, writer.ready,
|
||||
'writer.ready must be still rejected with the error indicating abort')
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -785,7 +785,7 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writer.close(),
|
||||
'writer.close() must reject with an error indicating already closing'),
|
||||
promise_rejects(t, new TypeError(), writer.ready, 'writer.ready must reject with an error indicating abort'),
|
||||
promise_rejects(t, error1, writer.ready, 'writer.ready must reject with the error from abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -796,7 +796,7 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writer.close(),
|
||||
'writer.close() must reject with an error indicating already closing'),
|
||||
promise_rejects(t, new TypeError(), writer.ready,
|
||||
promise_rejects(t, error1, writer.ready,
|
||||
'writer.ready must be still rejected with the error indicating abort'),
|
||||
flushAsyncEvents()
|
||||
]);
|
||||
|
@ -821,7 +821,7 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writer.close(),
|
||||
'writer.close() must reject with an error indicating already closing'),
|
||||
promise_rejects(t, new TypeError(), writer.ready,
|
||||
promise_rejects(t, error1, writer.ready,
|
||||
'writer.ready must be still rejected with the error indicating abort')
|
||||
]);
|
||||
}).then(() => {
|
||||
|
@ -1125,11 +1125,11 @@ promise_test(t => {
|
|||
const ws = new WritableStream();
|
||||
const writer = ws.getWriter();
|
||||
const writerReady1 = writer.ready;
|
||||
writer.abort('a');
|
||||
writer.abort(error1);
|
||||
const writerReady2 = writer.ready;
|
||||
assert_not_equals(writerReady1, writerReady2, 'abort() should replace the ready promise with a rejected one');
|
||||
return Promise.all([writerReady1,
|
||||
promise_rejects(t, new TypeError(), writerReady2, 'writerReady2 should reject')]);
|
||||
promise_rejects(t, error1, writerReady2, 'writerReady2 should reject')]);
|
||||
}, 'writer abort() during sink start() should replace the writer.ready promise synchronously');
|
||||
|
||||
promise_test(t => {
|
||||
|
@ -1137,7 +1137,7 @@ promise_test(t => {
|
|||
const ws = recordingWritableStream();
|
||||
const writer = ws.getWriter();
|
||||
const writePromise1 = writer.write(1);
|
||||
const abortPromise = writer.abort('a');
|
||||
const abortPromise = writer.abort(error1);
|
||||
const writePromise2 = writer.write(2);
|
||||
const closePromise = writer.close();
|
||||
writePromise1.catch(() => events.push('write1'));
|
||||
|
@ -1145,15 +1145,15 @@ promise_test(t => {
|
|||
writePromise2.catch(() => events.push('write2'));
|
||||
closePromise.catch(() => events.push('close'));
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), writePromise1, 'first write() should reject'),
|
||||
promise_rejects(t, error1, writePromise1, 'first write() should reject'),
|
||||
abortPromise,
|
||||
promise_rejects(t, new TypeError(), writePromise2, 'second write() should reject'),
|
||||
promise_rejects(t, new TypeError(), closePromise, 'close() should reject')
|
||||
promise_rejects(t, error1, writePromise2, 'second write() should reject'),
|
||||
promise_rejects(t, error1, closePromise, 'close() should reject')
|
||||
])
|
||||
.then(() => {
|
||||
assert_array_equals(events, ['write2', 'write1', 'abort', 'close'],
|
||||
'promises should resolve in the standard order');
|
||||
assert_array_equals(ws.events, ['abort', 'a'], 'underlying sink write() should not be called');
|
||||
assert_array_equals(ws.events, ['abort', error1], 'underlying sink write() should not be called');
|
||||
});
|
||||
}, 'promises returned from other writer methods should be rejected when writer abort() happens during sink start()');
|
||||
|
||||
|
@ -1224,7 +1224,7 @@ promise_test(t => {
|
|||
return Promise.all([
|
||||
promise_rejects(t, error1, writePromise, 'write should reject'),
|
||||
abortPromise,
|
||||
promise_rejects(t, new TypeError(), writer.closed, 'closed should reject with TypeError')
|
||||
promise_rejects(t, error2, writer.closed, 'closed should reject with error2')
|
||||
]);
|
||||
}).then(() => {
|
||||
assert_array_equals(ws.events, ['write', '1', 'abort', error2], 'abort sink method should be called');
|
||||
|
@ -1243,7 +1243,7 @@ promise_test(() => {
|
|||
});
|
||||
}, 'when start errors after stream abort(), underlying sink abort() should be called anyway');
|
||||
|
||||
promise_test(t => {
|
||||
promise_test(() => {
|
||||
const ws = new WritableStream();
|
||||
const abortPromise1 = ws.abort();
|
||||
const abortPromise2 = ws.abort();
|
||||
|
@ -1253,7 +1253,7 @@ promise_test(t => {
|
|||
v => assert_equals(v, undefined, 'abort() should fulfill with undefined'));
|
||||
}, 'when calling abort() twice on the same stream, both should give the same promise that fulfills with undefined');
|
||||
|
||||
promise_test(t => {
|
||||
promise_test(() => {
|
||||
const ws = new WritableStream();
|
||||
const abortPromise1 = ws.abort();
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ promise_test(t => {
|
|||
const writer = ws.getWriter();
|
||||
|
||||
return promise_rejects(t, error1, writer.abort(abortReason), 'abort should reject with the thrown error')
|
||||
.then(() => promise_rejects(t, new TypeError(), writer.closed, 'closed should reject with a TypeError'));
|
||||
.then(() => promise_rejects(t, abortReason, writer.closed, 'closed should reject with abortReason'));
|
||||
}, 'abort: throwing method should cause abort() and closed to reject');
|
||||
|
||||
done();
|
||||
|
|
|
@ -361,8 +361,8 @@ promise_test(t => {
|
|||
'closePromise must reject with the error returned from the sink\'s close method'),
|
||||
promise_rejects(t, error1, abortPromise,
|
||||
'abortPromise must reject with the error returned from the sink\'s close method'),
|
||||
promise_rejects(t, new TypeError(), writer.closed,
|
||||
'writer.closed must reject with a TypeError indicating the stream was aborted')
|
||||
promise_rejects(t, error2, writer.closed,
|
||||
'writer.closed must reject with error2')
|
||||
]).then(() => {
|
||||
assert_array_equals(events, ['closePromise', 'abortPromise', 'closed'],
|
||||
'promises must fulfill/reject in the expected order');
|
||||
|
|
|
@ -165,8 +165,8 @@ promise_test(() => {
|
|||
|
||||
promise_test(t => {
|
||||
function functionWithOverloads() {}
|
||||
functionWithOverloads.apply = () => assert_unreached('apply() should not be called');
|
||||
functionWithOverloads.call = () => assert_unreached('call() should not be called');
|
||||
functionWithOverloads.apply = t.unreached_func('apply() should not be called');
|
||||
functionWithOverloads.call = t.unreached_func('call() should not be called');
|
||||
const underlyingSink = {
|
||||
start: functionWithOverloads,
|
||||
write: functionWithOverloads,
|
||||
|
@ -180,9 +180,12 @@ promise_test(t => {
|
|||
writer1.close();
|
||||
|
||||
// Test abort().
|
||||
const abortError = new Error();
|
||||
abortError.name = 'abort error';
|
||||
|
||||
const ws2 = new WritableStream(underlyingSink);
|
||||
const writer2 = ws2.getWriter();
|
||||
writer2.abort();
|
||||
writer2.abort(abortError);
|
||||
|
||||
// Test abort() with a close underlying sink method present. (Historical; see
|
||||
// https://github.com/whatwg/streams/issues/620#issuecomment-263483953 for what used to be
|
||||
|
@ -193,11 +196,11 @@ promise_test(t => {
|
|||
close: functionWithOverloads
|
||||
});
|
||||
const writer3 = ws3.getWriter();
|
||||
writer3.abort();
|
||||
writer3.abort(abortError);
|
||||
|
||||
return writer1.closed
|
||||
.then(() => promise_rejects(t, new TypeError(), writer2.closed, 'writer2.closed should be rejected'))
|
||||
.then(() => promise_rejects(t, new TypeError(), writer3.closed, 'writer3.closed should be rejected'));
|
||||
.then(() => promise_rejects(t, abortError, writer2.closed, 'writer2.closed should be rejected'))
|
||||
.then(() => promise_rejects(t, abortError, writer3.closed, 'writer3.closed should be rejected'));
|
||||
}, 'methods should not not have .apply() or .call() called');
|
||||
|
||||
promise_test(() => {
|
||||
|
|
|
@ -114,16 +114,16 @@ promise_test(t => {
|
|||
let writer;
|
||||
const strategy = {
|
||||
size() {
|
||||
writer.abort('nice');
|
||||
writer.abort(error1);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
const ws = recordingWritableStream({}, strategy);
|
||||
writer = ws.getWriter();
|
||||
return promise_rejects(t, new TypeError(), writer.write('a'), 'write() promise should reject')
|
||||
return promise_rejects(t, error1, writer.write('a'), 'write() promise should reject')
|
||||
.then(() => {
|
||||
assert_array_equals(ws.events, ['abort', 'nice'], 'sink.write() should not be called');
|
||||
assert_array_equals(ws.events, ['abort', error1], 'sink.write() should not be called');
|
||||
});
|
||||
}, 'abort() should work when called from within strategy.size()');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue