Commit f492b05
committed
fix: use binaryType correctly
The `.binaryType` field on the `RTCDataChannel` class defines what
type the `.data` field on emitted `MessageEvent`s will be.
It's either `arraybuffer` (the default) or `blob`.
Docs: https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/binaryType
1. Switches the default to `arraybuffer`
2. Converts incoming data to the correct type based on the `binaryType`
I've done my best to assert the right types/values in the "P2P test"
in `polyfill.test.ts`.
Because getting the binary data out of a `Blob` is an async operation
I had to make the test async, but it doesn't fit very well with the
current nature of the test.
TBH that test is very complicated and would be much better off split
into multiple smaller tests, each testing one thing.1 parent 5eee147 commit f492b05
File tree
2 files changed
+243
-202
lines changed- src/polyfill
- test/jest-tests
2 files changed
+243
-202
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
79 | 97 | | |
80 | 98 | | |
81 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
| |||
0 commit comments