File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,24 @@ impl IntoUnderlyingByteSource {
27
27
}
28
28
}
29
29
30
+ #[ wasm_bindgen( inline_js = "export function bytes_literal() { return \" bytes\" ; }" ) ]
31
+ extern "C" {
32
+ fn bytes_literal ( ) -> JsValue ;
33
+ }
34
+
30
35
#[ allow( clippy:: await_holding_refcell_ref) ]
31
36
#[ wasm_bindgen]
32
37
impl IntoUnderlyingByteSource {
38
+ // Chromium has a bug where it only recognizes `new ReadableStream({ type: "bytes" })`,
39
+ // not `new ReadableStream({ type: "by" + "tes" })` or any other non-literal string
40
+ // that equals "bytes". Therefore, we cannot return a Rust `String` here, since
41
+ // that needs to be converted to a JavaScript string at runtime.
42
+ // Instead, we call a function that returns the desired string literal as a `JsValue`
43
+ // and pass that value around. It looks silly, but it works.
44
+ // See https://crbug.com/1187774
33
45
#[ wasm_bindgen( getter, js_name = type ) ]
34
- pub fn type_ ( & self ) -> String {
35
- "bytes" . into ( )
46
+ pub fn type_ ( & self ) -> JsValue {
47
+ bytes_literal ( )
36
48
}
37
49
38
50
#[ wasm_bindgen( getter, js_name = autoAllocateChunkSize) ]
You can’t perform that action at this time.
0 commit comments