To perform a navigation API traversal given a Navigation navigation, a string key, and a NavigationOptions options:

  1. Let document be navigation's relevant global object's associated Document.

  2. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException.

  3. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException.

  4. Let current be the current entry of navigation.

  5. If key equals current's session history entry's navigation API key, then return «[ "committed" → a promise resolved with current, "finished" → a promise resolved with current ]».

  6. If navigation's upcoming traverse API method trackers[key] exists, then return a navigation API method tracker-derived result for navigation's upcoming traverse API method trackers[key].

  7. Let info be options["info"], if it exists; otherwise, undefined.

  8. Let apiMethodTracker be the result of adding an upcoming traverse API method tracker for navigation given key and info.

  9. Let navigable be document's node navigable.

  10. Let traversable be navigable's traversable navigable.

  11. Let sourceSnapshotParams be the result of snapshotting source snapshot params given document.

  12. Append the following session history traversal steps to traversable:

    1. Let navigableSHEs be the result of getting session history entries given navigable.

    2. Let targetSHE be the session history entry in navigableSHEs whose navigation API key is key. If no such entry exists:

      1. Queue a global task on the navigation and traversal task source given navigation's relevant global object to reject the finished promise for apiMethodTracker with an "InvalidStateError" DOMException.

      2. Abort these steps.

      This path is taken if navigation's entry list was outdated compared to navigableSHEs, which can occur for brief periods while all the relevant threads and processes are being synchronized in reaction to a history change.

    3. If targetSHE is navigable's active session history entry:

      1. Queue a global task on the navigation and traversal task source given navigation's relevant global object to reject the finished promise for apiMethodTracker with an "InvalidStateError" DOMException.

      2. Abort these steps.

      This can occur if a previously queued traversal already took us to this session history entry.

    4. Let result be the result of applying the traverse history step given by targetSHE's step to traversable, given sourceSnapshotParams, navigable, and "none".

    5. If result is "canceled-by-beforeunload", then queue a global task on the navigation and traversal task source given navigation's relevant global object to reject the finished promise for apiMethodTracker with a new "AbortError" DOMException created in navigation's relevant realm.

    6. If result is "initiator-disallowed", then queue a global task on the navigation and traversal task source given navigation's relevant global object to reject the finished promise for apiMethodTracker with a new "SecurityError" DOMException created in navigation's relevant realm.

      When result is "canceled-by-beforeunload" or "initiator-disallowed", the navigate event was never fired, aborting the ongoing navigation would not be correct; it would result in a navigateerror event without a preceding navigate event.

      In the "canceled-by-navigate" case, navigate is fired, but the inner navigate event firing algorithm will take care of aborting the ongoing navigation.

  13. Return a navigation API method tracker-derived result for apiMethodTracker.