Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <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
| |
| 3 | |
| 4 function setUpPage() { | |
| 5 loadTimeData.data = { | |
| 6 'allowedByDefault': '<a href="https://google.com">Google!</a>', | |
| 7 'customAttr': '<a is="action-link">Take action!</a>', | |
| 8 'customTag': "<x-foo>I'm an X, foo!</x-foo>", | |
| 9 'javascriptHref': '<a href="javascript:alert(1)">teh hax</a>', | |
| 10 'script': '<script>alert(/xss/)</scr' + 'ipt>', | |
| 11 'text': "I'm just text, nobody should have a problem with me!", | |
| 12 }; | |
| 13 } | |
| 14 | |
| 15 function testI18n() { | |
| 16 I18nBehavior.i18n('allowedByDefault'); | |
| 17 I18nBehavior.i18n('text'); | |
| 18 | |
| 19 assertThrows(function() { I18nBehavior.i18n('customAttr'); }); | |
| 20 assertThrows(function() { I18nBehavior.i18n('customTag'); }); | |
| 21 assertThrows(function() { I18nBehavior.i18n('javascriptHref'); }); | |
| 22 assertThrows(function() { I18nBehavior.i18n('script'); }); | |
| 23 } | |
| 24 | |
| 25 function testI18nAdvanced() { | |
| 26 I18nBehavior.i18nAdvanced('customAttr', { | |
| 27 attrs: { | |
| 28 is: function(el, val) { | |
| 29 return el.tagName == 'A' && val == 'action-link'; | |
| 30 }, | |
| 31 }, | |
| 32 }); | |
| 33 I18nBehavior.i18nAdvanced('customTag', {tags: ['X-FOO']}); | |
| 34 } | |
| 35 | |
| 36 </script> | |
| OLD | NEW |