Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: media/test/data/eme_player_js/player_utils.js

Issue 641443002: Add unprefixed EME tests for LoadSession() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The PlayerUtils provides utility functions to binding common media events 5 // The PlayerUtils provides utility functions to binding common media events
6 // to specific player functions. It also provides functions to load media source 6 // to specific player functions. It also provides functions to load media source
7 // base on test configurations. 7 // base on test configurations.
8 var PlayerUtils = new function() { 8 var PlayerUtils = new function() {
9 } 9 }
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 player.onMessage(message); 50 player.onMessage(message);
51 }); 51 });
52 mediaKeySession.addEventListener('error', function(error) { 52 mediaKeySession.addEventListener('error', function(error) {
53 Utils.failTest(error, KEY_ERROR); 53 Utils.failTest(error, KEY_ERROR);
54 }); 54 });
55 } 55 }
56 56
57 // TODO(sandersd): Stop checking contentType once we complete the switch to 57 // TODO(sandersd): Stop checking contentType once we complete the switch to
58 // using the 'encrypted' event. 58 // using the 'encrypted' event.
59 var init_data_type = message.initDataType || message.contentType; 59 var init_data_type = message.initDataType || message.contentType;
60 Utils.timeLog('Creating new media key session for initDataType: ' +
61 init_data_type + ', initData: ' +
62 Utils.getHexString(new Uint8Array(message.initData)));
63 try { 60 try {
64 if (message.target.mediaKeys.createSession.length == 0) { 61 if (player.testConfig.sessionToLoad) {
65 // FIXME(jrummell): Remove this test (and else branch) once blink 62 Utils.timeLog('Loading session: ' + player.testConfig.sessionToLoad);
66 // uses the new API. 63 var session = message.target.mediaKeys.createSession('persistent');
64 addMediaKeySessionListeners(session);
65 session.load(player.testConfig.sessionToLoad)
66 .catch(function(error) { Utils.failTest(error, KEY_ERROR); });
ddorwin 2014/10/08 22:04:28 In theory, these catches aren't necessary because
jrummell 2014/10/16 18:53:58 Failed promises don't throw, so line 79 won't run.
67 } else {
68 Utils.timeLog('Creating new media key session for initDataType: ' +
69 init_data_type + ', initData: ' +
70 Utils.getHexString(new Uint8Array(message.initData)));
67 var session = message.target.mediaKeys.createSession(); 71 var session = message.target.mediaKeys.createSession();
68 addMediaKeySessionListeners(session); 72 addMediaKeySessionListeners(session);
69 session.generateRequest(init_data_type, message.initData) 73 session.generateRequest(init_data_type, message.initData)
70 .catch(function(error) { 74 .catch(function(error) {
71 Utils.failTest(error, KEY_ERROR); 75 Utils.failTest(error, KEY_ERROR);
72 }); 76 });
73 } else {
74 var session = message.target.mediaKeys.createSession(
75 init_data_type, message.initData);
76 session.then(addMediaKeySessionListeners)
77 .catch(function(error) {
78 Utils.failTest(error, KEY_ERROR);
79 });
80 } 77 }
81 } catch (e) { 78 } catch (e) {
82 Utils.failTest(e); 79 Utils.failTest(e);
83 } 80 }
84 } 81 }
85 82
86 // TODO(sandersd): Stop registering 'needkey' after it is renamed to 83 // TODO(sandersd): Stop registering 'needkey' after it is renamed to
87 // 'encrypted'. 84 // 'encrypted'.
88 if (player.video.onencrypted) { 85 if (player.video.onencrypted) {
89 player.video.addEventListener('encrypted', encrypted_handler); 86 player.video.addEventListener('encrypted', encrypted_handler);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 default: 190 default:
194 Utils.timeLog(keySystem + ' is not a known key system'); 191 Utils.timeLog(keySystem + ' is not a known key system');
195 if (usePrefixedEME) 192 if (usePrefixedEME)
196 return PrefixedClearKeyPlayer; 193 return PrefixedClearKeyPlayer;
197 return ClearKeyPlayer; 194 return ClearKeyPlayer;
198 } 195 }
199 } 196 }
200 var Player = getPlayerType(testConfig.keySystem); 197 var Player = getPlayerType(testConfig.keySystem);
201 return new Player(video, testConfig); 198 return new Player(video, testConfig);
202 }; 199 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698