Element.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. loadPage("file:///res/html/misc/innertext_textcontent.html");
  2. afterInitialPageLoad(() => {
  3. test("Element.innerText", () => {
  4. var p = document.getElementsByTagName("p")[0];
  5. expect(p.innerText).toBe("This is a very small test page :^)");
  6. // FIXME: Call this on p once that's supported.
  7. var b = document.getElementsByTagName("b")[0];
  8. b.innerText = "foo";
  9. expect(b.innerText).toBe("foo");
  10. expect(p.innerText).toBe("This is a foo test page :^)");
  11. p.innerText = "bar";
  12. expect(p.innerText).toBe("bar");
  13. var p = document.getElementById("source");
  14. // FIXME: The leading and trailing two spaces each are wrong.
  15. // FIXME: The text should be affected by the text-transform:uppercase.
  16. expect(p.innerText).toBe(` Take a look at
  17. how this text
  18. is interpreted below. `);
  19. });
  20. test("Element.namespaceURI basics", () => {
  21. const htmlNamespace = "http://www.w3.org/1999/xhtml";
  22. const p = document.getElementsByTagName("p")[0];
  23. expect(p.namespaceURI).toBe(htmlNamespace);
  24. // createElement always sets the namespace to the HTML namespace in HTML documents.
  25. const svgElement = document.createElement("svg");
  26. expect(svgElement.namespaceURI).toBe(htmlNamespace);
  27. const svgNamespace = "http://www.w3.org/2000/svg";
  28. p.innerHTML = "<svg></svg>";
  29. const domSVGElement = p.getElementsByTagName("svg")[0];
  30. expect(domSVGElement.namespaceURI).toBe(svgNamespace);
  31. });
  32. });