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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/close.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/close.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/close.js b/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/close.js
index 5c83a5e12839d13460241731c39e467de2a7a399..5844f367f911d1923e88f5e24cb6b4be2f14aed6 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/close.js
+++ b/third_party/WebKit/LayoutTests/external/wpt/streams/writable-streams/close.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';
+
promise_test(() => {
const ws = new WritableStream({
close() {
@@ -54,6 +60,38 @@ promise_test(t => {
return writer.close().then(() => promise_rejects(t, passedError, writer.closed, 'closed should stay rejected'));
}, 'when sink calls error synchronously while closing, the stream should become errored');
+promise_test(t => {
+ const ws = new WritableStream({
+ write(chunk, controller) {
+ controller.error(error1);
+ return new Promise(() => {});
+ }
+ });
+
+ const writer = ws.getWriter();
+ writer.write('a');
+
+ return delay(0).then(() => {
+ writer.releaseLock();
+ });
+}, 'releaseLock on a stream with a pending write in which the stream has been errored');
+
+promise_test(t => {
+ const ws = new WritableStream({
+ close(controller) {
+ controller.error(error1);
+ return new Promise(() => {});
+ }
+ });
+
+ const writer = ws.getWriter();
+ writer.close();
+
+ return delay(0).then(() => {
+ writer.releaseLock();
+ });
+}, 'releaseLock on a stream with a pending close in which the stream has been errored');
+
promise_test(() => {
const ws = recordingWritableStream();
@@ -213,4 +251,97 @@ promise_test(() => {
});
}, 'the promise returned by async abort during close should resolve');
+// Though the order in which the promises are fulfilled or rejected is arbitrary, we're checking it for
+// interoperability. We can change the order as long as we file bugs on all implementers to update to the latest tests
+// to keep them interoperable.
+
+promise_test(() => {
+ const ws = new WritableStream({});
+
+ const writer = ws.getWriter();
+
+ const closePromise = writer.close();
+
+ const events = [];
+ return Promise.all([
+ closePromise.then(() => {
+ events.push('closePromise');
+ }),
+ writer.closed.then(() => {
+ events.push('closed');
+ })
+ ]).then(() => {
+ assert_array_equals(events, ['closePromise', 'closed'],
+ 'promises must fulfill/reject in the expected order');
+ });
+}, 'promises must fulfill/reject in the expected order on closure');
+
+promise_test(t => {
+ const ws = new WritableStream({});
+
+ // Wait until the WritableStream starts so that the close() call gets processed. Otherwise, abort() will be
+ // processed without waiting for completion of the close().
+ return delay(0).then(() => {
+ const writer = ws.getWriter();
+
+ const closePromise = writer.close();
+ const abortPromise = writer.abort(error1);
+
+ const events = [];
+ return Promise.all([
+ closePromise.then(() => {
+ events.push('closePromise');
+ }),
+ abortPromise.then(() => {
+ events.push('abortPromise');
+ }),
+ promise_rejects(t, new TypeError(), writer.closed, 'writer.closed must reject with an error indicating abort')
+ .then(() => {
+ events.push('closed');
+ })
+ ]).then(() => {
+ assert_array_equals(events, ['closePromise', 'abortPromise', 'closed'],
+ 'promises must fulfill/reject in the expected order');
+ });
+ });
+}, 'promises must fulfill/reject in the expected order on aborted closure');
+
+promise_test(t => {
+ const ws = new WritableStream({
+ close() {
+ return Promise.reject(error1);
+ }
+ });
+
+ // Wait until the WritableStream starts so that the close() call gets processed.
+ return delay(0).then(() => {
+ const writer = ws.getWriter();
+
+ const closePromise = writer.close();
+ const abortPromise = writer.abort(error2);
+
+ const events = [];
+ return Promise.all([
+ promise_rejects(t, error1, closePromise,
+ 'closePromise must reject with the error returned from the sink\'s close method')
+ .then(() => {
+ events.push('closePromise');
+ }),
+ promise_rejects(t, error1, abortPromise,
+ 'abortPromise must reject with the error returned from the sink\'s close method')
+ .then(() => {
+ events.push('abortPromise');
+ }),
+ promise_rejects(t, error1, writer.closed,
+ 'writer.closed must reject with the error returned from the sink\'s close method')
+ .then(() => {
+ events.push('closed');
+ })
+ ]).then(() => {
+ assert_array_equals(events, ['closePromise', 'abortPromise', 'closed'],
+ 'promises must fulfill/reject in the expected order');
+ });
+ });
+}, 'promises must fulfill/reject in the expected order on aborted and errored closure');
+
done();

Powered by Google App Engine
This is Rietveld 408576698