summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-21 00:43:38 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-21 11:51:18 +0200
commit797d28adcae203fec67ea626e8de20230cce48fc (patch)
tree5f8d76556d5dabfa3b6c3f894be367cac67fa5fb /Userland
parentd4fc1367f6eb0ef463fd6e5676b2c852c7c73275 (diff)
downloadserenity-797d28adcae203fec67ea626e8de20230cce48fc.zip
LibWeb: Save begin/end timestamps for load and DOMContentLoaded events
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h6
-rw-r--r--Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp12
-rw-r--r--Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp12
3 files changed, 20 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index b560d9e7c9..61155bae10 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -424,11 +424,13 @@ public:
RefPtr<HTML::HTMLParser> active_parser();
// https://html.spec.whatwg.org/multipage/dom.html#load-timing-info
- DocumentLoadTimingInfo const& load_timing_info() { return m_load_timing_info; }
+ DocumentLoadTimingInfo& load_timing_info() { return m_load_timing_info; }
+ DocumentLoadTimingInfo const& load_timing_info() const { return m_load_timing_info; }
void set_load_timing_info(DocumentLoadTimingInfo const& load_timing_info) { m_load_timing_info = load_timing_info; }
// https://html.spec.whatwg.org/multipage/dom.html#previous-document-unload-timing
- DocumentUnloadTimingInfo const& previous_document_unload_timing() { return m_previous_document_unload_timing; }
+ DocumentUnloadTimingInfo& previous_document_unload_timing() { return m_previous_document_unload_timing; }
+ DocumentUnloadTimingInfo const& previous_document_unload_timing() const { return m_previous_document_unload_timing; }
void set_previous_document_unload_timing(DocumentUnloadTimingInfo const& previous_document_unload_timing) { m_previous_document_unload_timing = previous_document_unload_timing; }
protected:
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index 84a960b62d..8d5761f2e1 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -234,14 +234,16 @@ void HTMLParser::the_end()
// 6. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, *m_document, [document = m_document]() mutable {
- // FIXME: 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
+ // 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
+ document->load_timing_info().dom_content_loaded_event_start_time = main_thread_event_loop().unsafe_shared_current_time();
// 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
auto content_loaded_event = DOM::Event::create(document->window(), HTML::EventNames::DOMContentLoaded);
content_loaded_event->set_bubbles(true);
document->dispatch_event(*content_loaded_event);
- // FIXME: 3. Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
+ // 3. Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
+ document->load_timing_info().dom_content_loaded_event_end_time = main_thread_event_loop().unsafe_shared_current_time();
// FIXME: 4. Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
@@ -271,7 +273,8 @@ void HTMLParser::the_end()
// 3. Let window be the Document's relevant global object.
JS::NonnullGCPtr<Window> window = document->window();
- // FIXME: 4. Set the Document's load timing info's load event start time to the current high resolution time given window.
+ // 4. Set the Document's load timing info's load event start time to the current high resolution time given window.
+ document->load_timing_info().load_event_start_time = main_thread_event_loop().unsafe_shared_current_time();
// 5. Fire an event named load at window, with legacy target override flag set.
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
@@ -282,7 +285,8 @@ void HTMLParser::the_end()
// FIXME: 7. Set the Document object's navigation id to null.
- // FIXME: 8. Set the Document's load timing info's load event end time to the current high resolution time given window.
+ // 8. Set the Document's load timing info's load event end time to the current high resolution time given window.
+ document->load_timing_info().load_event_end_time = main_thread_event_loop().unsafe_shared_current_time();
// 9. Assert: Document's page showing is false.
VERIFY(!document->page_showing());
diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
index 067bb0fb93..48b30178dc 100644
--- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
+++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp
@@ -173,14 +173,16 @@ void XMLDocumentBuilder::document_end()
}
// Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
old_queue_global_task_with_document(HTML::Task::Source::DOMManipulation, m_document, [document = JS::make_handle(m_document)]() mutable {
- // FIXME: Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
+ // Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
+ document->load_timing_info().dom_content_loaded_event_start_time = HTML::main_thread_event_loop().unsafe_shared_current_time();
// Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
auto content_loaded_event = DOM::Event::create(document->window(), HTML::EventNames::DOMContentLoaded);
content_loaded_event->set_bubbles(true);
document->dispatch_event(*content_loaded_event);
- // FIXME: Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
+ // Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
+ document->load_timing_info().dom_content_loaded_event_end_time = HTML::main_thread_event_loop().unsafe_shared_current_time();
// FIXME: Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
@@ -209,7 +211,8 @@ void XMLDocumentBuilder::document_end()
// Let window be the Document's relevant global object.
JS::NonnullGCPtr<HTML::Window> window = document->window();
- // FIXME: Set the Document's load timing info's load event start time to the current high resolution time given window.
+ // Set the Document's load timing info's load event start time to the current high resolution time given window.
+ document->load_timing_info().load_event_start_time = HTML::main_thread_event_loop().unsafe_shared_current_time();
// Fire an event named load at window, with legacy target override flag set.
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
@@ -220,7 +223,8 @@ void XMLDocumentBuilder::document_end()
// FIXME: Set the Document object's navigation id to null.
- // FIXME: Set the Document's load timing info's load event end time to the current high resolution time given window.
+ // Set the Document's load timing info's load event end time to the current high resolution time given window.
+ document->load_timing_info().dom_content_loaded_event_end_time = HTML::main_thread_event_loop().unsafe_shared_current_time();
// Assert: Document's page showing is false.
VERIFY(!document->page_showing());