HTMLTemplateElement.js 1.2 KB

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