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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/constructor.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 unified diff | Download patch
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 if (self.importScripts) { 3 if (self.importScripts) {
4 self.importScripts('/resources/testharness.js'); 4 self.importScripts('/resources/testharness.js');
5 } 5 }
6 6
7 const error1 = new Error('error1');
8 error1.name = 'error1';
9
7 promise_test(() => { 10 promise_test(() => {
8 let controller; 11 let controller;
9 const ws = new WritableStream({ 12 const ws = new WritableStream({
10 start(c) { 13 start(c) {
11 controller = c; 14 controller = c;
12 } 15 }
13 }); 16 });
14 17
15 // Now error the stream after its construction. 18 // Now error the stream after its construction.
16 const passedError = new Error('horrible things'); 19 controller.error(error1);
17 controller.error(passedError);
18 20
19 const writer = ws.getWriter(); 21 const writer = ws.getWriter();
20 22
21 assert_equals(writer.desiredSize, null, 'desiredSize should be null'); 23 assert_equals(writer.desiredSize, null, 'desiredSize should be null');
22 return writer.closed.catch(r => { 24 return writer.closed.catch(r => {
23 assert_equals(r, passedError, 'ws should be errored by passedError'); 25 assert_equals(r, error1, 'ws should be errored by the passed error');
24 }); 26 });
25 }, 'controller argument should be passed to start method'); 27 }, 'controller argument should be passed to start method');
26 28
27 promise_test(t => { 29 promise_test(t => {
28 const ws = new WritableStream({ 30 const ws = new WritableStream({
29 write(chunk, controller) { 31 write(chunk, controller) {
30 controller.error(new Error()); 32 controller.error(error1);
31 } 33 }
32 }); 34 });
33 35
34 const writer = ws.getWriter(); 36 const writer = ws.getWriter();
35 writer.write('a');
36 37
37 return promise_rejects(t, new Error(), writer.closed, 'controller.error() in w rite() should errored the stream'); 38 return Promise.all([
39 writer.write('a'),
40 promise_rejects(t, error1, writer.closed, 'controller.error() in write() sho uld errored the stream')
41 ]);
38 }, 'controller argument should be passed to write method'); 42 }, 'controller argument should be passed to write method');
39 43
40 promise_test(t => { 44 promise_test(t => {
41 const ws = new WritableStream({ 45 const ws = new WritableStream({
42 close(controller) { 46 close(controller) {
43 controller.error(new Error()); 47 controller.error(error1);
44 } 48 }
45 }); 49 });
46 50
47 const writer = ws.getWriter(); 51 const writer = ws.getWriter();
48 writer.close();
49 52
50 return promise_rejects(t, new Error(), writer.closed, 'controller.error() in c lose() should error the stream'); 53 return Promise.all([
54 writer.close(),
55 promise_rejects(t, error1, writer.closed, 'controller.error() in close() sho uld error the stream')
56 ]);
51 }, 'controller argument should be passed to close method'); 57 }, 'controller argument should be passed to close method');
52 58
53 promise_test(() => { 59 promise_test(() => {
54 const ws = new WritableStream({}, { 60 const ws = new WritableStream({}, {
55 highWaterMark: 1000, 61 highWaterMark: 1000,
56 size() { return 1; } 62 size() { return 1; }
57 }); 63 });
58 64
59 const writer = ws.getWriter(); 65 const writer = ws.getWriter();
60 66
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 test(() => { 125 test(() => {
120 let WritableStreamDefaultController; 126 let WritableStreamDefaultController;
121 const stream = new WritableStream({ 127 const stream = new WritableStream({
122 start(c) { 128 start(c) {
123 WritableStreamDefaultController = c.constructor; 129 WritableStreamDefaultController = c.constructor;
124 } 130 }
125 }); 131 });
126 132
127 assert_throws(new TypeError(), () => new WritableStreamDefaultController(strea m), 133 assert_throws(new TypeError(), () => new WritableStreamDefaultController(strea m),
128 'constructor should throw a TypeError exception'); 134 'constructor should throw a TypeError exception');
129 }, 'WritableStreamDefaultController constructor should throw when passed an init alised WritableStream'); 135 }, 'WritableStreamDefaultController constructor should throw when passed an init ialised WritableStream');
130 136
131 test(() => { 137 test(() => {
132 const stream = new WritableStream(); 138 const stream = new WritableStream();
133 const writer = stream.getWriter(); 139 const writer = stream.getWriter();
134 const WritableStreamDefaultWriter = writer.constructor; 140 const WritableStreamDefaultWriter = writer.constructor;
135 writer.releaseLock(); 141 writer.releaseLock();
136 assert_throws(new TypeError(), () => new WritableStreamDefaultWriter({}), 142 assert_throws(new TypeError(), () => new WritableStreamDefaultWriter({}),
137 'constructor should throw a TypeError exception'); 143 'constructor should throw a TypeError exception');
138 }, 'WritableStreamDefaultWriter should throw unless passed a WritableStream'); 144 }, 'WritableStreamDefaultWriter should throw unless passed a WritableStream');
139 145
140 test(() => { 146 test(() => {
141 const stream = new WritableStream(); 147 const stream = new WritableStream();
142 const writer = stream.getWriter(); 148 const writer = stream.getWriter();
143 const WritableStreamDefaultWriter = writer.constructor; 149 const WritableStreamDefaultWriter = writer.constructor;
144 assert_throws(new TypeError(), () => new WritableStreamDefaultWriter(stream), 150 assert_throws(new TypeError(), () => new WritableStreamDefaultWriter(stream),
145 'constructor should throw a TypeError exception'); 151 'constructor should throw a TypeError exception');
146 }, 'WritableStreamDefaultWriter constructor should throw when stream argument is locked'); 152 }, 'WritableStreamDefaultWriter constructor should throw when stream argument is locked');
147 153
148 done(); 154 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698