1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:57:44 +00:00

LibWeb: Implement test-web in terms of LibTest/JavaScriptTestRunner

This deduplicates the test-js copy-ism :^)
This commit is contained in:
Ali Mohammad Pur 2021-05-18 18:46:54 +04:30 committed by Linus Groh
parent f137c1bfaa
commit d897abf4c2
26 changed files with 643 additions and 1159 deletions

View file

@ -1,55 +1,58 @@
loadPage("file:///res/html/misc/blank.html");
describe("body", () => {
loadLocalPage("/res/html/misc/blank.html");
afterInitialPageLoad(() => {
test("Basic functionality", () => {
expect(document.body).not.toBeNull();
// FIXME: Add this in once HTMLBodyElement's constructor is implemented.
//expect(document.body).toBeInstanceOf(HTMLBodyElement);
expect(document.body.nodeName).toBe("BODY");
});
// FIXME: Add this in once set_body is fully implemented.
test.skip("Setting body to a new body element", () => {
// Add something to body to see if it's gone afterwards
const p = document.createElement("p");
document.body.appendChild(p);
expect(document.body.firstChild).toBe(p);
const newBody = document.createElement("body");
document.body = newBody;
expect(document.body).not.toBeNull();
expect(document.body.nodeName).toBe("BODY");
// FIXME: Add this in once HTMLBodyElement's constructor is implemented.
//expect(document.body).toBeInstanceOf(HTMLBodyElement);
expect(document.body.firstChild).toBeNull();
});
// FIXME: Add this in once set_body is fully implemented.
test.skip("Setting body to a new frameset element", () => {
const newFrameSet = document.createElement("frameset");
document.body = newFrameSet;
expect(document.body).not.toBeNull();
expect(document.body.nodeName).toBe("FRAMESET");
// FIXME: Add this in once HTMLFrameSetElement's constructor is implemented.
//expect(document.body).toBeInstanceOf(HTMLFrameSetElement);
});
// FIXME: Add this in once set_body is fully implemented.
test.skip("Setting body to an element that isn't body/frameset", () => {
expect(() => {
document.body = document.createElement("div");
}).toThrow(DOMException);
});
// FIXME: Add this in once removeChild is implemented.
test.skip("Nullable", () => {
document.documentElement.removeChild(document.body);
expect(document.body).toBeNull();
afterInitialPageLoad(page => {
test("Basic functionality", () => {
expect(page.document.body).not.toBeNull();
// FIXME: Add this in once HTMLBodyElement's constructor is implemented.
//expect(page.document.body).toBeInstanceOf(HTMLBodyElement);
expect(page.document.body.nodeName).toBe("BODY");
});
// FIXME: Add this in once set_body is fully implemented.
test.skip("Setting body to a new body element", () => {
// Add something to body to see if it's gone afterwards
const p = page.document.createElement("p");
page.document.body.appendChild(p);
expect(page.document.body.firstChild).toBe(p);
const newBody = page.document.createElement("body");
page.document.body = newBody;
expect(page.document.body).not.toBeNull();
expect(page.document.body.nodeName).toBe("BODY");
// FIXME: Add this in once HTMLBodyElement's constructor is implemented.
//expect(page.document.body).toBeInstanceOf(HTMLBodyElement);
expect(page.document.body.firstChild).toBeNull();
});
// FIXME: Add this in once set_body is fully implemented.
test.skip("Setting body to a new frameset element", () => {
const newFrameSet = page.document.createElement("frameset");
page.document.body = newFrameSet;
expect(page.document.body).not.toBeNull();
expect(page.document.body.nodeName).toBe("FRAMESET");
// FIXME: Add this in once HTMLFrameSetElement's constructor is implemented.
//expect(page.document.body).toBeInstanceOf(HTMLFrameSetElement);
});
// FIXME: Add this in once set_body is fully implemented.
test.skip("Setting body to an element that isn't body/frameset", () => {
expect(() => {
page.document.body = page.document.createElement("div");
}).toThrow(DOMException);
});
// FIXME: Add this in once removeChild is implemented.
test.skip("Nullable", () => {
page.document.page.documentElement.removeChild(page.document.body);
expect(page.document.body).toBeNull();
});
});
waitForPageToLoad();
});