diff options
Diffstat (limited to 'Libraries/LibWeb/Tests')
23 files changed, 0 insertions, 458 deletions
diff --git a/Libraries/LibWeb/Tests/DOM/Comment.js b/Libraries/LibWeb/Tests/DOM/Comment.js deleted file mode 100644 index 0dab522e9c..0000000000 --- a/Libraries/LibWeb/Tests/DOM/Comment.js +++ /dev/null @@ -1,15 +0,0 @@ -loadPage("file:///home/anon/web-tests/Pages/Comment.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - const comment = document.body.firstChild.nextSibling; - expect(comment).not.toBeNull(); - - // FIXME: Add this in once Comment's constructor is implemented. - //expect(comment).toBeInstanceOf(Comment); - - expect(comment.nodeName).toBe("#comment"); - expect(comment.data).toBe("This is a comment"); - expect(comment).toHaveLength(17); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/Element.js b/Libraries/LibWeb/Tests/DOM/Element.js deleted file mode 100644 index 16606829aa..0000000000 --- a/Libraries/LibWeb/Tests/DOM/Element.js +++ /dev/null @@ -1,39 +0,0 @@ -loadPage("file:///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 :^)"); - - // 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 :^)"); - - 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 -how this text -is interpreted below. `); - }); - - 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); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/Node.js b/Libraries/LibWeb/Tests/DOM/Node.js deleted file mode 100644 index 5427d143bd..0000000000 --- a/Libraries/LibWeb/Tests/DOM/Node.js +++ /dev/null @@ -1,28 +0,0 @@ -loadPage("file:///res/html/misc/innertext_textcontent.html"); - -afterInitialPageLoad(() => { - test("Node.textContent", () => { - var p = document.getElementsByTagName("p")[0]; - expect(p.textContent).toBe("This is a very small test page :^)"); - expect(p.firstChild.textContent).toBe("This is a "); - expect(p.firstChild.firstChild).toBe(null); - - p.firstChild.textContent = "foo"; - expect(p.firstChild.textContent).toBe("foo"); - expect(p.firstChild.firstChild).toBe(null); - expect(p.textContent).toBe("foovery small test page :^)"); - - p.textContent = "bar"; - expect(p.textContent).toBe("bar"); - expect(p.firstChild.textContent).toBe("bar"); - expect(p.firstChild.firstChild).toBe(null); - - var p = document.getElementById("source"); - expect(p.textContent).toBe(` - #source { color: red; } #text { text-transform: uppercase; } - Take a look athow this textis interpreted - below. - HIDDEN TEXT - `); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/Text.js b/Libraries/LibWeb/Tests/DOM/Text.js deleted file mode 100644 index 1557a59d3f..0000000000 --- a/Libraries/LibWeb/Tests/DOM/Text.js +++ /dev/null @@ -1,15 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - const title = document.getElementsByTagName("title")[0]; - expect(title).toBeDefined(); - - // FIXME: Add this in once Text's constructor is implemented. - //expect(title.firstChild).toBeInstanceOf(Text); - - expect(title.firstChild.nodeName).toBe("#text"); - expect(title.firstChild.data).toBe("Blank"); - expect(title.firstChild.length).toBe(5); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/document.createComment.js b/Libraries/LibWeb/Tests/DOM/document.createComment.js deleted file mode 100644 index a60d6bfcd5..0000000000 --- a/Libraries/LibWeb/Tests/DOM/document.createComment.js +++ /dev/null @@ -1,13 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - const comment = document.createComment("Create Comment Test"); - - // FIXME: Add this in once Comment's constructor is implemented. - //expect(comment).toBeInstanceOf(Comment); - expect(comment.nodeName).toBe("#comment"); - expect(comment.data).toBe("Create Comment Test"); - expect(comment.length).toBe(19); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/document.createDocumentFragment.js b/Libraries/LibWeb/Tests/DOM/document.createDocumentFragment.js deleted file mode 100644 index bebc137313..0000000000 --- a/Libraries/LibWeb/Tests/DOM/document.createDocumentFragment.js +++ /dev/null @@ -1,11 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - const fragment = document.createDocumentFragment(); - - // FIXME: Add this in once DocumentFragment's constructor is implemented. - //expect(fragment).toBeInstanceOf(DocumentFragment); - expect(fragment.nodeName).toBe("#document-fragment"); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/document.createTextNode.js b/Libraries/LibWeb/Tests/DOM/document.createTextNode.js deleted file mode 100644 index bef06a81c7..0000000000 --- a/Libraries/LibWeb/Tests/DOM/document.createTextNode.js +++ /dev/null @@ -1,13 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - const text = document.createTextNode("Create Text Test"); - - // FIXME: Add this in once Text's constructor is implemented. - //expect(text).toBeInstanceOf(Text); - expect(text.nodeName).toBe("#text"); - expect(text.data).toBe("Create Text Test"); - expect(text.length).toBe(16); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/document.doctype.js b/Libraries/LibWeb/Tests/DOM/document.doctype.js deleted file mode 100644 index 5da52014d1..0000000000 --- a/Libraries/LibWeb/Tests/DOM/document.doctype.js +++ /dev/null @@ -1,18 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - expect(document.compatMode).toBe("CSS1Compat"); - expect(document.doctype).not.toBeNull(); - expect(document.doctype.name).toBe("html"); - expect(document.doctype.publicId).toBe(""); - expect(document.doctype.systemId).toBe(""); - }); - - libweb_tester.changePage("file:///res/html/misc/blank-no-doctype.html"); - - test("Quirks mode", () => { - expect(document.compatMode).toBe("BackCompat"); - expect(document.doctype).toBeNull(); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/document.documentElement.js b/Libraries/LibWeb/Tests/DOM/document.documentElement.js deleted file mode 100644 index 86d885c709..0000000000 --- a/Libraries/LibWeb/Tests/DOM/document.documentElement.js +++ /dev/null @@ -1,16 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("Basic functionality", () => { - expect(document.documentElement).not.toBeNull(); - // FIXME: Add this in once HTMLHtmlElement's constructor is implemented. - //expect(document.documentElement).toBeInstanceOf(HTMLHtmlElement); - expect(document.documentElement.nodeName).toBe("html"); - }); - - // FIXME: Add this in once removeChild is implemented. - test.skip("Nullable", () => { - document.removeChild(document.documentElement); - expect(document.documentElement).toBeNull(); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/mixins/NonElementParentNode.js b/Libraries/LibWeb/Tests/DOM/mixins/NonElementParentNode.js deleted file mode 100644 index 5b269025f4..0000000000 --- a/Libraries/LibWeb/Tests/DOM/mixins/NonElementParentNode.js +++ /dev/null @@ -1,19 +0,0 @@ -loadPage("file:///home/anon/web-tests/Pages/ParentNode.html"); - -afterInitialPageLoad(() => { - test("getElementById basics", () => { - const unique = document.getElementById("unique"); - expect(unique).not.toBeNull(); - expect(unique.nodeName).toBe("div"); - expect(unique.id).toBe("unique"); - - const caseSensitive = document.getElementById("Unique"); - expect(caseSensitive).toBeNull(); - - const firstDuplicate = document.getElementById("dupeId"); - expect(firstDuplicate).not.toBeNull(); - expect(firstDuplicate.nodeName).toBe("div"); - expect(firstDuplicate.id).toBe("dupeId"); - expect(firstDuplicate.innerHTML).toBe("First ID"); - }); -}); diff --git a/Libraries/LibWeb/Tests/DOM/mixins/ParentNode.js b/Libraries/LibWeb/Tests/DOM/mixins/ParentNode.js deleted file mode 100644 index 3558c0352f..0000000000 --- a/Libraries/LibWeb/Tests/DOM/mixins/ParentNode.js +++ /dev/null @@ -1,25 +0,0 @@ -loadPage("file:///home/anon/web-tests/Pages/ParentNode.html"); - -afterInitialPageLoad(() => { - test("querySelector basics", () => { - const firstDuplicateElement = document.querySelector(".duplicate"); - expect(firstDuplicateElement).not.toBeNull(); - expect(firstDuplicateElement.nodeName).toBe("div"); - expect(firstDuplicateElement.innerHTML).toBe("First"); - - const noElement = document.querySelector(".nonexistent"); - expect(noElement).toBeNull(); - }); - - test("querySelectorAll basics", () => { - const allDuplicates = document.querySelectorAll(".duplicate"); - expect(allDuplicates).toHaveLength(2); - expect(allDuplicates[0].nodeName).toBe("div"); - expect(allDuplicates[0].innerHTML).toBe("First"); - expect(allDuplicates[1].nodeName).toBe("div"); - expect(allDuplicates[1].innerHTML).toBe("Second"); - - const noElements = document.querySelectorAll(".nonexistent"); - expect(noElements).toHaveLength(0); - }); -}); diff --git a/Libraries/LibWeb/Tests/HTML/HTMLElement.js b/Libraries/LibWeb/Tests/HTML/HTMLElement.js deleted file mode 100644 index 2950bb45c5..0000000000 --- a/Libraries/LibWeb/Tests/HTML/HTMLElement.js +++ /dev/null @@ -1,9 +0,0 @@ -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"); - }); -}); diff --git a/Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js b/Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js deleted file mode 100644 index dd6c66e1f2..0000000000 --- a/Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js +++ /dev/null @@ -1,27 +0,0 @@ -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(); - }); -}); diff --git a/Libraries/LibWeb/Tests/HTML/document.body.js b/Libraries/LibWeb/Tests/HTML/document.body.js deleted file mode 100644 index 9fc1907583..0000000000 --- a/Libraries/LibWeb/Tests/HTML/document.body.js +++ /dev/null @@ -1,55 +0,0 @@ -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(); - }); -}); diff --git a/Libraries/LibWeb/Tests/HTML/document.head.js b/Libraries/LibWeb/Tests/HTML/document.head.js deleted file mode 100644 index 5d997fe3dd..0000000000 --- a/Libraries/LibWeb/Tests/HTML/document.head.js +++ /dev/null @@ -1,16 +0,0 @@ -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(); - }); -}); diff --git a/Libraries/LibWeb/Tests/HTML/document.readyState.js b/Libraries/LibWeb/Tests/HTML/document.readyState.js deleted file mode 100644 index 12b6c1d8df..0000000000 --- a/Libraries/LibWeb/Tests/HTML/document.readyState.js +++ /dev/null @@ -1,31 +0,0 @@ -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"); - }); -}); diff --git a/Libraries/LibWeb/Tests/Pages/Comment.html b/Libraries/LibWeb/Tests/Pages/Comment.html deleted file mode 100644 index 84ae91695f..0000000000 --- a/Libraries/LibWeb/Tests/Pages/Comment.html +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -</head> -<body> -<!--This is a comment--> -</body> -</html> diff --git a/Libraries/LibWeb/Tests/Pages/ParentNode.html b/Libraries/LibWeb/Tests/Pages/ParentNode.html deleted file mode 100644 index 536b5ab35d..0000000000 --- a/Libraries/LibWeb/Tests/Pages/ParentNode.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -</head> -<body> - <div class="duplicate">First</div> - <div class="duplicate">Second</div> - <div id="unique"></div> - <div id="dupeId">First ID</div> - <div id="dupeId">Second ID</div> -</body> -</html> diff --git a/Libraries/LibWeb/Tests/Pages/Template.html b/Libraries/LibWeb/Tests/Pages/Template.html deleted file mode 100644 index e4478f408f..0000000000 --- a/Libraries/LibWeb/Tests/Pages/Template.html +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -</head> -<body> -<template id="template"> - <div id="templatediv">Hello template!</div> - <script> - // I shouldn't be run. - window.templateScriptRan = true; - </script> -</template> -</body> -</html> diff --git a/Libraries/LibWeb/Tests/Window/Base64.js b/Libraries/LibWeb/Tests/Window/Base64.js deleted file mode 100644 index c272d70b74..0000000000 --- a/Libraries/LibWeb/Tests/Window/Base64.js +++ /dev/null @@ -1,19 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("atob", () => { - expect(atob("YQ==")).toBe("a"); - expect(atob("YWE=")).toBe("aa"); - expect(atob("YWFh")).toBe("aaa"); - expect(atob("YWFhYQ==")).toBe("aaaa"); - expect(atob("/w==")).toBe("\xff"); - }); - - test("btoa", () => { - expect(btoa("a")).toBe("YQ=="); - expect(btoa("aa")).toBe("YWE="); - expect(btoa("aaa")).toBe("YWFh"); - expect(btoa("aaaa")).toBe("YWFhYQ=="); - expect(btoa("\xff")).toBe("/w=="); - }); -}); diff --git a/Libraries/LibWeb/Tests/Window/window.window_frames_self.js b/Libraries/LibWeb/Tests/Window/window.window_frames_self.js deleted file mode 100644 index 1d7799843e..0000000000 --- a/Libraries/LibWeb/Tests/Window/window.window_frames_self.js +++ /dev/null @@ -1,8 +0,0 @@ -loadPage("file:///res/html/misc/blank.html"); - -afterInitialPageLoad(() => { - test("window.{window,frames,self} all return the Window object", () => { - expect(window.window).toBe(window.frames); - expect(window.window).toBe(window.self); - }); -}); diff --git a/Libraries/LibWeb/Tests/libweb_tester.d.ts b/Libraries/LibWeb/Tests/libweb_tester.d.ts deleted file mode 100644 index 23570e70f8..0000000000 --- a/Libraries/LibWeb/Tests/libweb_tester.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// NOTE: This file is only for syntax highlighting, documentation, etc. - -interface LibwebTester { - /** - * Changes the page to the specified URL. Everything afterwards will refer to the new page. - * @param url Page to load. - */ - changePage(url: string): void; -} - -interface Window { - /** - * Special test object used to ease test development for LibWeb. - */ - readonly libweb_tester: LibwebTester; -} diff --git a/Libraries/LibWeb/Tests/test-common.js b/Libraries/LibWeb/Tests/test-common.js deleted file mode 100644 index 7fc4f914bf..0000000000 --- a/Libraries/LibWeb/Tests/test-common.js +++ /dev/null @@ -1,31 +0,0 @@ -// NOTE: The tester loads in LibJS's test-common to prevent duplication. - -// NOTE: "window.libweb_tester" is set to a special tester object. -// See libweb_tester.d.ts for definitions. - -let __PageToLoad__; - -// This tells the tester which page to load. -// This will only be checked when we look at which page the test wants to use. -// Subsequent calls to loadPage in before/after initial load will be ignored. -let loadPage; - -let __BeforeInitialPageLoad__ = () => {}; - -// This function will be called just before loading the initial page. -// This is useful for injecting event listeners. -// Defaults to an empty function. -let beforeInitialPageLoad; - -let __AfterInitialPageLoad__ = () => {}; - -// This function will be called just after loading the initial page. -// This is where the main bulk of the tests should be. -// Defaults to an empty function. -let afterInitialPageLoad; - -(() => { - loadPage = page => (__PageToLoad__ = page); - beforeInitialPageLoad = callback => (__BeforeInitialPageLoad__ = callback); - afterInitialPageLoad = callback => (__AfterInitialPageLoad__ = callback); -})(); |