1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +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,27 +1,30 @@
loadPage("file:///home/anon/web-tests/Pages/Template.html");
describe("HTMLTemplateElement", () => {
loadLocalPage("Template.html");
afterInitialPageLoad(() => {
test("Basic functionality", () => {
const template = document.getElementById("template");
expect(template).not.toBeNull();
afterInitialPageLoad(page => {
test("Basic functionality", () => {
const template = page.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();
// 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");
// FIXME: Add this in once page.DocumentFragment's constructor is implemented.
//expect(template.content).toBeInstanceOf(page.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();
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(page.window.templateScriptRan).toBeUndefined();
});
});
waitForPageToLoad();
});