Chromium Code Reviews| 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 // Global test configuration used by media players. On each test run call | 5 // Global test configuration used by media players. On each test run call |
| 6 // TestConfig.init() to load new test configuration from the test page. | 6 // TestConfig.init() to load new test configuration from the test page. |
| 7 var TestConfig = new function() { | 7 var TestConfig = new function() { |
| 8 this.mediaFile = null; | 8 this.mediaFile = null; |
| 9 this.keySystem = null; | 9 this.keySystem = null; |
| 10 this.mediaType = null; | 10 this.mediaType = null; |
| 11 this.licenseServer = null; | 11 this.licenseServerURL = null; |
| 12 this.useSRC = false; | 12 this.useSRC = false; |
| 13 this.usePrefixedEME = false; | 13 this.usePrefixedEME = false; |
| 14 this.runFPS = false | |
| 14 } | 15 } |
| 15 | 16 |
| 16 TestConfig.updateDocument = function() { | 17 TestConfig.loadQueryParams = function() { |
| 17 Utils.addOptions(KEYSYSTEM_ELEMENT_ID, KEY_SYSTEMS); | |
| 18 Utils.addOptions(MEDIA_TYPE_ELEMENT_ID, MEDIA_TYPES); | |
| 19 Utils.addOptions(USE_PREFIXED_EME_ID, EME_VERSIONS_OPTIONS); | |
| 20 | |
| 21 // Load query parameters and set default values. | 18 // Load query parameters and set default values. |
| 22 var r = /([^&=]+)=?([^&]*)/g; | 19 var r = /([^&=]+)=?([^&]*)/g; |
| 23 // Lambda function for decoding extracted match values. Replaces '+' with | 20 // Lambda function for decoding extracted match values. Replaces '+' with |
| 24 // space so decodeURIComponent functions properly. | 21 // space so decodeURIComponent functions properly. |
| 25 var decodeURI = function decodeURI(s) { | 22 var decodeURI = function decodeURI(s) { |
| 26 return decodeURIComponent(s.replace(/\+/g, ' ')); | 23 return decodeURIComponent(s.replace(/\+/g, ' ')); |
| 27 }; | 24 }; |
| 28 var match; | 25 var match; |
| 29 var params = {}; | 26 var params = {}; |
|
jrummell
2014/05/29 21:45:05
Is params needed anymore?
shadi
2014/05/31 00:31:37
Done.
| |
| 30 while (match = r.exec(window.location.search.substring(1))) | 27 while (match = r.exec(window.location.search.substring(1))) |
| 31 params[decodeURI(match[1])] = decodeURI(match[2]); | 28 this[decodeURI(match[1])] = decodeURI(match[2]); |
| 29 | |
| 30 this.useSRC = this.useSRC == '1' || this.useSRC == 'true'; | |
| 31 this.usePrefixedEME = | |
| 32 this.usePrefixedEME == '1' || this.usePrefixedEME == 'true'; | |
| 33 }; | |
| 34 | |
| 35 TestConfig.updateDocument = function() { | |
| 36 this.loadQueryParams(); | |
| 37 Utils.addOptions(KEYSYSTEM_ELEMENT_ID, KEY_SYSTEMS); | |
| 38 Utils.addOptions(MEDIA_TYPE_ELEMENT_ID, MEDIA_TYPES); | |
| 39 Utils.addOptions(USE_PREFIXED_EME_ID, EME_VERSIONS_OPTIONS); | |
| 32 | 40 |
| 33 document.getElementById(MEDIA_FILE_ELEMENT_ID).value = | 41 document.getElementById(MEDIA_FILE_ELEMENT_ID).value = |
| 34 params.mediaFile || DEFAULT_MEDIA_FILE; | 42 this.mediaFile || DEFAULT_MEDIA_FILE; |
| 35 | 43 |
| 36 document.getElementById(LICENSE_SERVER_ELEMENT_ID).value = | 44 document.getElementById(LICENSE_SERVER_ELEMENT_ID).value = |
| 37 params.licenseServer || DEFAULT_LICENSE_SERVER; | 45 this.licenseServerURL || DEFAULT_LICENSE_SERVER; |
| 38 | 46 |
| 39 if (params.keySystem) | 47 if (this.keySystem) |
| 40 document.getElementById(KEYSYSTEM_ELEMENT_ID).value = params.keySystem; | 48 Utils.ensureOptionInList(KEYSYSTEM_ELEMENT_ID, this.keySystem); |
| 41 if (params.mediaType) | 49 // document.getElementById(KEYSYSTEM_ELEMENT_ID).value = this.keySystem; |
| 42 document.getElementById(MEDIA_TYPE_ELEMENT_ID).value = params.mediaType; | 50 if (this.mediaType) |
| 43 if (params.useSRC) { | 51 Utils.ensureOptionInList(MEDIA_TYPE_ELEMENT_ID, this.mediaType); |
| 44 params.useSRC = params.useSRC == '1' || params.useSRC == 'true'; | 52 //document.getElementById(MEDIA_TYPE_ELEMENT_ID).value = this.mediaType; |
| 45 document.getElementById(USE_SRC_ELEMENT_ID).value = params.useSRC; | 53 document.getElementById(USE_SRC_ELEMENT_ID).value = this.useSRC; |
| 46 } | 54 document.getElementById(USE_PREFIXED_EME_ID).value = this.usePrefixedEME; |
| 47 if (params.usePrefixedEME) { | |
| 48 params.usePrefixedEME = | |
| 49 params.usePrefixedEME == '1' || params.usePrefixedEME == 'true'; | |
| 50 document.getElementById(USE_PREFIXED_EME_ID).value = params.usePrefixedEME; | |
| 51 } | |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 TestConfig.init = function() { | 57 TestConfig.init = function() { |
| 55 // Reload test configuration from document. | 58 // Reload test configuration from document. |
| 56 this.mediaFile = document.getElementById(MEDIA_FILE_ELEMENT_ID).value; | 59 this.mediaFile = document.getElementById(MEDIA_FILE_ELEMENT_ID).value; |
| 57 this.keySystem = document.getElementById(KEYSYSTEM_ELEMENT_ID).value; | 60 this.keySystem = document.getElementById(KEYSYSTEM_ELEMENT_ID).value; |
| 58 this.mediaType = document.getElementById(MEDIA_TYPE_ELEMENT_ID).value; | 61 this.mediaType = document.getElementById(MEDIA_TYPE_ELEMENT_ID).value; |
| 59 this.useSRC = document.getElementById(USE_SRC_ELEMENT_ID).value == 'true'; | 62 this.useSRC = document.getElementById(USE_SRC_ELEMENT_ID).value == 'true'; |
| 60 this.usePrefixedEME = | 63 this.usePrefixedEME = |
| 61 document.getElementById(USE_PREFIXED_EME_ID).value == 'true'; | 64 document.getElementById(USE_PREFIXED_EME_ID).value == 'true'; |
| 62 this.licenseServer = document.getElementById(LICENSE_SERVER_ELEMENT_ID).value; | 65 this.licenseServerURL = |
| 66 document.getElementById(LICENSE_SERVER_ELEMENT_ID).value; | |
| 63 }; | 67 }; |
| OLD | NEW |