| <!DOCTYPE html> |
| <script src='../../resources/testharness.js'></script> |
| <script src='../../resources/testharnessreport.js'></script> |
| <script src='resources/streams-utils.js'></script> |
| <script> |
| // This is updated till https://github.com/whatwg/streams/commit/4ba861e6f60c248060811830e11271c84b439cc3 |
| |
| test(function() { |
| var theError = new Error('a unique string'); |
| |
| assert_throws_exactly(theError, function() { |
| new WritableStream({ |
| get start() { |
| throw theError; |
| } |
| }); |
| }); |
| }, 'Underlying sink: throwing start getter'); |
| |
| test(function() { |
| var theError = new Error('a unique string'); |
| |
| assert_throws_exactly(theError, function() { |
| new WritableStream({ |
| start: function() { |
| throw theError; |
| } |
| }); |
| }); |
| }, 'Underlying sink: throwing start method'); |
| |
| var test1 = async_test('Underlying sink: throwing write getter'); |
| test1.step(function() { |
| var writeRejected = false; |
| |
| var theError = new Error('a unique string'); |
| var ws = new WritableStream({ |
| get write() { |
| throw theError; |
| } |
| }); |
| |
| ws.write('a').then( |
| test1.step_func(function() { assert_unreached('write should not fulfill'); }), |
| test1.step_func(function(r) { |
| assert_equals(r, theError, 'write should reject with the thrown error'); |
| writeRejected = true; |
| }) |
| ); |
| |
| ws.closed.then( |
| test1.step_func(function() { assert_unreached('closed should not fulfill'); }), |
| test1.step_func(function(r) { |
| assert_equals(r, theError, 'closed should reject with the thrown error'); |
| assert_true(writeRejected); |
| test1.done(); |
| }) |
| ); |
| }); |
| |
| var test2 = async_test('Underlying sink: throwing write method'); |
| test2.step(function() { |
| var writeRejected = false; |
| |
| var theError = new Error('a unique string'); |
| var ws = new WritableStream({ |
| write: function() { |
| throw theError; |
| } |
| }); |
| |
| ws.write('a').then( |
| test2.step_func(function() { assert_unreached('write should not fulfill'); }), |
| test2.step_func(function(r) { |
| assert_equals(r, theError, 'write should reject with the thrown error'); |
| writeRejected = true; |
| }) |
| ); |
| |
| ws.closed.then( |
| test2.step_func(function() { assert_unreached('closed should not fulfill'); }), |
| test2.step_func(function(r) { |
| assert_equals(r, theError, 'closed should reject with the thrown error'); |
| assert_true(writeRejected); |
| test2.done(); |
| }) |
| ); |
| }); |
| |
| var test3 = async_test('Underlying sink: throwing abort getter'); |
| test3.step(function() { |
| var closedRejected = false; |
| var theError = new Error('a unique string'); |
| var abortReason = new Error('different string'); |
| var ws = new WritableStream({ |
| get abort() { |
| throw theError; |
| } |
| }); |
| |
| ws.abort(abortReason).then( |
| test3.step_func(function() { assert_unreached('abort should not fulfill'); }), |
| test3.step_func(function(r) { |
| assert_equals(r, theError, 'abort should reject with the abort reason'); |
| assert_true(closedRejected); |
| test3.done(); |
| }) |
| ); |
| |
| ws.closed.then( |
| test3.step_func(function() { assert_unreached('closed should not fulfill'); }), |
| test3.step_func(function(r) { |
| assert_equals(r, abortReason, 'closed should reject with the thrown error'); |
| closedRejected = true; |
| }) |
| ); |
| }); |
| |
| var test4 = async_test('Underlying sink: throwing abort method'); |
| test4.step(function() { |
| var closedRejected = false; |
| var theError = new Error('a unique string'); |
| var abortReason = new Error('different string'); |
| var ws = new WritableStream({ |
| abort: function() { |
| throw theError; |
| } |
| }); |
| |
| ws.abort(abortReason).then( |
| test4.step_func(function() { assert_unreached('abort should not fulfill'); }), |
| test4.step_func(function(r) { |
| assert_equals(r, theError, 'abort should reject with the abort reason'); |
| assert_true(closedRejected); |
| test4.done(); |
| }) |
| ); |
| |
| ws.closed.then( |
| test4.step_func(function() { assert_unreached('closed should not fulfill'); }), |
| test4.step_func(function(r) { |
| assert_equals(r, abortReason, 'closed should reject with the thrown error'); |
| closedRejected = true; |
| }) |
| ); |
| }); |
| |
| var test5 = async_test('Underlying sink: throwing close getter'); |
| test5.step(function() { |
| var theError = new Error('a unique string'); |
| var ws = new WritableStream({ |
| get close() { |
| throw theError; |
| } |
| }); |
| |
| ws.close().then( |
| test5.step_func(function() { assert_unreached('close should not fulfill'); }), |
| test5.step_func(function(r) { |
| assert_equals(r, theError, 'close should reject with the thrown error'); |
| test5.done(); |
| }) |
| ); |
| }); |
| |
| var test6 = async_test('Underlying sink: throwing close method'); |
| test6.step(function() { |
| var theError = new Error('a unique string'); |
| var ws = new WritableStream({ |
| close: function() { |
| throw theError; |
| } |
| }); |
| |
| ws.close().then( |
| test6.step_func(function() { assert_unreached('close should not fulfill'); }), |
| test6.step_func(function(r) { |
| assert_equals(r, theError, 'close should reject with the thrown error'); |
| test6.done(); |
| }) |
| ); |
| }); |
| </script> |