we (web engine): Experimental web browser project to understand the limits of Claude

Implement window.history History API #159

open opened by pierrelf.com

Description#

Implement the History API (window.history) per the WHATWG HTML spec. This enables single-page applications to manage navigation state without full page reloads.

Requirements#

Properties#

  • history.length — number of entries in the session history
  • history.state — the state object for the current entry (or null)
  • history.scrollRestorationauto or manual

Methods#

  • history.pushState(state, title, url) — push a new entry without page reload. URL must be same-origin. State is structured-cloned.
  • history.replaceState(state, title, url) — replace the current entry without page reload. Same constraints as pushState.
  • history.back() — equivalent to history.go(-1)
  • history.forward() — equivalent to history.go(1)
  • history.go(delta) — traverse by delta steps. history.go(0) reloads.

Events#

  • popstate event fires on the window when the active history entry changes due to traversal (back/forward/go), NOT when pushState/replaceState is called
  • Event has a state property containing the state object of the new entry
  • popstate fires after the entry is activated

Constraints#

  • pushState/replaceState URL must be same-origin as current document
  • State object must be serializable (structured clone)
  • Rapid pushState calls should be rate-limited to prevent abuse

Acceptance Criteria#

  • pushState adds entry and updates URL bar without page reload
  • replaceState updates current entry without adding new one
  • back()/forward()/go() traverse the history
  • popstate event fires with correct state on traversal
  • history.length reflects actual entry count
  • Cross-origin URL in pushState throws SecurityError
  • Unit tests for all History API methods and popstate event
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mii3vv2srw2h