Element.js 1.7 KB

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