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

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

Issue 1233883005: Fix i18nTemplate.process() for DocumentFragments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stronger typing Created 5 years, 5 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/css/i18n_process.css » ('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 <head> 3 <head>
4 <title i18n-content="title"></title> 4 <title i18n-content="title"></title>
5 <link rel="import" href="data:text/html, 5 <link rel="import" href="data:text/html,
6 <link rel=import href='data:text/html,<div i18n-content=nested>'>"> 6 <link rel=import href='data:text/html,<div i18n-content=nested>'>">
7 <script> 7 <script>
8 document.write('<link id=cycle rel=import href="' + location.href + '">'); 8 document.write('<link id=cycle rel=import href="' + location.href + '">');
9 </script> 9 </script>
10 </head> 10 </head>
11 <body i18n-values="type:type"> 11 <body i18n-values="type:type">
12 <span i18n-values=".innerHTML:content;.style.display:display">&lt;3</span> 12 <span i18n-values=".innerHTML:content;.style.display:display">&lt;3</span>
13 <template> 13 <template>
14 <template> 14 <template>
15 <div i18n-content="nested"></div> 15 <div i18n-content="nested"></div>
16 </template> 16 </template>
17 </template> 17 </template>
18 <script> 18 <script>
19 function runI18nProcess() {
20 i18nTemplate.process(document, loadTimeData);
21 }
22
23 function setUpPage() { 19 function setUpPage() {
24 loadTimeData.data = { 20 loadTimeData.data = {
25 'content': "doesn't matter; you can't see me!", 21 'content': "doesn't matter; you can't see me!",
26 'display': 'none', 22 'display': 'none',
27 'title': 'BUY NOW!', 23 'title': 'BUY NOW!',
28 'type': 'ectomorph', 24 'type': 'ectomorph',
29 'nested': 'real deep', 25 'nested': 'real deep',
30 }; 26 };
31 runI18nProcess(); 27 i18nTemplate.process(document, loadTimeData);
32 } 28 }
33 29
34 function testI18nProcess_Attributes() { 30 function testI18nProcess_Attributes() {
35 assertNotEqual('', document.title); 31 assertNotEqual('', document.title);
36 assertTrue(document.body.hasAttribute('type')); 32 assertTrue(document.body.hasAttribute('type'));
37 assertTrue(document.querySelector('span').textContent.length > 5); 33 assertTrue(document.querySelector('span').textContent.length > 5);
38 assertEquals('none', document.querySelector('span').style.display); 34 assertEquals('none', document.querySelector('span').style.display);
39 } 35 }
40 36
41 function testI18nProcess_Cycles() { 37 function testI18nProcess_Cycles() {
42 assertEquals(document.URL, $('cycle').import.URL); 38 assertEquals(document.URL, $('cycle').import.URL);
43 } 39 }
44 40
41 function testI18nProcess_DocumentFragment() {
42 var span = document.createElement('span');
43 span.setAttribute('i18n-content', 'content');
44
45 var docFrag = document.createDocumentFragment();
46 docFrag.appendChild(span);
47
48 var div = document.createElement('div');
49 docFrag.appendChild(div);
50
51 i18nTemplate.process(docFrag, loadTimeData);
52
53 assertTrue(span.hasAttribute('i18n-processed'));
54 assertNotEqual('', span.textContent);
55
56 assertTrue(div.hasAttribute('i18n-processed'));
57 }
58
45 function testI18nProcess_Imports() { 59 function testI18nProcess_Imports() {
46 var outerImportDoc = document.querySelector('link').import; 60 var outerImportDoc = document.querySelector('link').import;
47 var innerImportDoc = outerImportDoc.querySelector('link').import; 61 var innerImportDoc = outerImportDoc.querySelector('link').import;
48 assertNotEqual('', innerImportDoc.querySelector('div').textContent); 62 assertNotEqual('', innerImportDoc.querySelector('div').textContent);
49 } 63 }
50 64
51 function testI18nProcess_ReRun() { 65 function testI18nProcess_ReRun() {
52 document.body.removeAttribute('type'); 66 document.body.removeAttribute('type');
53 runI18nProcess(); 67 i18nTemplate.process(document, loadTimeData);
54 assertTrue(document.body.hasAttribute('type')); 68 assertTrue(document.body.hasAttribute('type'));
55 } 69 }
56 70
71 function testI18nProcess_ShadowRoot() {
72 var a = document.createElement('a');
73 var outerShadow = a.createShadowRoot();
74
75 var b = document.createElement('b');
76 outerShadow.appendChild(b);
77
78 var innerShadow = b.createShadowRoot();
79 var i = document.createElement('i');
80 i.setAttribute('i18n-content', 'content');
81 innerShadow.appendChild(i);
82
83 i18nTemplate.process(i, loadTimeData);
84
85 assertTrue(i.hasAttribute('i18n-processed'));
86 assertNotEqual('', i.textContent);
87 }
88
57 function testI18nProcess_Templates() { 89 function testI18nProcess_Templates() {
58 var outerDocFrag = document.querySelector('template').content; 90 var outerDocFrag = document.querySelector('template').content;
59 var innerDocFrag = outerDocFrag.querySelector('template').content; 91 var innerDocFrag = outerDocFrag.querySelector('template').content;
60 assertNotEqual('', innerDocFrag.querySelector('div').textContent); 92 assertNotEqual('', innerDocFrag.querySelector('div').textContent);
61 } 93 }
62 </script> 94 </script>
63 </body> 95 </body>
64 </html> 96 </html>
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/css/i18n_process.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698