mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 22:05:07 +00:00
LibWeb: Implement document ready state
This commit is contained in:
parent
8aabec1c94
commit
124c52b3b5
5 changed files with 49 additions and 0 deletions
31
Libraries/LibWeb/Tests/HTML/document.readyState.js
Normal file
31
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