Firefox has supported
getStats to the spec for a couple of years now, and Chrome Canary finally has a spec-compliant version, so it’s a good time to check in how to write code that (soon!) will work across browsers.
- It uses promises (the callback version was removed from the spec!)
- You iterate on a maplike stats report object.
- Type fields have hyphens. E.g.
Oh, goodness, I hear you say. adapter.js to the rescue. Here’s an example that works in Firefox and Chrome Canary:
Click the “Result” tab above to see it run. Tick the “Mute” checkbox and see if your browser stops sending video packets!
There’s still a lot of work to do. Firefox supports only a subset of what the spec mandates. The point of this blog however, is to help you write spec-compliant code, so we all converge on the spec, for a healthier web.