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 // Utils provide logging functions and other JS functions commonly used by the | 5 // Utils provide logging functions and other JS functions commonly used by the |
| 6 // app and media players. | 6 // app and media players. |
| 7 var Utils = new function() { | 7 var Utils = new function() { |
| 8 this.titleChanged = false; | 8 this.titleChanged = false; |
| 9 }; | 9 }; |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 // The list does not have the option, let's add it and select it. | 120 // The list does not have the option, let's add it and select it. |
| 121 var optionElement = new Option(option, option); | 121 var optionElement = new Option(option, option); |
| 122 optionElement.title = option; | 122 optionElement.title = option; |
| 123 selectElement.options.add(optionElement); | 123 selectElement.options.add(optionElement); |
| 124 selectElement.value = option; | 124 selectElement.value = option; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 Utils.failTest = function(msg, newTitle) { | 127 Utils.failTest = function(msg, newTitle) { |
|
ddorwin
2015/07/09 00:29:36
See below. We should comment that this should only
jrummell
2015/07/10 00:16:50
Acknowledged.
| |
| 128 var failMessage = 'FAIL: '; | 128 var failMessage = 'FAIL: '; |
| 129 var title = 'FAILED'; | 129 var title = 'FAILED'; |
| 130 // Handle exception messages; | 130 // Handle exception messages; |
| 131 if (msg.message) { | 131 if (msg.message) { |
| 132 title = msg.name || 'Error'; | 132 title = msg.name || 'Error'; |
| 133 failMessage += title + ' ' + msg.message; | 133 failMessage += title + ' ' + msg.message; |
| 134 } else if (msg instanceof Event) { | 134 } else if (msg instanceof Event) { |
| 135 // Handle failing events. | 135 // Handle failing events. |
| 136 failMessage = msg.target + '.' + msg.type; | 136 failMessage = msg.target + '.' + msg.type; |
| 137 title = msg.type; | 137 title = msg.type; |
| 138 } else { | 138 } else { |
| 139 failMessage += msg; | 139 failMessage += msg; |
| 140 } | 140 } |
| 141 // Force newTitle if passed. | 141 // Force newTitle if passed. |
| 142 title = newTitle || title; | 142 title = newTitle || title; |
| 143 // Log failure. | 143 // Log failure. |
| 144 Utils.documentLog(failMessage, false); | 144 Utils.documentLog(failMessage, false); |
| 145 console.log(failMessage, msg); | 145 console.log(failMessage, msg); |
| 146 Utils.setResultInTitle(title); | 146 Utils.setResultInTitle(title); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 Utils.reportResult = function(msg, newTitle) { | |
|
ddorwin
2015/07/09 00:29:36
Please add some comments. For example, reports a r
jrummell
2015/07/10 00:16:50
Removed function.
| |
| 150 Utils.timeLog(msg); | |
|
ddorwin
2015/07/09 00:29:35
Continuing from the first comment: If this really
jrummell
2015/07/10 00:16:50
Removed function.
| |
| 151 Utils.setResultInTitle(newTitle); | |
| 152 }; | |
| 153 | |
| 149 Utils.getCurrentTimeString = function() { | 154 Utils.getCurrentTimeString = function() { |
| 150 var date = new Date(); | 155 var date = new Date(); |
| 151 var hours = ('0' + date.getHours()).slice(-2); | 156 var hours = ('0' + date.getHours()).slice(-2); |
| 152 var minutes = ('0' + date.getMinutes()).slice(-2); | 157 var minutes = ('0' + date.getMinutes()).slice(-2); |
| 153 var secs = ('0' + date.getSeconds()).slice(-2); | 158 var secs = ('0' + date.getSeconds()).slice(-2); |
| 154 var milliSecs = ('00' + date.getMilliseconds()).slice(-3); | 159 var milliSecs = ('00' + date.getMilliseconds()).slice(-3); |
| 155 return hours + ':' + minutes + ':' + secs + '.' + milliSecs; | 160 return hours + ':' + minutes + ':' + secs + '.' + milliSecs; |
| 156 }; | 161 }; |
| 157 | 162 |
| 158 Utils.getDefaultKey = function(forceInvalidResponse) { | 163 Utils.getDefaultKey = function(forceInvalidResponse) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 var time = Utils.getCurrentTimeString(); | 292 var time = Utils.getCurrentTimeString(); |
| 288 // Log to document. | 293 // Log to document. |
| 289 Utils.documentLog(arguments[0], time); | 294 Utils.documentLog(arguments[0], time); |
| 290 // Log to JS console. | 295 // Log to JS console. |
| 291 var logString = time + ' - '; | 296 var logString = time + ' - '; |
| 292 for (var i = 0; i < arguments.length; i++) { | 297 for (var i = 0; i < arguments.length; i++) { |
| 293 logString += ' ' + arguments[i]; | 298 logString += ' ' + arguments[i]; |
| 294 } | 299 } |
| 295 console.log(logString); | 300 console.log(logString); |
| 296 }; | 301 }; |
| OLD | NEW |