HTMLTemplateElement.js 1.3 KB

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