To navigate a navigable navigable to a URL url using an optional Document-or-null sourceDocument (default null), with an optional POST resource, string, or null documentResource (default null), an optional response-or-null response (default null), an optional boolean exceptionsEnabled (default false), an optional NavigationHistoryBehavior historyHandling (default "auto"), an optional serialized state-or-null navigationAPIState (default null), an optional entry list or null formDataEntryList (default null), an optional referrer policy referrerPolicy (default the empty string), an optional user navigation involvement userInvolvement (default "none"), an optional Element sourceElement (default null), an optional boolean initialInsertion (default false), and an optional navigation API method tracker-or-null apiMethodTracker (default null):

  1. Let cspNavigationType be "form-submission" if formDataEntryList is non-null; otherwise "other".

  2. Let sourceSnapshotParams be the result of snapshotting source snapshot params given sourceDocument.

  3. Let initiatorOriginSnapshot be a new opaque origin.

  4. Let initiatorBaseURLSnapshot be about:blank.

  5. If sourceDocument is null:

    1. Assert: userInvolvement is "browser UI".

    2. If url's scheme is "javascript", then set initiatorOriginSnapshot to navigable's active document's origin.

  6. Otherwise:

    1. Assert: userInvolvement is not "browser UI".

    2. Set initiatorOriginSnapshot to sourceDocument's origin.

    3. Set initiatorBaseURLSnapshot to sourceDocument's document base URL.

  7. Let navigationId be the result of generating a random UUID. [WEBCRYPTO]

  8. If the surrounding agent is equal to navigable's active document's relevant agent, then continue these steps. Otherwise, queue a global task on the navigation and traversal task source given navigable's active window to continue these steps.

    We do this because we are about to look at a lot of properties of navigable's active document, which are in theory only accessible over in the appropriate event loop. (But, we do not want to unconditionally queue a task, since — for example — same-event-loop fragment navigations need to take effect synchronously.)

    Another implementation strategy would be to replicate the relevant information across event loops, or into a canonical "browser process", so that it can be consulted without queueing a task. This could give different results than what we specify here in edge cases, where the relevant properties have changed over in the target event loop but not yet been replicated. Further testing is needed to determine which of these strategies best matches browser behavior, in such racy edge cases.

  9. If navigable's active document's unload counter is greater than 0, then invoke WebDriver BiDi navigation failed with navigable and a WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url, and return.

  10. Let container be navigable's container.

  11. If container is an iframe element and will lazy load element steps given container returns true, then stop intersection-observing a lazy loading element container and set container's lazy load resumption steps to null.

  12. If navigable's allowed to perform a navigation or history update returns blocked, then invoke WebDriver BiDi navigation failed with navigable and a WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url, and return.

  13. If the navigation must be a replace given url and navigable's active document, then set historyHandling to "replace".

  14. If navigable's parent is non-null, then set navigable's is delaying load events to true.

  15. Let targetSnapshotParams be the result of snapshotting target snapshot params given navigable.

  16. Invoke WebDriver BiDi navigation started with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "pending", and url is url.

  17. If navigable's ongoing navigation is "traversal":

    1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.

    2. Return.

    Any attempts to navigate a navigable that is currently traversing are ignored.

  18. Set the ongoing navigation for navigable to navigationId.

    This will have the effect of aborting other ongoing navigations of navigable, since at certain points during navigation changes to the ongoing navigation will cause further work to be abandoned.

  19. If url's scheme is "javascript":

    1. Let request be a new request, with

      URL
      url
      client
      sourceSnapshotParams's fetch client
      policy container
      sourceSnapshotParams's source policy container

      This is a synthetic request, needed because the Content Security Policy check in navigate to a javascript: URL operates on a request. It will never hit the network.

    2. Queue a global task on the navigation and traversal task source given navigable's active window to navigate to a javascript: URL given navigable, request, historyHandling, initiatorOriginSnapshot, userInvolvement, cspNavigationType, initialInsertion, and navigationId.

    3. Return.

  20. If all of the following are true:

    then:

    1. Let navigation be navigable's active window's navigation API.

    2. Let entryListForFiring be formDataEntryList if documentResource is a POST resource; otherwise, null.

    3. Let navigationAPIStateForFiring be navigationAPIState if navigationAPIState is not null; otherwise, StructuredSerializeForStorage(undefined).

    4. Let continue be the result of firing a push/replace/reload navigate event at navigation with navigationType set to historyHandling, isSameDocument set to false, userInvolvement set to userInvolvement, sourceElement set to sourceElement, formDataEntryList set to entryListForFiring, destinationURL set to url, navigationAPIState set to navigationAPIStateForFiring, and apiMethodTracker set to apiMethodTracker.

    5. If continue is false, then return.

    It is possible for navigations with userInvolvement of "browser UI" or initiated by a cross origin-domain sourceDocument to fire navigate events, if they go through the earlier navigate to a fragment path.

  21. If sourceDocument is navigable's container document, then reserve deferred fetch quota for navigable's container given url's origin.

  22. In parallel, run these steps:

    1. Let unloadPromptCanceled be the result of checking if unloading is canceled for navigable's active document's inclusive descendant navigables.

    2. If unloadPromptCanceled is not "continue", or navigable's ongoing navigation is no longer navigationId:

      1. Invoke WebDriver BiDi navigation failed with navigable and a new WebDriver BiDi navigation status whose id is navigationId, status is "canceled", and url is url.

      2. Abort these steps.

    3. Queue a global task on the navigation and traversal task source given navigable's active window to abort a document and its descendants given navigable's active document.

    4. If url matches about:blank or is about:srcdoc:

      1. Set documentState's origin to initiatorOriginSnapshot.

      2. Set documentState's about base URL to initiatorBaseURLSnapshot.

    5. Let historyEntry be a new session history entry, with its URL set to url and its document state set to documentState.

    6. Let navigationParams be null.

    7. If response is non-null:

      The navigate algorithm is only supplied with a response as part of the object and embed processing models, or for processing parts of multipart/x-mixed-replace responses after the initial response.

      1. Let sourcePolicyContainer be a clone of the sourceDocument's policy container, if sourceDocument is not null; otherwise null.

      2. Let policyContainer be the result of determining navigation params policy container given response's URL, null, sourcePolicyContainer, navigable's container document's policy container, and null.

      3. Let finalSandboxFlags be the union of targetSnapshotParams's sandboxing flags and policyContainer's CSP list's CSP-derived sandboxing flags.

      4. Let responseOrigin be the result of determining the origin given response's URL, finalSandboxFlags, and documentState's initiator origin.

      5. Let coop be a new opener policy.

      6. Let coopEnforcementResult be a new opener policy enforcement result with

        url
        response's URL
        origin
        responseOrigin
        opener policy
        coop
      7. Set navigationParams to a new navigation params, with

        id
        navigationId
        navigable
        navigable
        request
        null
        response
        response
        fetch controller
        null
        commit early hints
        null
        COOP enforcement result
        coopEnforcementResult
        reserved environment
        null
        origin
        responseOrigin
        policy container
        policyContainer
        final sandboxing flag set
        finalSandboxFlags
        iframe element referrer policy
        targetSnapshotParams's iframe element referrer policy
        opener policy
        coop
        navigation timing type
        "navigate"
        about base URL
        documentState's about base URL
        user involvement
        userInvolvement
    8. Attempt to populate the history entry's document for historyEntry, given navigable, "navigate", sourceSnapshotParams, targetSnapshotParams, userInvolvement, navigationId, navigationParams, cspNavigationType, with allowPOST set to true and completionSteps set to the following step:

      1. Append session history traversal steps to navigable's traversable navigable to finalize a cross-document navigation given navigable, historyHandling, userInvolvement, and historyEntry.