4 <title i18n-content=
"title"></title>
5 <link rel=
"import" href=
"data:text/html,
6 <link rel=import href='data:text/html,<div i18n-content=nested>'>">
8 document
.write('<link id=cycle rel=import href="' + location
.href
+ '">');
11 <body i18n-values=
"type:type">
12 <span i18n-values=
".innerHTML:content;.style.display:display"><3</span>
15 <div i18n-content=
"nested"></div>
19 function setUpPage() {
21 'content': "doesn't matter; you can't see me!",
25 'nested': 'real deep',
27 i18nTemplate
.process(document
, loadTimeData
);
30 function testI18nProcess_Attributes() {
31 assertNotEqual('', document
.title
);
32 assertTrue(document
.body
.hasAttribute('type'));
33 assertTrue(document
.querySelector('span').textContent
.length
> 5);
34 assertEquals('none', document
.querySelector('span').style
.display
);
37 function testI18nProcess_Cycles() {
38 assertEquals(document
.URL
, $('cycle').import.URL
);
41 function testI18nProcess_DocumentFragment() {
42 var span
= document
.createElement('span');
43 span
.setAttribute('i18n-content', 'content');
45 var docFrag
= document
.createDocumentFragment();
46 docFrag
.appendChild(span
);
48 var div
= document
.createElement('div');
49 docFrag
.appendChild(div
);
51 i18nTemplate
.process(docFrag
, loadTimeData
);
53 assertTrue(span
.hasAttribute('i18n-processed'));
54 assertNotEqual('', span
.textContent
);
56 assertTrue(div
.hasAttribute('i18n-processed'));
59 function testI18nProcess_Imports() {
60 var outerImportDoc
= document
.querySelector('link').import;
61 var innerImportDoc
= outerImportDoc
.querySelector('link').import;
62 assertNotEqual('', innerImportDoc
.querySelector('div').textContent
);
65 function testI18nProcess_ReRun() {
66 document
.body
.removeAttribute('type');
67 i18nTemplate
.process(document
, loadTimeData
);
68 assertTrue(document
.body
.hasAttribute('type'));
71 function testI18nProcess_ShadowRoot() {
72 var a
= document
.createElement('a');
73 var outerShadow
= a
.createShadowRoot();
75 var b
= document
.createElement('b');
76 outerShadow
.appendChild(b
);
78 var innerShadow
= b
.createShadowRoot();
79 var i
= document
.createElement('i');
80 i
.setAttribute('i18n-content', 'content');
81 innerShadow
.appendChild(i
);
83 i18nTemplate
.process(i
, loadTimeData
);
85 assertTrue(i
.hasAttribute('i18n-processed'));
86 assertNotEqual('', i
.textContent
);
89 function testI18nProcess_Templates() {
90 var outerDocFrag
= document
.querySelector('template').content
;
91 var innerDocFrag
= outerDocFrag
.querySelector('template').content
;
92 assertNotEqual('', innerDocFrag
.querySelector('div').textContent
);