Serenity Operating System
at master 30 lines 1.4 kB view raw
1describe("HTMLTemplateElement", () => { 2 loadLocalPage("Template.html"); 3 4 afterInitialPageLoad(page => { 5 test("Basic functionality", () => { 6 const template = page.document.getElementById("template"); 7 expect(template).not.toBeNull(); 8 9 // The contents of a template element are not children of the actual element. 10 // The document fragment is not a child of the element either. 11 expect(template.firstChild).toBeNull(); 12 13 // FIXME: Add this in once page.DocumentFragment's constructor is implemented. 14 //expect(template.content).toBeInstanceOf(page.DocumentFragment); 15 expect(template.content.nodeName).toBe("#document-fragment"); 16 17 const templateDiv = template.content.getElementById("templatediv"); 18 expect(templateDiv.nodeName).toBe("DIV"); 19 expect(templateDiv.textContent).toBe("Hello template!"); 20 }); 21 22 test("Templates are inert (e.g. scripts won't run)", () => { 23 // The page has a template element with a script element in it. 24 // Templates are inert, for example, they won't run scripts. 25 // That script will set "templateScriptRan" to true if it ran. 26 expect(page.window.templateScriptRan).toBeUndefined(); 27 }); 28 }); 29 waitForPageToLoad(); 30});