mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
Libraries: Move to Userland/Libraries/
This commit is contained in:
parent
dc28c07fa5
commit
13d7c09125
1857 changed files with 266 additions and 274 deletions
9
Userland/Libraries/LibWeb/Tests/HTML/HTMLElement.js
Normal file
9
Userland/Libraries/LibWeb/Tests/HTML/HTMLElement.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
loadPage("file:///res/html/misc/welcome.html");
|
||||
|
||||
afterInitialPageLoad(() => {
|
||||
test("contentEditable attribute", () => {
|
||||
expect(document.body.contentEditable).toBe("inherit");
|
||||
expect(document.firstChild.nextSibling.nodeName).toBe("html");
|
||||
expect(document.firstChild.nextSibling.contentEditable).toBe("true");
|
||||
});
|
||||
});
|
27
Userland/Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js
Normal file
27
Userland/Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
loadPage("file:///home/anon/web-tests/Pages/Template.html");
|
||||
|
||||
afterInitialPageLoad(() => {
|
||||
test("Basic functionality", () => {
|
||||
const template = document.getElementById("template");
|
||||
expect(template).not.toBeNull();
|
||||
|
||||
// The contents of a template element are not children of the actual element.
|
||||
// The document fragment is not a child of the element either.
|
||||
expect(template.firstChild).toBeNull();
|
||||
|
||||
// FIXME: Add this in once DocumentFragment's constructor is implemented.
|
||||
//expect(template.content).toBeInstanceOf(DocumentFragment);
|
||||
expect(template.content.nodeName).toBe("#document-fragment");
|
||||
|
||||
const templateDiv = template.content.getElementById("templatediv");
|
||||
expect(templateDiv.nodeName).toBe("div");
|
||||
expect(templateDiv.textContent).toBe("Hello template!");
|
||||
});
|
||||
|
||||
test("Templates are inert (e.g. scripts won't run)", () => {
|
||||
// The page has a template element with a script element in it.
|
||||
// Templates are inert, for example, they won't run scripts.
|
||||
// That script will set "templateScriptRan" to true if it ran.
|
||||
expect(window.templateScriptRan).toBeUndefined();
|
||||
});
|
||||
});
|
55
Userland/Libraries/LibWeb/Tests/HTML/document.body.js
Normal file
55
Userland/Libraries/LibWeb/Tests/HTML/document.body.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
loadPage("file:///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();
|
||||
});
|
||||
});
|
16
Userland/Libraries/LibWeb/Tests/HTML/document.head.js
Normal file
16
Userland/Libraries/LibWeb/Tests/HTML/document.head.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
loadPage("file:///res/html/misc/blank.html");
|
||||
|
||||
afterInitialPageLoad(() => {
|
||||
test("Basic functionality", () => {
|
||||
expect(document.head).not.toBeNull();
|
||||
// FIXME: Add this in once HTMLHeadElement's constructor is implemented.
|
||||
//expect(document.head).toBeInstanceOf(HTMLHeadElement);
|
||||
expect(document.head.nodeName).toBe("head");
|
||||
});
|
||||
|
||||
// FIXME: Add this in once removeChild is implemented.
|
||||
test.skip("Nullable", () => {
|
||||
document.documentElement.removeChild(document.head);
|
||||
expect(document.head).toBeNull();
|
||||
});
|
||||
});
|
31
Userland/Libraries/LibWeb/Tests/HTML/document.readyState.js
Normal file
31
Userland/Libraries/LibWeb/Tests/HTML/document.readyState.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
loadPage("file:///res/html/misc/blank.html");
|
||||
|
||||
beforeInitialPageLoad(() => {
|
||||
window.events = [];
|
||||
|
||||
document.addEventListener("readystatechange", () => {
|
||||
window.events.push(document.readyState);
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
test("Ready state should be 'interactive' when 'DOMContentLoaded' fires", () => {
|
||||
expect(document.readyState).toBe("interactive");
|
||||
});
|
||||
});
|
||||
|
||||
test("Ready state should be 'loading' initially", () => {
|
||||
expect(document.readyState).toBe("loading");
|
||||
});
|
||||
});
|
||||
|
||||
afterInitialPageLoad(() => {
|
||||
test("'interactive' should come before 'complete' and both should have happened", () => {
|
||||
expect(window.events).toHaveLength(2);
|
||||
expect(window.events[0]).toBe("interactive");
|
||||
expect(window.events[1]).toBe("complete");
|
||||
});
|
||||
|
||||
test("Ready state should be 'complete' after loading", () => {
|
||||
expect(document.readyState).toBe("complete");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue