diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 0e221c3992..b221b746fa 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -54,16 +54,12 @@ WebIDL::ExceptionOr History::replace_state(JS::Value data, String const&, // https://html.spec.whatwg.org/multipage/history.html#dom-history-length WebIDL::ExceptionOr History::length() const { - // 1. If this's associated Document is not fully active, then throw a "SecurityError" DOMException. + // 1. If this's relevant global object's associated Document is not fully active, then throw a "SecurityError" DOMException. if (!m_associated_document->is_fully_active()) return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."_fly_string); - // 2. Return the number of entries in the top-level browsing context's joint session history. - auto const* browsing_context = m_associated_document->browsing_context(); - - // FIXME: We don't have the concept of "joint session history", this is an ad-hoc implementation. - // See: https://html.spec.whatwg.org/multipage/history.html#joint-session-history - return browsing_context->session_history().size(); + // 2. Return this's length. + return m_length; } // https://html.spec.whatwg.org/multipage/history.html#dom-history-go diff --git a/Userland/Libraries/LibWeb/HTML/History.h b/Userland/Libraries/LibWeb/HTML/History.h index ab3fc70666..481ac94f30 100644 --- a/Userland/Libraries/LibWeb/HTML/History.h +++ b/Userland/Libraries/LibWeb/HTML/History.h @@ -27,6 +27,9 @@ public: WebIDL::ExceptionOr forward(); WebIDL::ExceptionOr length() const; + u64 m_index { 0 }; + u64 m_length { 0 }; + private: History(JS::Realm&, DOM::Document&); diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index c5844cb150..c276b339d8 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -1744,9 +1744,11 @@ void perform_url_and_history_update_steps(DOM::Document& document, AK::URL new_u // 6. If historyHandling is "push", then: if (history_handling == HistoryHandlingBehavior::Push) { - // FIXME: 1. Increment document's history object's index. - // FIXME: 2. Set document's history object's length to its index + 1. - TODO(); + // 1. Increment document's history object's index. + document.history()->m_index++; + + // 2. Set document's history object's length to its index + 1. + document.history()->m_length = document.history()->m_index + 1; } // FIXME: 7. If serializedData is not null, then restore the history object state given document and newEntry.