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

Unified Diff: chrome/test/data/webui/i18n_behavior_test.html

Issue 1952253004: I18nBehavior: make i18nRaw private as raw_, add tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@i18n-behavior
Patch Set: . Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/webui_resource_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3dd199a37b543fea0ea4656dfba46ecb2b3a804b
--- /dev/null
+++ b/chrome/test/data/webui/i18n_behavior_test.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<html>
+<body>
+<script>
+
+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>
+</body>
+</html>
« no previous file with comments | « no previous file | chrome/test/data/webui/webui_resource_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698