diff options
author | Luke <luke.wilde@live.co.uk> | 2020-08-31 13:56:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-31 23:05:51 +0200 |
commit | 124c52b3b5388441748478404a906139d678a96e (patch) | |
tree | ffb9296aa6918f23d61ea2e889f1a4f61f06916d /Libraries/LibWeb/Tests | |
parent | 8aabec1c94251b859f227dd2d6e69f7426117723 (diff) | |
download | serenity-124c52b3b5388441748478404a906139d678a96e.zip |
LibWeb: Implement document ready state
Diffstat (limited to 'Libraries/LibWeb/Tests')
-rw-r--r-- | Libraries/LibWeb/Tests/HTML/document.readyState.js | 31 |
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"); + }); +}); |