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