| OLD | NEW |
| 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 // File IO test player is used to test File IO CDM functionality. | 5 // File IO test player is used to test File IO CDM functionality. |
| 6 function FileIOTestPlayer(video, testConfig) { | 6 function FileIOTestPlayer(video, testConfig) { |
| 7 this.video = video; | 7 this.video = video; |
| 8 this.testConfig = testConfig; | 8 this.testConfig = testConfig; |
| 9 } | 9 } |
| 10 | 10 |
| 11 FileIOTestPlayer.prototype.init = function() { | 11 FileIOTestPlayer.prototype.init = function() { |
| 12 // Returns a promise. | 12 // Returns a promise. |
| 13 return PlayerUtils.initEMEPlayer(this); | 13 return PlayerUtils.initEMEPlayer(this); |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 FileIOTestPlayer.prototype.registerEventListeners = function() { | 16 FileIOTestPlayer.prototype.registerEventListeners = function() { |
| 17 // Returns a promise. | 17 // Returns a promise. |
| 18 return PlayerUtils.registerEMEEventListeners(this).then(function(result) { | 18 return PlayerUtils.registerEMEEventListeners(this); |
| 19 return PlayerUtils.registerPrefixedEMEEventListeners(this); | |
| 20 }); | |
| 21 }; | 19 }; |
| 22 | 20 |
| 23 handleMessage = function(message) { | 21 handleMessage = function(message) { |
| 24 // The test result is either '0' or '1' appended to the header. | 22 // The test result is either '0' or '1' appended to the header. |
| 25 var msg = Utils.convertToUint8Array(message.message); | 23 var msg = Utils.convertToUint8Array(message.message); |
| 26 if (Utils.hasPrefix(msg, FILE_IO_TEST_RESULT_HEADER)) { | 24 if (Utils.hasPrefix(msg, FILE_IO_TEST_RESULT_HEADER)) { |
| 27 if (msg.length != FILE_IO_TEST_RESULT_HEADER.length + 1) { | 25 if (msg.length != FILE_IO_TEST_RESULT_HEADER.length + 1) { |
| 28 Utils.failTest('Unexpected FileIOTest CDM message' + msg); | 26 Utils.failTest('Unexpected FileIOTest CDM message' + msg); |
| 29 return; | 27 return; |
| 30 } | 28 } |
| 31 var result_index = FILE_IO_TEST_RESULT_HEADER.length; | 29 var result_index = FILE_IO_TEST_RESULT_HEADER.length; |
| 32 var success = String.fromCharCode(msg[result_index]) == 1; | 30 var success = String.fromCharCode(msg[result_index]) == 1; |
| 33 Utils.timeLog('CDM file IO test: ' + (success ? 'Success' : 'Fail')); | 31 Utils.timeLog('CDM file IO test: ' + (success ? 'Success' : 'Fail')); |
| 34 if (success) | 32 if (success) |
| 35 Utils.setResultInTitle(FILE_IO_TEST_SUCCESS); | 33 Utils.setResultInTitle(FILE_IO_TEST_SUCCESS); |
| 36 else | 34 else |
| 37 Utils.failTest('File IO CDM message fail status.'); | 35 Utils.failTest('File IO CDM message fail status.'); |
| 38 } | 36 } |
| 39 }; | 37 }; |
| 40 | 38 |
| 41 // Check message for prefixed API. | |
| 42 FileIOTestPlayer.prototype.onWebkitKeyMessage = handleMessage; | |
| 43 | |
| 44 // Check message for unprefixed API. | |
| 45 FileIOTestPlayer.prototype.onMessage = handleMessage; | 39 FileIOTestPlayer.prototype.onMessage = handleMessage; |
| OLD | NEW |