<!DOCTYPE html>
<html>
    <head>
        <title>MediaKeys</title>
        <script src=../video-test.js></script>
        <script>
            function stringToUint8Array(str)
            {
                var arr=[];
                for(var i=0,j=str.length;i<j;++i)
                  arr[i]=str.charCodeAt(i);
                return new Uint8Array(arr);
            }

            var mediaKeys;
            var mediaKeySession;
            var initData = stringToUint8Array('mock');
            var invalidKey = stringToUint8Array('invalid');
            var validKey = stringToUint8Array('1234567890abcdef');

            function runTest() 
            {
                run('mediaKeys = new MediaKeys("org.w3.clearkey")');
                run('mediaKeySession = mediaKeys.createSession("video/webm", initData)');
                waitForEvent('webkitkeymessage', keyMessage, false, false, mediaKeySession);
                waitForEvent('webkitkeyerror', keyError, false, false, mediaKeySession);
                waitForEvent('webkitkeyadded', null, true, false, mediaKeySession);
            }

            function keyMessage(event)
            {
                run('mediaKeySession.update(invalidKey)');
            }

            function keyError(event)
            {
                run('mediaKeySession.update(validKey)');
            }
        </script>
    </head>
    <body onload="runTest()">
        <p>This tests the events created by MediaKeys.</p>
    </body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <title>MediaKeys</title>
        <script src=../video-test.js></script>
        <script>
            function stringToUint8Array(str)
            {
                var arr=[];
                for(var i=0,j=str.length;i<j;++i)
                  arr[i]=str.charCodeAt(i);
                return new Uint8Array(arr);
            }

            var mediaKeys;
            var mediaKeySession;
            var initData = stringToUint8Array('mock');
            var invalidKey = stringToUint8Array('invalid');
            var validKey = stringToUint8Array(
                '{"keys":[{"kty":"oct","kid":"AAECAw==","k":"MTIzNDU2Nzg5MGFiY2RlZg=="}]}');

            function runTest() 
            {
                run('mediaKeys = new MediaKeys("org.w3.clearkey")');
                run('mediaKeySession = mediaKeys.createSession("video/webm", initData)');
                waitForEvent('webkitkeymessage', keyMessage, false, false, mediaKeySession);
                waitForEvent('webkitkeyerror', keyError, false, false, mediaKeySession);
                waitForEvent('webkitkeyadded', null, true, false, mediaKeySession);
            }

            function keyMessage(event)
            {
                run('mediaKeySession.update(invalidKey)');
            }

            function keyError(event)
            {
                run('mediaKeySession.update(validKey)');
            }
        </script>
    </head>
    <body onload="runTest()">
        <p>This tests the events created by MediaKeys.</p>
    </body>
</html>
Update encrypted media tests to use JSON Web Key
Update encrypted media tests to use JSON Web Key

The EME spec now specifies that update() calls use the JSON Web Key (JWK)
representation of the symmetric key, rather than passing in a raw key.
Code has already been updated to support either, but the tests need to
change to match the latest spec.

BUG=267143

TEST=The test still passes.

Review URL: https://chromiumcodereview.appspot.com/23892014

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@158055 bbb929c8-8fbe-4397-9dbb-9b2b20218538
