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