1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +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,39 +1,42 @@
loadPage("file:///res/html/misc/innertext_textcontent.html");
describe("Element", () => {
loadLocalPage("/res/html/misc/innertext_textcontent.html");
afterInitialPageLoad(() => {
test("Element.innerText", () => {
var p = document.getElementsByTagName("p")[0];
expect(p.innerText).toBe("This is a very small test page :^)");
afterInitialPageLoad(page => {
test("Element.innerText", () => {
var p = page.document.getElementsByTagName("p")[0];
expect(p.innerText).toBe("This is a very small test page :^)");
// FIXME: Call this on p once that's supported.
var b = document.getElementsByTagName("b")[0];
b.innerText = "foo";
expect(b.innerText).toBe("foo");
expect(p.innerText).toBe("This is a foo test page :^)");
// FIXME: Call this on p once that's supported.
var b = page.document.getElementsByTagName("b")[0];
b.innerText = "foo";
expect(b.innerText).toBe("foo");
expect(p.innerText).toBe("This is a foo test page :^)");
p.innerText = "bar";
expect(p.innerText).toBe("bar");
p.innerText = "bar";
expect(p.innerText).toBe("bar");
var p = document.getElementById("source");
// FIXME: The leading and trailing two spaces each are wrong.
// FIXME: The text should be affected by the text-transform:uppercase.
expect(p.innerText).toBe(` Take a look at
var p = page.document.getElementById("source");
// FIXME: The leading and trailing two spaces each are wrong.
// FIXME: The text should be affected by the text-transform:uppercase.
expect(p.innerText).toBe(` Take a look at
how this text
is interpreted below. `);
});
test("Element.namespaceURI basics", () => {
const htmlNamespace = "http://www.w3.org/1999/xhtml";
const p = page.document.getElementsByTagName("p")[0];
expect(p.namespaceURI).toBe(htmlNamespace);
// createElement always sets the namespace to the HTML namespace in HTML page.documents.
const svgElement = page.document.createElement("svg");
expect(svgElement.namespaceURI).toBe(htmlNamespace);
const svgNamespace = "http://www.w3.org/2000/svg";
p.innerHTML = "<svg></svg>";
const domSVGElement = p.getElementsByTagName("svg")[0];
expect(domSVGElement.namespaceURI).toBe(svgNamespace);
});
});
test("Element.namespaceURI basics", () => {
const htmlNamespace = "http://www.w3.org/1999/xhtml";
const p = document.getElementsByTagName("p")[0];
expect(p.namespaceURI).toBe(htmlNamespace);
// createElement always sets the namespace to the HTML namespace in HTML documents.
const svgElement = document.createElement("svg");
expect(svgElement.namespaceURI).toBe(htmlNamespace);
const svgNamespace = "http://www.w3.org/2000/svg";
p.innerHTML = "<svg></svg>";
const domSVGElement = p.getElementsByTagName("svg")[0];
expect(domSVGElement.namespaceURI).toBe(svgNamespace);
});
waitForPageToLoad();
});