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

Unified Diff: media/test/data/eme_player_js/utils.js

Issue 405733003: Update browser tests to support upcoming EME parameter type changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/test/data/eme_player_js/widevine_player.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/test/data/eme_player_js/utils.js
diff --git a/media/test/data/eme_player_js/utils.js b/media/test/data/eme_player_js/utils.js
index e664593e8e56c6536a090817d4fc6dccc41ccb01..491bac7892a7370b9d23809e7284384f3996c759 100644
--- a/media/test/data/eme_player_js/utils.js
+++ b/media/test/data/eme_player_js/utils.js
@@ -30,11 +30,16 @@ Utils.convertToArray = function(input) {
};
Utils.convertToUint8Array = function(msg) {
- var ans = new Uint8Array(msg.length);
- for (var i = 0; i < msg.length; i++) {
- ans[i] = msg.charCodeAt(i);
+ if (typeof msg == 'string') {
+ var ans = new Uint8Array(msg.length);
+ for (var i = 0; i < msg.length; i++) {
+ ans[i] = msg.charCodeAt(i);
+ }
+ return ans;
}
- return ans;
+ // Assume it is an ArrayBuffer or ArrayBufferView. If it already is a
+ // Uint8Array, this will just make a copy of the view.
+ return new Uint8Array(msg);
};
Utils.createJWKData = function(keyId, key) {
@@ -150,7 +155,7 @@ Utils.getHexString = function(uintArray) {
};
Utils.getInitDataFromMessage = function(message, mediaType) {
- var initData = message.message;
+ var initData = Utils.convertToUint8Array(message.message);
if (mediaType.indexOf('mp4') != -1) {
// Temporary hack for Clear Key in v0.1.
// If content uses mp4, then message.message is PSSH data. Instead of
@@ -172,7 +177,7 @@ Utils.installTitleEventHandler = function(element, event) {
};
Utils.isHeartBeatMessage = function(msg) {
- return Utils.hasPrefix(msg, HEART_BEAT_HEADER);
+ return Utils.hasPrefix(Utils.convertToUint8Array(msg), HEART_BEAT_HEADER);
};
Utils.resetTitleChange = function() {
« no previous file with comments | « no previous file | media/test/data/eme_player_js/widevine_player.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698