| <!doctype html> |
| <html> |
| <head> |
| <title i18n-content="title"></title> |
| <link rel="import" href="data:text/html,<link rel=import href='data:text/html,<div i18n-content=nested>'>"> |
| <script> |
| document.write('<link id=cycle rel=import href="' + location.href + '">'); |
| </script> |
| </head> |
| <body i18n-values="type:type"> |
| <span i18n-values=".innerHTML:content;.style.display:display"><3</span> |
| <template> |
| <template> |
| <div i18n-content="nested"></div> |
| </template> |
| </template> |
| <script> |
| function setUpPage() { |
| loadTimeData.data = { |
| 'content': "doesn't matter; you can't see me!", |
| 'display': 'none', |
| 'title': 'BUY NOW!', |
| 'type': 'ectomorph', |
| 'nested': 'real deep', |
| }; |
| i18nTemplate.process(document, loadTimeData); |
| } |
| |
| function testI18nProcess_Attributes() { |
| assertNotEqual('', document.title); |
| assertTrue(document.body.hasAttribute('type')); |
| assertTrue(document.querySelector('span').textContent.length > 5); |
| assertEquals('none', document.querySelector('span').style.display); |
| } |
| |
| function testI18nProcess_Cycles() { |
| assertEquals(document.URL, $('cycle').import.URL); |
| } |
| |
| function testI18nProcess_DocumentFragment() { |
| var span = document.createElement('span'); |
| span.setAttribute('i18n-content', 'content'); |
| |
| var docFrag = document.createDocumentFragment(); |
| docFrag.appendChild(span); |
| |
| var div = document.createElement('div'); |
| docFrag.appendChild(div); |
| |
| i18nTemplate.process(docFrag, loadTimeData); |
| |
| assertTrue(span.hasAttribute('i18n-processed')); |
| assertNotEqual('', span.textContent); |
| |
| assertTrue(div.hasAttribute('i18n-processed')); |
| } |
| |
| function testI18nProcess_Imports() { |
| var outerImportDoc = document.querySelector('link').import; |
| var innerImportDoc = outerImportDoc.querySelector('link').import; |
| assertNotEqual('', innerImportDoc.querySelector('div').textContent); |
| } |
| |
| function testI18nProcess_ReRun() { |
| document.body.removeAttribute('type'); |
| i18nTemplate.process(document, loadTimeData); |
| assertTrue(document.body.hasAttribute('type')); |
| } |
| |
| function testI18nProcess_ShadowRoot() { |
| var a = document.createElement('a'); |
| var outerShadow = a.createShadowRoot(); |
| |
| var b = document.createElement('b'); |
| outerShadow.appendChild(b); |
| |
| var innerShadow = b.createShadowRoot(); |
| var i = document.createElement('i'); |
| i.setAttribute('i18n-content', 'content'); |
| innerShadow.appendChild(i); |
| |
| i18nTemplate.process(i, loadTimeData); |
| |
| assertTrue(i.hasAttribute('i18n-processed')); |
| assertNotEqual('', i.textContent); |
| } |
| |
| function testI18nProcess_Templates() { |
| var outerDocFrag = document.querySelector('template').content; |
| var innerDocFrag = outerDocFrag.querySelector('template').content; |
| assertNotEqual('', innerDocFrag.querySelector('div').textContent); |
| } |
| </script> |
| </body> |
| </html> |