Chromium Code Reviews| Index: chrome/test/data/webui/i18n_behavior_test.html |
| diff --git a/chrome/test/data/webui/i18n_behavior_test.html b/chrome/test/data/webui/i18n_behavior_test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..016a9bb2e1d59de38c29a93f46676a13773574b8 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/i18n_behavior_test.html |
| @@ -0,0 +1,36 @@ |
| +<!doctype html> |
| +<script> |
|
tommycli
2016/05/06 21:10:57
The html and body tags can be omitted? I noticed e
Dan Beam
2016/05/06 21:43:23
are you asking in the "will it pass an HTML valida
|
| + |
| +function setUpPage() { |
| + loadTimeData.data = { |
| + 'allowedByDefault': '<a href="https://google.com">Google!</a>', |
| + 'customAttr': '<a is="action-link">Take action!</a>', |
| + 'customTag': "<x-foo>I'm an X, foo!</x-foo>", |
| + 'javascriptHref': '<a href="javascript:alert(1)">teh hax</a>', |
| + 'script': '<script>alert(/xss/)</scr' + 'ipt>', |
| + 'text': "I'm just text, nobody should have a problem with me!", |
| + }; |
| +} |
| + |
| +function testI18n() { |
| + I18nBehavior.i18n('allowedByDefault'); |
| + I18nBehavior.i18n('text'); |
| + |
| + assertThrows(function() { I18nBehavior.i18n('customAttr'); }); |
| + assertThrows(function() { I18nBehavior.i18n('customTag'); }); |
| + assertThrows(function() { I18nBehavior.i18n('javascriptHref'); }); |
| + assertThrows(function() { I18nBehavior.i18n('script'); }); |
| +} |
| + |
| +function testI18nAdvanced() { |
| + I18nBehavior.i18nAdvanced('customAttr', { |
| + attrs: { |
| + is: function(el, val) { |
| + return el.tagName == 'A' && val == 'action-link'; |
| + }, |
| + }, |
| + }); |
| + I18nBehavior.i18nAdvanced('customTag', {tags: ['X-FOO']}); |
| +} |
| + |
| +</script> |