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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/general.js

Issue 2596883002: Update writable streams for the latest spec changes (Closed)
Patch Set: Adjust indents 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/http/tests/streams/writable-streams/general.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/general.js b/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/general.js
index bcba6bfc81cdbbcc28000844640f7bc3c24415dd..891b2520a198a4fd3ccde9e4973ef933a2a63d53 100644
--- a/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/general.js
+++ b/third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/general.js
@@ -152,6 +152,56 @@ promise_test(() => {
.then(thisValue => assert_equals(thisValue, theSink, 'abort should be called as a method'));
}, 'WritableStream should call underlying sink methods as methods');
+promise_test(t => {
+ function functionWithOverloads() {}
+ functionWithOverloads.apply = () => assert_unreached('apply() should not be called');
+ functionWithOverloads.call = () => assert_unreached('call() should not be called');
+ const underlyingSink = {
+ start: functionWithOverloads,
+ write: functionWithOverloads,
+ close: functionWithOverloads,
+ abort: functionWithOverloads
+ };
+ // Test start(), write(), close().
+ const ws1 = new WritableStream(underlyingSink);
+ const writer1 = ws1.getWriter();
+ writer1.write('a');
+ writer1.close();
+
+ // Test abort().
+ const ws2 = new WritableStream(underlyingSink);
+ const writer2 = ws2.getWriter();
+ writer2.abort();
+
+ // Test PromiseInvokeOrFallbackOrNoop.
+ const ws3 = new WritableStream({
+ start: functionWithOverloads,
+ write: functionWithOverloads,
+ close: functionWithOverloads
+ });
+ const writer3 = ws3.getWriter();
+ writer3.abort();
+
+ return writer1.closed
+ .then(() => promise_rejects(t, new TypeError(), writer2.closed, 'writer2.closed should be rejected'))
+ .then(() => promise_rejects(t, new TypeError(), writer3.closed, 'writer3.closed should be rejected'));
+}, 'methods should not not have .apply() or .call() called');
+
+promise_test(() => {
+ const strategy = {
+ size() {
+ if (this !== undefined) {
+ throw new Error('size called as a method');
+ }
+ return 1;
+ }
+ };
+
+ const ws = new WritableStream({}, strategy);
+ const writer = ws.getWriter();
+ return writer.write('a');
+}, 'WritableStream\'s strategy.size should not be called as a method');
+
promise_test(() => {
const ws = new WritableStream();
const writer1 = ws.getWriter();

Powered by Google App Engine
This is Rietveld 408576698