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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/streams/count-queuing-strategy.js

Issue 2808853003: Remove Blink copies of readable-streams layout tests (Closed)
Patch Set: Restore rs-utils.js as it is used by fetch tests 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 test(() => {
8
9 new CountQueuingStrategy({ highWaterMark: 4 });
10
11 }, 'Can construct a CountQueuingStrategy with a valid high water mark');
12
13 test(() => {
14
15 for (const highWaterMark of [-Infinity, NaN, 'foo', {}, () => {}]) {
16 const strategy = new CountQueuingStrategy({ highWaterMark });
17 assert_equals(strategy.highWaterMark, highWaterMark, `${highWaterMark} gets set correctly`);
18 }
19
20 }, 'Can construct a CountQueuingStrategy with any value as its high water mark') ;
21
22 test(() => {
23
24 const highWaterMark = 1;
25 const highWaterMarkObjectGetter = {
26 get highWaterMark() { return highWaterMark; }
27 };
28 const error = new Error('wow!');
29 const highWaterMarkObjectGetterThrowing = {
30 get highWaterMark() { throw error; }
31 };
32
33 assert_throws({ name: 'TypeError' }, () => new CountQueuingStrategy(), 'constr uction fails with undefined');
34 assert_throws({ name: 'TypeError' }, () => new CountQueuingStrategy(null), 'co nstruction fails with null');
35 assert_throws({ name: 'Error' }, () => new CountQueuingStrategy(highWaterMarkO bjectGetterThrowing),
36 'construction fails with an object with a throwing highWaterMark getter');
37
38 // Should not fail:
39 new CountQueuingStrategy('potato');
40 new CountQueuingStrategy({});
41 new CountQueuingStrategy(highWaterMarkObjectGetter);
42
43 }, 'CountQueuingStrategy constructor behaves as expected with strange arguments' );
44
45
46 test(() => {
47
48 const thisValue = null;
49 const chunk = {
50 get byteLength() {
51 throw new TypeError('shouldn\'t be called');
52 }
53 };
54
55 assert_equals(CountQueuingStrategy.prototype.size.call(thisValue, chunk), 1);
56
57 }, 'CountQueuingStrategy.prototype.size should work generically on its this and its arguments');
58
59 test(() => {
60
61 const size = 1024;
62 const chunk = { byteLength: size };
63 const chunkGetter = {
64 get byteLength() { return size; }
65 };
66 const error = new Error('wow!');
67 const chunkGetterThrowing = {
68 get byteLength() { throw error; }
69 };
70
71 assert_equals(CountQueuingStrategy.prototype.size(), 1, 'size returns 1 with u ndefined');
72 assert_equals(CountQueuingStrategy.prototype.size(null), 1, 'size returns 1 wi th null');
73 assert_equals(CountQueuingStrategy.prototype.size('potato'), 1, 'size returns 1 with non-object type');
74 assert_equals(CountQueuingStrategy.prototype.size({}), 1, 'size returns 1 with empty object');
75 assert_equals(CountQueuingStrategy.prototype.size(chunk), 1, 'size returns 1 w ith a chunk');
76 assert_equals(CountQueuingStrategy.prototype.size(chunkGetter), 1, 'size retur ns 1 with chunk getter');
77 assert_equals(CountQueuingStrategy.prototype.size(chunkGetterThrowing), 1,
78 'size returns 1 with chunk getter that throws');
79
80 }, 'CountQueuingStrategy size behaves as expected with strange arguments');
81
82 test(() => {
83
84 const strategy = new CountQueuingStrategy({ highWaterMark: 4 });
85
86 assert_object_equals(Object.getOwnPropertyDescriptor(strategy, 'highWaterMark' ),
87 { value: 4, writable: true, enumerable: true, configurable: true },
88 'highWaterMark property should be a data property with the value passed the constructor');
89 assert_equals(typeof strategy.size, 'function');
90
91 }, 'CountQueuingStrategy instances have the correct properties');
92
93 test(() => {
94
95 const strategy = new CountQueuingStrategy({ highWaterMark: 4 });
96 assert_equals(strategy.highWaterMark, 4);
97
98 strategy.highWaterMark = 10;
99 assert_equals(strategy.highWaterMark, 10);
100
101 strategy.highWaterMark = 'banana';
102 assert_equals(strategy.highWaterMark, 'banana');
103
104 }, 'CountQueuingStrategy\'s highWaterMark property can be set to anything');
105
106 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698