Polyfill example


As an example I created an (admittedly messy) polyfill for the pseristent
session types for Clear Key.

You can see it here:

If you include this script, it will add support for the persistent session
types to a browser that supports only the "temporary" session type for
Clear Key. Since Clear Key is not robust, we can implement the persistence
/ usage recording in JS.

My persistent session type test cases (in the same branch) pass with this

There are some issues, which I can work on if there is interest in the
general approach:

   - I don't have test cases for retrieving a MediaKeySession in a new
   browsing session. I'm not sure how this should be done in
   web-platform-tests ? For example, how do we test that IndexedDB or even
   localStorage actually store data across browsing sessions ?
   - (As a consequence of the above, there are likely some bugs remaining
   in the polyfill)
   - I made up the release message format for the persistent-license
   session type, which is not in the specification for Clear Key. I wonder if
   we should add it ? I will open an issue to track discussion of that.
   - Exactly which keys are being used is not exposed to JS, so for the
   moment the persistent-usage-record case is recording all the time that an
   attached media element is playing content, independent of whether that
   content is encrypted with the keys available in the session. (I'm not sure
   how we could fix this, other than by intercepting MSE and parsing the
   stream for key ids and timestamps. This would be lot of work and I think
   unnecessary for proving the design / interoperability of the API).
   - Chrome doesn't seem to fire keystatuseschange on session close (or I
   have mis-understood something or there is a bug in the polyfill) and so I
   updated my test to match the implementation rather than the specification.
   One or the other needs to be fixed.

I do think this experiment demonstrates that we can run tests against an
implementation which is part native part Javascript and I think this is
valid for demonstrating the API design. IIUC, some chunks of the browser
itself are implemented in JS anyway.


Received on Thursday, 23 June 2016 06:34:18 UTC