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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/streams/writable-streams/bad-strategies.js

Issue 2772293002: Update WritableStream to new standard version (Closed)
Patch Set: Changes from domenic@ review Created 3 years, 8 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
(Empty)
1 'use strict';
2
3 if (self.importScripts) {
4 self.importScripts('/resources/testharness.js');
5 }
6
7 const error1 = new Error('a unique string');
8 error1.name = 'error1';
9
10 test(() => {
11 assert_throws(error1, () => {
12 new WritableStream({}, {
13 get size() {
14 throw error1;
15 },
16 highWaterMark: 5
17 });
18 }, 'construction should re-throw the error');
19 }, 'Writable stream: throwing strategy.size getter');
20
21 test(() => {
22 assert_throws(new TypeError(), () => {
23 new WritableStream({}, { size: 'a string' });
24 });
25 }, 'reject any non-function value for strategy.size');
26
27 test(() => {
28 assert_throws(error1, () => {
29 new WritableStream({}, {
30 size() {
31 return 1;
32 },
33 get highWaterMark() {
34 throw error1;
35 }
36 });
37 }, 'construction should re-throw the error');
38 }, 'Writable stream: throwing strategy.highWaterMark getter');
39
40 test(() => {
41
42 for (const highWaterMark of [-1, -Infinity, NaN, 'foo', {}]) {
43 assert_throws(new RangeError(), () => {
44 new WritableStream({}, {
45 size() {
46 return 1;
47 },
48 highWaterMark
49 });
50 }, `construction should throw a RangeError for ${highWaterMark}`);
51 }
52 }, 'Writable stream: invalid strategy.highWaterMark');
53
54 promise_test(t => {
55 const ws = new WritableStream({}, {
56 size() {
57 throw error1;
58 },
59 highWaterMark: 5
60 });
61
62 const writer = ws.getWriter();
63
64 const p1 = promise_rejects(t, error1, writer.write('a'), 'write should reject with the thrown error');
65
66 const p2 = promise_rejects(t, error1, writer.closed, 'closed should reject wit h the thrown error');
67
68 return Promise.all([p1, p2]);
69 }, 'Writable stream: throwing strategy.size method');
70
71 promise_test(() => {
72 const sizes = [NaN, -Infinity, Infinity, -1];
73 return Promise.all(sizes.map(size => {
74 const ws = new WritableStream({}, {
75 size() {
76 return size;
77 },
78 highWaterMark: 5
79 });
80
81 const writer = ws.getWriter();
82
83 return writer.write('a').then(() => assert_unreached('write must reject'), w riteE => {
84 assert_equals(writeE.name, 'RangeError', `write must reject with a RangeEr ror for ${size}`);
85
86 return writer.closed.then(() => assert_unreached('write must reject'), clo sedE => {
87 assert_equals(closedE, writeE, `closed should reject with the same error as write`);
88 });
89 });
90 }));
91 }, 'Writable stream: invalid strategy.size return value');
92
93 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698