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

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

Issue 1404523005: Implement author-constructible ReadableStream using V8 extras (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor test tweaks Created 5 years 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 test(() => {
8
9 const theError = new Error('a unique string');
10
11 assert_throws(theError, () => {
12 new ReadableStream({}, {
13 get size() {
14 throw theError;
15 },
16 highWaterMark: 5
17 });
18 }, 'construction should re-throw the error');
19
20 }, 'Readable stream: throwing strategy.size getter');
21
22 promise_test(() => {
23
24 const theError = new Error('a unique string');
25 const rs = new ReadableStream(
26 {
27 start(c) {
28 assert_throws(theError, () => c.enqueue('a'), 'enqueue should throw the error');
29 }
30 },
31 {
32 size() {
33 throw theError;
34 },
35 highWaterMark: 5
36 }
37 );
38
39 return rs.getReader().closed.catch(e => {
40 assert_equals(e, theError, 'closed should reject with the error');
41 });
42
43 }, 'Readable stream: throwing strategy.size method');
44
45 test(() => {
46
47 const theError = new Error('a unique string');
48
49 assert_throws(theError, () => {
50 new ReadableStream({}, {
51 size() {
52 return 1;
53 },
54 get highWaterMark() {
55 throw theError;
56 }
57 });
58 }, 'construction should re-throw the error');
59
60 }, 'Readable stream: throwing strategy.highWaterMark getter');
61
62 test(() => {
63
64 for (const highWaterMark of [-1, -Infinity]) {
65 assert_throws(new RangeError(), () => {
66 new ReadableStream({}, {
67 size() {
68 return 1;
69 },
70 highWaterMark
71 });
72 }, 'construction should throw a RangeError for ' + highWaterMark);
73 }
74
75 for (const highWaterMark of [NaN, 'foo', {}]) {
76 assert_throws(new TypeError(), () => {
77 new ReadableStream({}, {
78 size() {
79 return 1;
80 },
81 highWaterMark
82 });
83 }, 'construction should throw a TypeError for ' + highWaterMark);
84 }
85
86 }, 'Readable stream: invalid strategy.highWaterMark');
87
88 promise_test(() => {
89
90 const promises = [];
91 for (const size of [NaN, -Infinity, Infinity, -1]) {
92 let theError;
93 const rs = new ReadableStream(
94 {
95 start(c) {
96 try {
97 c.enqueue('hi');
98 assert_unreached('enqueue didn\'t throw');
99 } catch (error) {
100 assert_equals(error.name, 'RangeError', 'enqueue should throw a Rang eError for ' + size);
101 theError = error;
102 }
103 }
104 },
105 {
106 size() {
107 return size;
108 },
109 highWaterMark: 5
110 }
111 );
112
113 promises.push(rs.getReader().closed.catch(e => {
114 assert_equals(e, theError, 'closed should reject with the error for ' + si ze);
115 }));
116 }
117
118 return Promise.all(promises);
119
120 }, 'Readable stream: invalid strategy.size return value');
121
122 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698