Skip to content

Commit

Permalink
[Navigation] Implement navigation.updateCurrentEntry()
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268261

Reviewed by Alex Christensen.

This implements `navigation.UpdateCurrentEntry()`, both the method storing state, and emitting the currententryupdated event.

https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-updatecurrententry

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/anchor-click-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/constructor-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/history-back-same-doc-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/history-pushState-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/history-replaceState-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/location-api-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-back-forward-same-doc-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-navigate-preventDefault-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-navigate-replace-same-doc-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-navigate-same-doc-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-updateCurrentEntry-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/basic-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/cross-document-away-and-back-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/cross-document-location-api-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/exception-order-initial-about-blank-unserializablestate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/exception-order-not-fully-active-unserializablestate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/history-pushState-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/history-replaceState-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/location-reload-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/not-fully-active-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/opaque-origin-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/same-document-away-and-back-location-api-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/unserializable-expected.txt:
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::updateCurrentEntry):
* Source/WebCore/page/Navigation.h:
* Source/WebCore/page/Navigation.idl:
* Source/WebCore/page/NavigationHistoryEntry.cpp:
(WebCore::NavigationHistoryEntry::getState const):
* Source/WebCore/page/NavigationHistoryEntry.h:
* Source/WebCore/page/NavigationHistoryEntry.idl:

Canonical link: https://commits.webkit.org/274321@main
  • Loading branch information
TingPing committed Feb 9, 2024
1 parent 3babd34 commit 6207ac0
Show file tree
Hide file tree
Showing 32 changed files with 122 additions and 48 deletions.
13 changes: 8 additions & 5 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -6889,11 +6889,11 @@ imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-e

# Navigation API is not yet fully implemented
webkit.org/b/258384 imported/w3c/web-platform-tests/navigation-api [ Skip ]
imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/ [ Pass ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/ [ Pass ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigation-back-forward-same-doc.html [ Skip ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/history-back-same-doc.html [ Skip ]
imported/w3c/web-platform-tests/navigation-api/commit-behavior/after-transition-uncancelable.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigate-from-initial-about-blank.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigate-from-initial-about-blank-same-doc.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/navigate-from-initial-about-blank-same-doc-popup.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/currententrychange-event/not-on-load.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/navigate-event/navigate-to-javascript.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/navigate-event/navigatesuccess-cross-document.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/navigate-event/replaceState-in-unload-then-remove-iframe.html [ Pass ]
Expand All @@ -6909,7 +6909,10 @@ imported/w3c/web-platform-tests/navigation-api/ordering-and-transition/transitio
imported/w3c/web-platform-tests/navigation-api/scroll-behavior/after-transition-intercept-handler-modifies.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/scroll-behavior/scroll-on-synthetic-event.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/scroll-behavior/scroll-without-intercept.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/no-args.html [ Pass ]
imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/same-document-away-and-back-location-api.html [ Skip ]
imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/cross-document-away-and-back.html [ Skip ]
imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/cross-document-location-api.html [ Skip ]
imported/w3c/web-platform-tests/navigation-api/updateCurrentEntry-method/location-reload.html [ Skip ]

# -- View Transitions -- #
# Reftest failures:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for link click null is not an object (evaluating 'navigation.currentEntry.index')
FAIL currententrychange fires for link click assert_true: expected true got false

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

PASS can't bypass required members by omitting the dictionary entirely
PASS from is required
FAIL all properties are reflected back Type error
FAIL defaults are as expected Type error
PASS all properties are reflected back
PASS defaults are as expected

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for history.back() promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'navigation.currentEntry.index')"
FAIL currententrychange fires for history.back() assert_equals: expected 3 but got 2

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for history.pushState() null is not an object (evaluating 'navigation.currentEntry.index')
FAIL currententrychange fires for history.pushState() assert_true: expected true got false

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for history.replaceState() null is not an object (evaluating 'navigation.currentEntry.index')
FAIL currententrychange fires for history.replaceState() assert_true: expected true got false

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for location API navigations null is not an object (evaluating 'navigation.currentEntry.index')
FAIL currententrychange fires for location API navigations assert_true: expected true got false

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for same-document navigation.back() and navigation.forward() promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'navigation.currentEntry.index')"
FAIL currententrychange fires for same-document navigation.back() and navigation.forward() assert_equals: expected 3 but got 2

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange does not fire when onnavigate preventDefault() is called promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'promise.then')"
FAIL currententrychange does not fire when onnavigate preventDefault() is called assert_unreached: Should have rejected: undefined Reached unreachable code

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for navigation.navigate() with replace promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'navigation.currentEntry.index')"
FAIL currententrychange fires for navigation.navigate() with replace assert_true: expected true got false

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for navigation.navigate() promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'navigation.currentEntry.index')"
FAIL currententrychange fires for navigation.navigate() assert_true: expected true got false

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL currententrychange fires for navigation.updateCurrentEntry() assert_equals: expected 1 but got 0
PASS currententrychange fires for navigation.updateCurrentEntry()

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL updateCurrentEntry() works as expected null is not an object (evaluating 'navigation.currentEntry.getState')
PASS updateCurrentEntry() works as expected

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


FAIL entry.getState() behavior after navigating away and back assert_equals: expected 1 but got 0
FAIL entry.getState() behavior after navigating away and back assert_equals: expected 1 but got 4

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


FAIL entry.getState() behavior after cross-document location API navigation assert_equals: expected 1 but got 0
FAIL entry.getState() behavior after cross-document location API navigation assert_equals: expected 1 but got 4

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

FAIL updateCurrentEntry() with unserializable state on the initial about:blank must throw an "InvalidStateError", not a "DataCloneError" assert_throws_dom: function "() => {
iframe.contentWindow.navigation.updateCurrentEntry({ state: document.body });
}" did not throw
}" threw object "DataCloneError: The object can not be cloned." that is not a DOMException InvalidStateError: property "code" is equal to 25, expected 11

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

FAIL updateCurrentEntry() with unserializable state while not fully active must throw an "InvalidStateError", not a "DataCloneError" assert_throws_dom: function "() => {
wNavigation.updateCurrentEntry({ state: document.body });
}" did not throw
PASS updateCurrentEntry() with unserializable state while not fully active must throw an "InvalidStateError", not a "DataCloneError"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL entry.getState() after history.pushState() null is not an object (evaluating 'navigation.currentEntry.getState')
FAIL entry.getState() after history.pushState() assert_equals: expected (undefined) undefined but got (object) object "[object Object]"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL entry.getState() after history.replaceState() null is not an object (evaluating 'navigation.currentEntry.getState')
FAIL entry.getState() after history.replaceState() assert_equals: expected (undefined) undefined but got (object) object "[object Object]"

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


FAIL entry.getState() after location.reload() assert_equals: expected 1 but got 0
FAIL entry.getState() after location.reload() assert_equals: expected 1 but got 4

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

FAIL updateCurrentEntry() must throw if the document is not fully active assert_throws_dom: function "() => {
wNavigation.updateCurrentEntry({ state: 1 });
}" did not throw
PASS updateCurrentEntry() must throw if the document is not fully active

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@


FAIL navigation.updateCurrentEntry() in an opaque origin iframe assert_throws_dom: function "() => {
navigation.updateCurrentEntry({ state: 1 });
}" did not throw
PASS navigation.updateCurrentEntry() in an opaque origin iframe

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CONSOLE MESSAGE: Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'entry0.index')
CONSOLE MESSAGE: Unhandled Promise Rejection: Error: assert_equals: expected 3 but got 2

Harness Error (FAIL), message = Unhandled rejection: null is not an object (evaluating 'entry0.index')
Harness Error (FAIL), message = Unhandled rejection: assert_equals: expected 3 but got 2

TIMEOUT entry.getState() behavior after navigating away using the location API, then back Test timed out

Harness Error (FAIL), message = Unhandled rejection: null is not an object (evaluating 'entry0.index')
Harness Error (FAIL), message = Unhandled rejection: assert_equals: expected 3 but got 2

TIMEOUT entry.getState() behavior after navigating away using the location API, then back Test timed out

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@


FAIL updateCurrentEntry() must throw if state is unserializable (WritableStream) assert_throws_dom: function "() => {
iframe.contentWindow.navigation.updateCurrentEntry({ state: new WritableStream() });
}" did not throw
PASS updateCurrentEntry() must throw if state is unserializable (WritableStream)
FAIL updateCurrentEntry() must throw if state is unserializable (SharedArrayBuffer) assert_throws_dom: function "() => {
iframe.contentWindow.navigation.updateCurrentEntry({ state: buffer });
}" did not throw
Expand Down
7 changes: 7 additions & 0 deletions Source/WebCore/history/HistoryItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void HistoryItem::reset()
m_itemSequenceNumber = generateSequenceNumber();

m_stateObject = nullptr;
m_navigationAPIStateObject = nullptr;
m_documentSequenceNumber = generateSequenceNumber();

m_formData = nullptr;
Expand Down Expand Up @@ -278,6 +279,12 @@ void HistoryItem::setStateObject(RefPtr<SerializedScriptValue>&& object)
notifyChanged();
}

// https://html.spec.whatwg.org/multipage/browsing-the-web.html#she-navigation-api-state
void HistoryItem::setNavigationAPIStateObject(RefPtr<SerializedScriptValue>&& object)
{
m_navigationAPIStateObject = WTFMove(object);
}

void HistoryItem::addChildItem(Ref<HistoryItem>&& child)
{
ASSERT(!childItemWithTarget(child->target()));
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/history/HistoryItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class HistoryItem : public RefCounted<HistoryItem>, public CanMakeWeakPtr<Histor
WEBCORE_EXPORT void setStateObject(RefPtr<SerializedScriptValue>&&);
SerializedScriptValue* stateObject() const { return m_stateObject.get(); }

void setNavigationAPIStateObject(RefPtr<SerializedScriptValue>&&);
SerializedScriptValue* navigationAPIStateObject() const { return m_navigationAPIStateObject.get(); }

void setItemSequenceNumber(long long number) { m_itemSequenceNumber = number; }
long long itemSequenceNumber() const { return m_itemSequenceNumber; }

Expand Down Expand Up @@ -255,6 +258,9 @@ class HistoryItem : public RefCounted<HistoryItem>, public CanMakeWeakPtr<Histor
// Support for HTML5 History
RefPtr<SerializedScriptValue> m_stateObject;

// Navigation API
RefPtr<SerializedScriptValue> m_navigationAPIStateObject;

// info used to repost form data
RefPtr<FormData> m_formData;
String m_formContentType;
Expand Down
32 changes: 29 additions & 3 deletions Source/WebCore/page/Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
#include "config.h"
#include "Navigation.h"

#include "Exception.h"
#include "HistoryItem.h"
#include "JSNavigationHistoryEntry.h"
#include "NavigationCurrentEntryChangeEvent.h"
#include "SerializedScriptValue.h"
#include <optional>
#include <wtf/IsoMallocInlines.h>

namespace WebCore {
Expand All @@ -41,10 +45,10 @@ Navigation::Navigation(ScriptExecutionContext* context, LocalDOMWindow& window)
}

// https://html.spec.whatwg.org/multipage/nav-history-apis.html#initialize-the-navigation-api-entries-for-a-new-document
void Navigation::initializeEntries(const Ref<HistoryItem>& currentItem, const Vector<Ref<HistoryItem>>& items)
void Navigation::initializeEntries(const Ref<HistoryItem>& currentItem, Vector<Ref<HistoryItem>>& items)
{
for (Ref item : items)
m_entries.append(NavigationHistoryEntry::create(protectedScriptExecutionContext().get(), item->url()));
m_entries.append(NavigationHistoryEntry::create(protectedScriptExecutionContext().get(), item));
m_currentEntryIndex = items.find(currentItem);
}

Expand Down Expand Up @@ -130,8 +134,30 @@ Navigation::Result Navigation::forward(Options&&, Ref<DeferredPromise>&& committ
return result;
}

void Navigation::updateCurrentEntry(UpdateCurrentEntryOptions&&)
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-updatecurrententry
ExceptionOr<void> Navigation::updateCurrentEntry(JSDOMGlobalObject& globalObject, UpdateCurrentEntryOptions&& options)
{
if (!window()->frame() || !window()->frame()->document())
return Exception { ExceptionCode::InvalidStateError };

auto current = currentEntry();
if (!current)
return Exception { ExceptionCode::InvalidStateError };

auto serializedState = SerializedScriptValue::create(globalObject, options.state, SerializationForStorage::Yes, SerializationErrorMode::Throwing);
if (!serializedState)
return { };

current->setState(WTFMove(serializedState));

auto currentEntryChangeEvent = NavigationCurrentEntryChangeEvent::create({ "currententrychange"_s }, {
{ false, false, false },
std::nullopt,
current
});
dispatchEvent(currentEntryChangeEvent);

return { };
}

// https://html.spec.whatwg.org/multipage/nav-history-apis.html#has-entries-and-events-disabled
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/page/Navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Navigation final : public RefCounted<Navigation>, public EventTarget, publ
bool canGoBack() const { return m_canGoBack; };
bool canGoForward() const { return m_canGoForward; };

void initializeEntries(const Ref<HistoryItem>& currentItem, const Vector<Ref<HistoryItem>> &items);
void initializeEntries(const Ref<HistoryItem>& currentItem, Vector<Ref<HistoryItem>> &items);

Result navigate(const String& url, NavigateOptions&&, Ref<DeferredPromise>&&, Ref<DeferredPromise>&&);

Expand All @@ -92,7 +92,7 @@ class Navigation final : public RefCounted<Navigation>, public EventTarget, publ
Result back(Options&&, Ref<DeferredPromise>&&, Ref<DeferredPromise>&&);
Result forward(Options&&, Ref<DeferredPromise>&&, Ref<DeferredPromise>&&);

void updateCurrentEntry(UpdateCurrentEntryOptions&&);
ExceptionOr<void> updateCurrentEntry(JSDOMGlobalObject&, UpdateCurrentEntryOptions&&);

private:
Navigation(ScriptExecutionContext*, LocalDOMWindow&);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/Navigation.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
] interface Navigation : EventTarget {
sequence<NavigationHistoryEntry> entries();
readonly attribute NavigationHistoryEntry? currentEntry;
undefined updateCurrentEntry(NavigationUpdateCurrentEntryOptions options);
[CallWith=CurrentGlobalObject] undefined updateCurrentEntry(NavigationUpdateCurrentEntryOptions options);
readonly attribute NavigationTransition? transition;

readonly attribute boolean canGoBack;
Expand Down
31 changes: 31 additions & 0 deletions Source/WebCore/page/NavigationHistoryEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@
#include "config.h"
#include "NavigationHistoryEntry.h"

#include "JSDOMGlobalObject.h"
#include "ScriptExecutionContext.h"
#include "SerializedScriptValue.h"
#include <JavaScriptCore/JSCJSValueInlines.h>
#include <wtf/IsoMallocInlines.h>

namespace WebCore {

WTF_MAKE_ISO_ALLOCATED_IMPL(NavigationHistoryEntry);

NavigationHistoryEntry::NavigationHistoryEntry(ScriptExecutionContext* context, Ref<HistoryItem>& historyItem)
: ContextDestructionObserver(context)
, m_url(historyItem->url())
, m_key(WTF::UUID::createVersion4())
, m_id(WTF::UUID::createVersion4())
, m_associatedHistoryItem(historyItem)
{
}

NavigationHistoryEntry::NavigationHistoryEntry(ScriptExecutionContext* context, const URL& url)
: ContextDestructionObserver(context)
, m_url(url)
Expand All @@ -52,4 +63,24 @@ EventTargetInterface NavigationHistoryEntry::eventTargetInterface() const
return NavigationHistoryEntryEventTargetInterfaceType;
}

JSC::JSValue NavigationHistoryEntry::getState(JSDOMGlobalObject& globalObject) const
{
if (!m_associatedHistoryItem)
return JSC::jsUndefined();

auto stateObject = m_associatedHistoryItem->get().navigationAPIStateObject();
if (!stateObject)
return JSC::jsUndefined();

return stateObject->deserialize(globalObject, &globalObject, SerializationErrorMode::Throwing);
}

void NavigationHistoryEntry::setState(RefPtr<SerializedScriptValue>&& state)
{
if (!m_associatedHistoryItem)
return;

m_associatedHistoryItem->get().setNavigationAPIStateObject(WTFMove(state));
}

} // namespace WebCore
13 changes: 11 additions & 2 deletions Source/WebCore/page/NavigationHistoryEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ContextDestructionObserver.h"
#include "EventHandler.h"
#include "EventTarget.h"
#include "HistoryItem.h"
#include <wtf/RefCounted.h>
#include <wtf/UUID.h>

Expand All @@ -37,22 +38,29 @@ class JSValue;

namespace WebCore {

class SerializedScriptValue;
class HistoryItem;

class NavigationHistoryEntry final : public RefCounted<NavigationHistoryEntry>, public EventTarget, public ContextDestructionObserver {
WTF_MAKE_ISO_ALLOCATED(NavigationHistoryEntry);
public:
using RefCounted<NavigationHistoryEntry>::ref;
using RefCounted<NavigationHistoryEntry>::deref;

static Ref<NavigationHistoryEntry> create(ScriptExecutionContext* context, Ref<HistoryItem>& historyItem) { return adoptRef(*new NavigationHistoryEntry(context, historyItem)); }
static Ref<NavigationHistoryEntry> create(ScriptExecutionContext* context, const URL& url) { return adoptRef(*new NavigationHistoryEntry(context, url)); }

const String& url() const { return m_url.string(); };
String key() const { return m_key.toString(); };
String id() const { return m_id.toString(); };
uint64_t index() const { return m_index; };
bool sameDocument() const { return m_sameDocument; };
const JSC::JSValue& getState() const { return m_state; };
JSC::JSValue getState(JSDOMGlobalObject&) const;

void setState(RefPtr<SerializedScriptValue>&&);

private:
NavigationHistoryEntry(ScriptExecutionContext*, Ref<HistoryItem>&);
NavigationHistoryEntry(ScriptExecutionContext*, const URL&);

EventTargetInterface eventTargetInterface() const final;
Expand All @@ -64,7 +72,8 @@ class NavigationHistoryEntry final : public RefCounted<NavigationHistoryEntry>,
const WTF::UUID m_key;
const WTF::UUID m_id;
uint64_t m_index;
JSC::JSValue m_state;
// TODO: Every entry is supposed to have an associated history item.
std::optional<Ref<HistoryItem>> m_associatedHistoryItem;
bool m_sameDocument;
};

Expand Down
Loading

0 comments on commit 6207ac0

Please sign in to comment.