Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/write.js

Issue 2668783003: Import wpt@767dc2a4f049c761bd146d61de2ea860a895a624 (Closed)
Patch Set: Update test expectations and baselines. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/write.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/write.js b/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/write.js
index a754b51f1bbca20b3e9042d8b50ac7283600eb93..8b86f0d22b8baa72950d3294506228aae21a7993 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/write.js
+++ b/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/write.js
@@ -6,6 +6,12 @@ if (self.importScripts) {
self.importScripts('../resources/recording-streams.js');
}
+const error1 = new Error('error1');
+error1.name = 'error1';
+
+const error2 = new Error('error2');
+error2.name = 'error2';
+
function writeArrayToStream(array, writableStreamWriter) {
array.forEach(chunk => writableStreamWriter.write(chunk));
return writableStreamWriter.close();
@@ -130,20 +136,21 @@ promise_test(t => {
assert_equals(writer.desiredSize, -1, 'desiredSize should still be -1');
- const passedError = new Error('horrible things');
-
return Promise.all([
- promise_rejects(t, passedError, closedPromise, 'closedPromise should reject with passedError')
+ promise_rejects(t, error1, closedPromise,
+ 'closedPromise should reject with the error returned from the sink\'s write method')
.then(() => assert_equals(sinkWritePromiseRejectors.length, 0,
'sinkWritePromise should reject before closedPromise')),
- promise_rejects(t, passedError, writePromise, 'writePromise should reject with passedError')
+ promise_rejects(t, error1, writePromise,
+ 'writePromise should reject with the error returned from the sink\'s write method')
.then(() => assert_equals(sinkWritePromiseRejectors.length, 0,
'sinkWritePromise should reject before writePromise')),
- promise_rejects(t, passedError, writePromise2, 'writePromise2 should reject with passedError')
+ promise_rejects(t, error1, writePromise2,
+ 'writePromise2 should reject with the error returned from the sink\'s write method')
.then(() => assert_equals(sinkWritePromiseRejectors.length, 0,
'sinkWritePromise should reject before writePromise2')),
flushAsyncEvents().then(() => {
- sinkWritePromiseRejectors[0](passedError);
+ sinkWritePromiseRejectors[0](error1);
sinkWritePromiseRejectors = [];
})
]);
@@ -151,19 +158,42 @@ promise_test(t => {
}, 'when write returns a rejected promise, queued writes and close should be cleared');
promise_test(t => {
- const thrownError = new Error('throw me');
const ws = new WritableStream({
write() {
- throw thrownError;
+ throw error1;
}
});
const writer = ws.getWriter();
- return promise_rejects(t, thrownError, writer.write('a'), 'write() should reject with thrownError')
+ return promise_rejects(t, error1, writer.write('a'),
+ 'write() should reject with the error returned from the sink\'s write method')
.then(() => promise_rejects(t, new TypeError(), writer.close(), 'close() should be rejected'));
}, 'when sink\'s write throws an error, the stream should become errored and the promise should reject');
+promise_test(t => {
+ const ws = new WritableStream({
+ write(chunk, controller) {
+ controller.error(error1);
+ throw error2;
+ }
+ });
+
+ const writer = ws.getWriter();
+
+ return promise_rejects(t, error2, writer.write('a'),
+ 'write() should reject with the error returned from the sink\'s write method ')
+ .then(() => {
+ return Promise.all([
+ promise_rejects(t, error1, writer.ready,
+ 'writer.ready must reject with the error passed to the controller'),
+ promise_rejects(t, error1, writer.closed,
+ 'writer.closed must reject with the error passed to the controller')
+ ]);
+ });
+}, 'writer.write(), ready and closed reject with the error passed to controller.error() made before sink.write'
+ + ' rejection');
+
promise_test(() => {
const numberOfWrites = 1000;

Powered by Google App Engine
This is Rietveld 408576698