| Index: third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/bad-underlying-sinks.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/bad-underlying-sinks.js b/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/bad-underlying-sinks.js
|
| index 3981316c81079cbc28564161a5164c51bc1800e5..c519aad71cfe4b45cddedcc7a39b98a84b59f1aa 100644
|
| --- a/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/bad-underlying-sinks.js
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/bad-underlying-sinks.js
|
| @@ -9,6 +9,36 @@ if (self.importScripts) {
|
| const error1 = new Error('error1');
|
| error1.name = 'error1';
|
|
|
| +test(() => {
|
| + assert_throws(error1, () => {
|
| + new WritableStream({
|
| + get start() {
|
| + throw error1;
|
| + }
|
| + });
|
| + }, 'constructor should throw same error as throwing start getter');
|
| +
|
| + assert_throws(error1, () => {
|
| + new WritableStream({
|
| + start() {
|
| + throw error1;
|
| + }
|
| + });
|
| + }, 'constructor should throw same error as throwing start method');
|
| +
|
| + assert_throws(new TypeError(), () => {
|
| + new WritableStream({
|
| + start: 'not a function or undefined'
|
| + });
|
| + }, 'constructor should throw TypeError when passed a non-function start property');
|
| +
|
| + assert_throws(new TypeError(), () => {
|
| + new WritableStream({
|
| + start: { apply() {} }
|
| + });
|
| + }, 'constructor should throw TypeError when passed a non-function start property with an .apply method');
|
| +}, 'start: errors in start cause WritableStream constructor to throw');
|
| +
|
| promise_test(t => {
|
|
|
| const ws = recordingWritableStream({
|
| @@ -40,13 +70,49 @@ promise_test(t => {
|
|
|
| return promise_rejects(t, error1, writer.close(), 'close() promise must reject with the same error')
|
| .then(() => promise_rejects(t, error1, writer.ready, 'ready promise must reject with the same error'))
|
| - .then(() => {
|
| - assert_array_equals(ws.events, ['close']);
|
| - });
|
| + .then(() => assert_array_equals(ws.events, ['close']));
|
|
|
| }, 'close: returning a rejected promise should cause writer close() and ready to reject');
|
|
|
| promise_test(t => {
|
| + const ws = new WritableStream({
|
| + get close() {
|
| + throw error1;
|
| + }
|
| + });
|
| +
|
| + const writer = ws.getWriter();
|
| +
|
| + return promise_rejects(t, error1, writer.close(), 'close should reject with the thrown error');
|
| +}, 'close: throwing getter should cause writer close() to reject');
|
| +
|
| +promise_test(t => {
|
| + const ws = new WritableStream({
|
| + get write() {
|
| + throw error1;
|
| + }
|
| + });
|
| +
|
| + const writer = ws.getWriter();
|
| +
|
| + return promise_rejects(t, error1, writer.write('a'), 'write should reject with the thrown error')
|
| + .then(() => promise_rejects(t, error1, writer.closed, 'closed should reject with the thrown error'));
|
| +}, 'write: throwing getter should cause write() and closed to reject');
|
| +
|
| +promise_test(t => {
|
| + const ws = new WritableStream({
|
| + write() {
|
| + throw error1;
|
| + }
|
| + });
|
| +
|
| + const writer = ws.getWriter();
|
| +
|
| + return promise_rejects(t, error1, writer.write('a'), 'write should reject with the thrown error')
|
| + .then(() => promise_rejects(t, error1, writer.closed, 'closed should reject with the thrown error'));
|
| +}, 'write: throwing method should cause write() and closed to reject');
|
| +
|
| +promise_test(t => {
|
|
|
| const startPromise = Promise.resolve();
|
| let rejectSinkWritePromise;
|
| @@ -83,7 +149,7 @@ promise_test(t => {
|
| const ws = recordingWritableStream({
|
| write() {
|
| if (ws.events.length === 2) {
|
| - return delay(10);
|
| + return delay(0);
|
| }
|
|
|
| return Promise.reject(error1);
|
| @@ -103,10 +169,47 @@ promise_test(t => {
|
| 'transitioned');
|
| return promise_rejects(t, error1, writer.ready, 'ready promise must reject with the same error');
|
| })
|
| - .then(() => {
|
| - assert_array_equals(ws.events, ['write', 'a', 'write', 'b']);
|
| - });
|
| + .then(() => assert_array_equals(ws.events, ['write', 'a', 'write', 'b']));
|
|
|
| }, 'write: returning a rejected promise (second write) should cause writer write() and ready to reject');
|
|
|
| +promise_test(t => {
|
| + const ws = new WritableStream({
|
| + abort: { apply() {} }
|
| + });
|
| +
|
| + return promise_rejects(t, new TypeError(), ws.abort(error1), 'abort should reject with TypeError').then(() => {
|
| + const writer = ws.getWriter();
|
| + return promise_rejects(t, new TypeError(), writer.closed, 'closed should reject with a TypeError');
|
| + });
|
| +}, 'abort: non-function abort method with .apply');
|
| +
|
| +promise_test(t => {
|
| + const abortReason = new Error('different string');
|
| + const ws = new WritableStream({
|
| + get abort() {
|
| + throw error1;
|
| + }
|
| + });
|
| +
|
| + 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'));
|
| +}, 'abort: throwing getter should cause abort() and closed to reject');
|
| +
|
| +promise_test(t => {
|
| + const abortReason = new Error('different string');
|
| + const ws = new WritableStream({
|
| + abort() {
|
| + throw error1;
|
| + }
|
| + });
|
| +
|
| + 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'));
|
| +}, 'abort: throwing method should cause abort() and closed to reject');
|
| +
|
| done();
|
|
|