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

Side by Side Diff: chrome/test/data/webui/i18n_behavior_test.html

Issue 2938473002: [MD settings] allow unicode nbsp in i18n behavior strings (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/webui/resources/js/i18n_behavior.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script> 4 <script>
5 5
6 /* Execute these tests with the browser_tests executable. */
7
8 var allowedByDefault = '<a href="https://google.com">Google!</a>';
9 var text = 'I\'m just text, nobody should have a problem with me!';
10 var nonBreakingSpace = 'A\u00a0B'; // 0xa0 is a unicode nbsp.
11
6 function setUpPage() { 12 function setUpPage() {
7 loadTimeData.data = { 13 loadTimeData.data = {
8 'allowedByDefault': '<a href="https://google.com">Google!</a>', 14 'allowedByDefault': allowedByDefault,
9 'customAttr': '<a is="action-link">Take action!</a>', 15 'customAttr': '<a is="action-link">Take action!</a>',
10 'customTag': "<x-foo>I'm an X, foo!</x-foo>", 16 'customTag': "<x-foo>I'm an X, foo!</x-foo>",
11 'javascriptHref': '<a href="javascript:alert(1)">teh hax</a>', 17 'javascriptHref': '<a href="javascript:alert(1)">teh hax</a>',
12 'script': '<script>alert(/xss/)</scr' + 'ipt>', 18 'script': '<script>alert(/xss/)</scr' + 'ipt>',
13 'text': "I'm just text, nobody should have a problem with me!", 19 'text': text,
20 'nonBreakingSpace': nonBreakingSpace,
14 }; 21 };
15 } 22 }
16 23
17 function testI18n() { 24 function testI18n() {
18 I18nBehavior.i18n('allowedByDefault'); 25 assertEquals(allowedByDefault, I18nBehavior.i18n('allowedByDefault'));
19 I18nBehavior.i18n('text'); 26 assertEquals(text, I18nBehavior.i18n('text'));
27 assertEquals(nonBreakingSpace, I18nBehavior.i18n('nonBreakingSpace'));
20 28
21 assertThrows(function() { I18nBehavior.i18n('customAttr'); }); 29 assertThrows(function() { I18nBehavior.i18n('customAttr'); });
22 assertThrows(function() { I18nBehavior.i18n('customTag'); }); 30 assertThrows(function() { I18nBehavior.i18n('customTag'); });
23 assertThrows(function() { I18nBehavior.i18n('javascriptHref'); }); 31 assertThrows(function() { I18nBehavior.i18n('javascriptHref'); });
24 assertThrows(function() { I18nBehavior.i18n('script'); }); 32 assertThrows(function() { I18nBehavior.i18n('script'); });
25 } 33 }
26 34
27 function testI18nAdvanced() { 35 function testI18nAdvanced() {
28 I18nBehavior.i18nAdvanced('customAttr', { 36 I18nBehavior.i18nAdvanced('customAttr', {
29 attrs: { 37 attrs: {
30 is: function(el, val) { 38 is: function(el, val) {
31 return el.tagName == 'A' && val == 'action-link'; 39 return el.tagName == 'A' && val == 'action-link';
32 }, 40 },
33 }, 41 },
34 }); 42 });
35 I18nBehavior.i18nAdvanced('customTag', {tags: ['X-FOO']}); 43 I18nBehavior.i18nAdvanced('customTag', {tags: ['X-FOO']});
36 } 44 }
37 45
38 function testI18nExists() { 46 function testI18nExists() {
39 assertTrue(I18nBehavior.i18nExists('text')); 47 assertTrue(I18nBehavior.i18nExists('text'));
40 assertFalse(I18nBehavior.i18nExists('missingText')); 48 assertFalse(I18nBehavior.i18nExists('missingText'));
41 } 49 }
42 50
43 </script> 51 </script>
44 </body> 52 </body>
45 </html> 53 </html>
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/js/i18n_behavior.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698