Skip to content

Commit 56e9e48

Browse files
Jake ChampionJakeChampion
authored andcommitted
Add support for deflate-raw format for CompressionStream
1 parent de7cab1 commit 56e9e48

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3336,6 +3336,7 @@ enum { Transform, Format, State, Buffer, Count };
33363336
enum class Format {
33373337
GZIP,
33383338
Deflate,
3339+
DeflateRaw,
33393340
};
33403341

33413342
// Using compression level 2, as per the reasoning here:
@@ -3578,6 +3579,8 @@ JSObject *create(JSContext *cx, HandleObject stream, Format format) {
35783579
int window_bits = 15;
35793580
if (format == Format::GZIP) {
35803581
window_bits += 16;
3582+
} else if (format == Format::DeflateRaw) {
3583+
window_bits = -15;
35813584
}
35823585

35833586
int err =
@@ -3604,7 +3607,9 @@ bool constructor(JSContext *cx, unsigned argc, Value *vp) {
36043607
return false;
36053608

36063609
Format format;
3607-
if (!strcmp(format_chars.get(), "deflate")) {
3610+
if (!strcmp(format_chars.get(), "deflate-raw")) {
3611+
format = Format::DeflateRaw;
3612+
} else if (!strcmp(format_chars.get(), "deflate")) {
36083613
format = Format::Deflate;
36093614
} else if (!strcmp(format_chars.get(), "gzip")) {
36103615
format = Format::GZIP;

tests/wpt-harness/expectations/compression/compression-bad-chunks.tentative.any.js.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"status": 0
77
},
88
"chunk of type undefined should error the stream for deflate-raw": {
9-
"status": 1
9+
"status": 0
1010
},
1111
"chunk of type null should error the stream for gzip": {
1212
"status": 0
@@ -15,7 +15,7 @@
1515
"status": 0
1616
},
1717
"chunk of type null should error the stream for deflate-raw": {
18-
"status": 1
18+
"status": 0
1919
},
2020
"chunk of type numeric should error the stream for gzip": {
2121
"status": 0
@@ -24,7 +24,7 @@
2424
"status": 0
2525
},
2626
"chunk of type numeric should error the stream for deflate-raw": {
27-
"status": 1
27+
"status": 0
2828
},
2929
"chunk of type object, not BufferSource should error the stream for gzip": {
3030
"status": 0
@@ -33,7 +33,7 @@
3333
"status": 0
3434
},
3535
"chunk of type object, not BufferSource should error the stream for deflate-raw": {
36-
"status": 1
36+
"status": 0
3737
},
3838
"chunk of type array should error the stream for gzip": {
3939
"status": 0
@@ -42,7 +42,7 @@
4242
"status": 0
4343
},
4444
"chunk of type array should error the stream for deflate-raw": {
45-
"status": 1
45+
"status": 0
4646
},
4747
"chunk of type SharedArrayBuffer should error the stream for gzip": {
4848
"status": 1

tests/wpt-harness/expectations/compression/compression-including-empty-chunk.tentative.any.js.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"status": 0
77
},
88
"the result of compressing [,Hello,Hello] with deflate-raw should be 'HelloHello'": {
9-
"status": 1
9+
"status": 0
1010
},
1111
"the result of compressing [Hello,,Hello] with deflate should be 'HelloHello'": {
1212
"status": 0
@@ -15,7 +15,7 @@
1515
"status": 0
1616
},
1717
"the result of compressing [Hello,,Hello] with deflate-raw should be 'HelloHello'": {
18-
"status": 1
18+
"status": 0
1919
},
2020
"the result of compressing [Hello,Hello,] with deflate should be 'HelloHello'": {
2121
"status": 0
@@ -24,6 +24,6 @@
2424
"status": 0
2525
},
2626
"the result of compressing [Hello,Hello,] with deflate-raw should be 'HelloHello'": {
27-
"status": 1
27+
"status": 0
2828
}
2929
}

tests/wpt-harness/expectations/compression/compression-multiple-chunks.tentative.any.js.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"status": 0
77
},
88
"compressing 2 chunks with deflate-raw should work": {
9-
"status": 1
9+
"status": 0
1010
},
1111
"compressing 3 chunks with deflate should work": {
1212
"status": 0
@@ -15,7 +15,7 @@
1515
"status": 0
1616
},
1717
"compressing 3 chunks with deflate-raw should work": {
18-
"status": 1
18+
"status": 0
1919
},
2020
"compressing 4 chunks with deflate should work": {
2121
"status": 0
@@ -24,7 +24,7 @@
2424
"status": 0
2525
},
2626
"compressing 4 chunks with deflate-raw should work": {
27-
"status": 1
27+
"status": 0
2828
},
2929
"compressing 5 chunks with deflate should work": {
3030
"status": 0
@@ -33,7 +33,7 @@
3333
"status": 0
3434
},
3535
"compressing 5 chunks with deflate-raw should work": {
36-
"status": 1
36+
"status": 0
3737
},
3838
"compressing 6 chunks with deflate should work": {
3939
"status": 0
@@ -42,7 +42,7 @@
4242
"status": 0
4343
},
4444
"compressing 6 chunks with deflate-raw should work": {
45-
"status": 1
45+
"status": 0
4646
},
4747
"compressing 7 chunks with deflate should work": {
4848
"status": 0
@@ -51,7 +51,7 @@
5151
"status": 0
5252
},
5353
"compressing 7 chunks with deflate-raw should work": {
54-
"status": 1
54+
"status": 0
5555
},
5656
"compressing 8 chunks with deflate should work": {
5757
"status": 0
@@ -60,7 +60,7 @@
6060
"status": 0
6161
},
6262
"compressing 8 chunks with deflate-raw should work": {
63-
"status": 1
63+
"status": 0
6464
},
6565
"compressing 9 chunks with deflate should work": {
6666
"status": 0
@@ -69,7 +69,7 @@
6969
"status": 0
7070
},
7171
"compressing 9 chunks with deflate-raw should work": {
72-
"status": 1
72+
"status": 0
7373
},
7474
"compressing 10 chunks with deflate should work": {
7575
"status": 0
@@ -78,7 +78,7 @@
7878
"status": 0
7979
},
8080
"compressing 10 chunks with deflate-raw should work": {
81-
"status": 1
81+
"status": 0
8282
},
8383
"compressing 11 chunks with deflate should work": {
8484
"status": 0
@@ -87,7 +87,7 @@
8787
"status": 0
8888
},
8989
"compressing 11 chunks with deflate-raw should work": {
90-
"status": 1
90+
"status": 0
9191
},
9292
"compressing 12 chunks with deflate should work": {
9393
"status": 0
@@ -96,7 +96,7 @@
9696
"status": 0
9797
},
9898
"compressing 12 chunks with deflate-raw should work": {
99-
"status": 1
99+
"status": 0
100100
},
101101
"compressing 13 chunks with deflate should work": {
102102
"status": 0
@@ -105,7 +105,7 @@
105105
"status": 0
106106
},
107107
"compressing 13 chunks with deflate-raw should work": {
108-
"status": 1
108+
"status": 0
109109
},
110110
"compressing 14 chunks with deflate should work": {
111111
"status": 0
@@ -114,7 +114,7 @@
114114
"status": 0
115115
},
116116
"compressing 14 chunks with deflate-raw should work": {
117-
"status": 1
117+
"status": 0
118118
},
119119
"compressing 15 chunks with deflate should work": {
120120
"status": 0
@@ -123,7 +123,7 @@
123123
"status": 0
124124
},
125125
"compressing 15 chunks with deflate-raw should work": {
126-
"status": 1
126+
"status": 0
127127
},
128128
"compressing 16 chunks with deflate should work": {
129129
"status": 0
@@ -132,6 +132,6 @@
132132
"status": 0
133133
},
134134
"compressing 16 chunks with deflate-raw should work": {
135-
"status": 1
135+
"status": 0
136136
}
137137
}

tests/wpt-harness/expectations/compression/compression-output-length.tentative.any.js.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"status": 0
77
},
88
"the length of deflated (with -raw) data should be shorter than that of the original data": {
9-
"status": 1
9+
"status": 0
1010
}
1111
}

0 commit comments

Comments
 (0)