mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 17:18:11 +00:00
LibWeb: Add state field to History
This is the "classic history API state" referenced in the current HTML spec.
This commit is contained in:
parent
2c27b4e63c
commit
49e0466a3d
3 changed files with 17 additions and 1 deletions
|
@ -38,6 +38,7 @@ void History::visit_edges(Cell::Visitor& visitor)
|
|||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_associated_document);
|
||||
visitor.visit(m_state);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-history-pushstate
|
||||
|
@ -65,6 +66,17 @@ WebIDL::ExceptionOr<u64> History::length() const
|
|||
return m_length;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-history-state
|
||||
WebIDL::ExceptionOr<JS::Value> History::state() const
|
||||
{
|
||||
// 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 state on a document that isn't fully active."_fly_string);
|
||||
|
||||
// 2. Return this's state.
|
||||
return m_state;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-history-go
|
||||
WebIDL::ExceptionOr<void> History::go(long delta = 0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue