summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Tests
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2020-08-31 13:56:16 +0100
committerAndreas Kling <kling@serenityos.org>2020-08-31 23:05:51 +0200
commit124c52b3b5388441748478404a906139d678a96e (patch)
treeffb9296aa6918f23d61ea2e889f1a4f61f06916d /Libraries/LibWeb/Tests
parent8aabec1c94251b859f227dd2d6e69f7426117723 (diff)
downloadserenity-124c52b3b5388441748478404a906139d678a96e.zip
LibWeb: Implement document ready state
Diffstat (limited to 'Libraries/LibWeb/Tests')
-rw-r--r--Libraries/LibWeb/Tests/HTML/document.readyState.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Tests/HTML/document.readyState.js b/Libraries/LibWeb/Tests/HTML/document.readyState.js
new file mode 100644
index 0000000000..12b6c1d8df
--- /dev/null
+++ b/Libraries/LibWeb/Tests/HTML/document.readyState.js
@@ -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");
+ });
+});