Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / test / data / webui / local_strings_test.html
blob6a8eb7a9b845ea1d82e7ec464a320a57b53fae89
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>LocalStrings Tests</title>
5 </head>
6 <body>
7 <script>
9 function testGetString() {
10 var localStrings = new LocalStrings;
11 localStrings.templateData = {
12 'a': 'apple',
13 'b': 'banana'
15 assertEquals(localStrings.getString('a'), 'apple');
16 assertEquals(localStrings.getString('b'), 'banana');
18 var warnings = [];
19 var consoleWarn = console.warn;
20 console.warn = function(n) {
21 warnings.push(n);
23 try {
24 assertEquals(localStrings.getString('blah'), undefined);
25 } finally {
26 console.warn = consoleWarn;
28 assertEquals(1, warnings.length);
29 assertTrue(warnings[0].indexOf('blah') > 0);
32 function testGetStringF() {
33 var localStrings = new LocalStrings;
34 localStrings.templateData = {
35 'a': '$1',
36 'b': '$1$2',
37 'c': '$1$2$3',
38 'd': '$1$2$3$4$5$6$7$8$9'
40 assertEquals(localStrings.getStringF('a', 'A'), 'A');
41 assertEquals(localStrings.getStringF('b', 'A', 'B'), 'AB');
42 assertEquals(localStrings.getStringF('b', 'A'),
43 'Aundefined');
44 assertEquals(localStrings.getStringF('c', 'A', 'B', 'C'),
45 'ABC');
46 assertEquals(localStrings.getStringF('c', 'A'),
47 'Aundefinedundefined');
48 assertEquals(localStrings.getStringF('d', 'A', 'B', 'C',
49 'D', 'E', 'F', 'G', 'H', 'I'), 'ABCDEFGHI');
50 assertThrows(function() {
51 localStrings.getStringF('e', 'A');
52 });
55 </script>
56 </body>
57 </html>