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

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

Issue 2426813002: EME: Close existing sessions on CDM failure (Closed)
Patch Set: add test Created 4 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
« no previous file with comments | « media/test/data/eme_player_js/clearkey_player.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
21 var eventListenerFunction = player[eventListenerMap[eventName]]; 21 var eventListenerFunction = player[eventListenerMap[eventName]];
22 if (eventListenerFunction) { 22 if (eventListenerFunction) {
23 player.video.addEventListener(eventName, function(e) { 23 player.video.addEventListener(eventName, function(e) {
24 player[eventListenerMap[e.type]](e); 24 player[eventListenerMap[e.type]](e);
25 }); 25 });
26 } 26 }
27 } 27 }
28 28
29 player.video.addEventListener('error', function(error) { 29 player.video.addEventListener('error', function(error) {
30 // This most likely happens on pipeline failures (e.g. when the CDM 30 // This most likely happens on pipeline failures (e.g. when the CDM
31 // crashes). 31 // crashes). Don't report a failure if the test is expecting a crash.
32 Utils.timeLog('onHTMLElementError', error); 32 Utils.timeLog('onHTMLElementError', error);
33 Utils.failTest(error); 33 if (player.testConfig.keySystem != 'org.chromium.externalclearkey.crash') {
34 Utils.failTest(error);
35 }
34 }); 36 });
35 }; 37 };
36 38
37 // Register the necessary event handlers needed when playing encrypted content. 39 // Register the necessary event handlers needed when playing encrypted content.
38 // Returns a promise that resolves to the player. 40 // Returns a promise that resolves to the player.
39 PlayerUtils.registerEMEEventListeners = function(player) { 41 PlayerUtils.registerEMEEventListeners = function(player) {
40 player.video.addEventListener('encrypted', function(message) { 42 player.video.addEventListener('encrypted', function(message) {
41 43
42 function addMediaKeySessionListeners(mediaKeySession) { 44 function addMediaKeySessionListeners(mediaKeySession) {
43 mediaKeySession.addEventListener('message', function(message) { 45 mediaKeySession.addEventListener('message', function(message) {
(...skipping 26 matching lines...) Expand all
70 }, 72 },
71 function(error) { Utils.failTest(error, EME_LOAD_FAILED); }); 73 function(error) { Utils.failTest(error, EME_LOAD_FAILED); });
72 } else { 74 } else {
73 Utils.timeLog('Creating new media key session for initDataType: ' + 75 Utils.timeLog('Creating new media key session for initDataType: ' +
74 message.initDataType + ', initData: ' + 76 message.initDataType + ', initData: ' +
75 Utils.getHexString(new Uint8Array(message.initData))); 77 Utils.getHexString(new Uint8Array(message.initData)));
76 var session = message.target.mediaKeys.createSession(); 78 var session = message.target.mediaKeys.createSession();
77 addMediaKeySessionListeners(session); 79 addMediaKeySessionListeners(session);
78 session.generateRequest(message.initDataType, message.initData) 80 session.generateRequest(message.initDataType, message.initData)
79 .catch(function(error) { 81 .catch(function(error) {
80 // Ignore the error if a crash is expected. This ensures that 82 // If a crash is expected, wait for the session to be closed.
xhwang 2016/10/20 22:38:59 We added the crash test to make sure if the CDM cr
jrummell 2016/11/01 01:08:46 Yes. Restored the original tests, added 2 new ones
81 // the decoder actually detects and reports the error. 83 if (this.testConfig.keySystem ==
82 if (this.testConfig.keySystem !=
83 'org.chromium.externalclearkey.crash') { 84 'org.chromium.externalclearkey.crash') {
85 session.closed.then(
86 function(result) {
87 Utils.setResultInTitle('SESSION_CLOSED');
88 },
89 function(error) { Utils.failTest(error); });
90 } else {
91 // Failure unexpected.
84 Utils.failTest(error, EME_GENERATEREQUEST_FAILED); 92 Utils.failTest(error, EME_GENERATEREQUEST_FAILED);
85 } 93 }
86 }); 94 });
87 } 95 }
88 } catch (e) { 96 } catch (e) {
89 Utils.failTest(e); 97 Utils.failTest(e);
90 } 98 }
91 }); 99 });
92 100
93 this.registerDefaultEventListeners(player); 101 this.registerDefaultEventListeners(player);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 case OUTPUT_PROTECTION_TEST_KEYSYSTEM: 212 case OUTPUT_PROTECTION_TEST_KEYSYSTEM:
205 return UnitTestPlayer; 213 return UnitTestPlayer;
206 default: 214 default:
207 Utils.timeLog(keySystem + ' is not a known key system'); 215 Utils.timeLog(keySystem + ' is not a known key system');
208 return ClearKeyPlayer; 216 return ClearKeyPlayer;
209 } 217 }
210 } 218 }
211 var Player = getPlayerType(testConfig.keySystem); 219 var Player = getPlayerType(testConfig.keySystem);
212 return new Player(video, testConfig); 220 return new Player(video, testConfig);
213 }; 221 };
OLDNEW
« no previous file with comments | « media/test/data/eme_player_js/clearkey_player.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698