document.body.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. loadPage("file:///res/html/misc/blank.html");
  2. afterInitialPageLoad(() => {
  3. test("Basic functionality", () => {
  4. expect(document.body).not.toBeNull();
  5. // FIXME: Add this in once HTMLBodyElement's constructor is implemented.
  6. //expect(document.body).toBeInstanceOf(HTMLBodyElement);
  7. expect(document.body.nodeName).toBe("body");
  8. });
  9. // FIXME: Add this in once set_body is fully implemented.
  10. test.skip("Setting body to a new body element", () => {
  11. // Add something to body to see if it's gone afterwards
  12. const p = document.createElement("p");
  13. document.body.appendChild(p);
  14. expect(document.body.firstChild).toBe(p);
  15. const newBody = document.createElement("body");
  16. document.body = newBody;
  17. expect(document.body).not.toBeNull();
  18. expect(document.body.nodeName).toBe("body");
  19. // FIXME: Add this in once HTMLBodyElement's constructor is implemented.
  20. //expect(document.body).toBeInstanceOf(HTMLBodyElement);
  21. expect(document.body.firstChild).toBeNull();
  22. });
  23. // FIXME: Add this in once set_body is fully implemented.
  24. test.skip("Setting body to a new frameset element", () => {
  25. const newFrameSet = document.createElement("frameset");
  26. document.body = newFrameSet;
  27. expect(document.body).not.toBeNull();
  28. expect(document.body.nodeName).toBe("frameset");
  29. // FIXME: Add this in once HTMLFrameSetElement's constructor is implemented.
  30. //expect(document.body).toBeInstanceOf(HTMLFrameSetElement);
  31. });
  32. // FIXME: Add this in once set_body is fully implemented.
  33. test.skip("Setting body to an element that isn't body/frameset", () => {
  34. expect(() => {
  35. document.body = document.createElement("div");
  36. }).toThrow(DOMException);
  37. });
  38. // FIXME: Add this in once removeChild is implemented.
  39. test.skip("Nullable", () => {
  40. document.documentElement.removeChild(document.body);
  41. expect(document.body).toBeNull();
  42. });
  43. });