Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WritableStream: test writer behaviour #15235

Merged
merged 1 commit into from
Feb 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions streams/writable-streams/write.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,27 @@ promise_test(() => {
});
return ws.getWriter().write('a').then(() => assert_true(thenCalled, 'thenCalled should be true'));
}, 'returning a thenable from write() should work');

promise_test(() => {
const stream = new WritableStream();
const writer = stream.getWriter();
const WritableStreamDefaultWriter = writer.constructor;
assert_throws(new TypeError(), () => new WritableStreamDefaultWriter(stream),
'should not be able to construct on locked stream');
// If stream.[[writer]] no longer points to |writer| then the closed Promise
// won't work properly.
return Promise.all([writer.close(), writer.closed]);
}, 'failing DefaultWriter constructor should not release an existing writer');

promise_test(t => {
const ws = new WritableStream({
start() {
return Promise.reject(error1);
}
}, { highWaterMark: 0 });
const writer = ws.getWriter();
return Promise.all([
promise_rejects(t, error1, writer.ready, 'ready should be rejected'),
promise_rejects(t, error1, writer.write(), 'write() should be rejected')
]);
}, 'write() on a stream with HWM 0 should not cause the ready Promise to resolve');