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

Unified Diff: chrome/browser/resources/chromeos/chromevox/host/testing/msgs.js

Issue 350653006: Fix chromevox_tests that depend on actual message strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Split out fix for mock4js. Created 6 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/host/testing/msgs.js
diff --git a/chrome/browser/resources/chromeos/chromevox/host/testing/msgs.js b/chrome/browser/resources/chromeos/chromevox/host/testing/msgs.js
index 77a481e67e27c5a0d112aa7bafe2cd7229053442..ecaede65f77c32511dcf8ec1cecf53b047525650 100644
--- a/chrome/browser/resources/chromeos/chromevox/host/testing/msgs.js
+++ b/chrome/browser/resources/chromeos/chromevox/host/testing/msgs.js
@@ -43,35 +43,18 @@ cvox.TestMsgs.prototype.getLocale = function() {
*/
cvox.TestMsgs.prototype.getMsg = function(message_id, opt_subs) {
if (!message_id) {
- var e = new Error();
- e.message = 'Message id required';
- throw e;
+ throw Error('Message id required');
}
- var message = cvox.TestMessages['chromevox_' + message_id];
+ var message = cvox.TestMessages[('chromevox_' + message_id).toUpperCase()];
if (message == undefined) {
- var e = new Error();
- e.message = 'missing-msg: ' + message_id;
- throw e;
+ throw Error('missing-msg: ' + message_id);
}
var messageString = message.message;
if (opt_subs) {
// Unshift a null to make opt_subs and message.placeholders line up.
for (var i = 0; i < opt_subs.length; i++) {
- var placeholderObject = message.placeholders ?
- message.placeholders[i + 1] : undefined;
- if (!placeholderObject) {
- // Allow tests to substitute the string 'dummy' if they don't know
dmazzoni 2014/06/24 05:54:10 FWIW, I think we will need to add this feature bac
- // how many substitutions a message has.
- if (opt_subs[i] == 'dummy') {
- continue;
- }
- var e = new Error();
- e.message = 'Bad placeholder ' + i + ' for message id ' + message_id;
- throw e;
- }
- var placeholder = message.placeholders[i + 1].content;
- messageString = messageString.replace(placeholder, opt_subs[i]);
+ messageString = messageString.replace('$' + (i + 1), opt_subs[i]);
}
}
return messageString;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698