UrlbarController Reference

class UrlbarController(options)

The address bar controller handles queries from the address bar, obtains results and returns them to the UI for display.

Listeners may be added to listen for the results. They may support the following methods which may be called when a query is run:

  • onQueryStarted(queryContext)

  • onQueryResults(queryContext)

  • onQueryCancelled(queryContext)

  • onQueryFinished(queryContext)

  • onQueryResultRemoved(index)

  • onViewOpen()

  • onViewClose()

Initialises the class. The manager may be overridden here, this is for test purposes.

  • options (object) – The initial options for UrlbarController.

  • options.input (UrlbarInput) – The input this controller is operating with.

  • options.manager (object) – Optional fake providers manager to override the built-in providers manager. Intended for use in unit tests only.


Initialises the class. The manager may be overridden here, this is for test purposes.


Stores the selection behavior that the user has used to select a result.


Adds a listener for query actions and results.

  • listener (object) – The listener to add.


TypeError – Throws if the listener is not an object.


Cancels an in-progress query. Note, queries may continue running if they can’t be cancelled.


Clear the previous query context cache.

UrlbarController.handleKeyNavigation(event, executeAction=true)

Receives keyboard events from the input and handles those that should navigate within the view or pick the currently selected item.

  • event (KeyboardEvent) – The DOM KeyboardEvent.

  • executeAction (boolean) – Whether the event should actually execute the associated action, or just be managed (at a preventDefault() level). This is used when the event will be deferred by the event bufferer, but preventDefault() and friends should still happen synchronously.


Checks whether a keyboard event that would normally open the view should instead be handled natively by the input field. On certain platforms, the up and down keys can be used to move the caret, in which case we only want to open the view if the caret is at the start or end of the input.

  • event (KeyboardEvent) – The DOM KeyboardEvent.


boolean – Returns true if the event should move the caret instead of opening the view.

UrlbarController.notify(name, ...params)

Notifies listeners of results.

  • name (string) – Name of the notification.

  • params (object) – Parameters to pass with the notification.


Receives results from a query.

  • queryContext (UrlbarQueryContext) – The query details.

UrlbarController.recordSelectedResult(event, result)

Records details of the selected result in telemetry. We only record the selection behavior, type and index.

  • event (Event) – The event which triggered the result to be selected.

  • result (UrlbarResult) – The selected result.


Removes a query listener.

  • listener (object) – The listener to add.


Removes a result from the current query context and notifies listeners. Heuristic results cannot be removed.

  • result (UrlbarResult) – The result to remove.


Hooks up the controller with a view.

  • view (UrlbarView) – The UrlbarView instance associated with this controller.

UrlbarController.speculativeConnect(result, context, reason)

Tries to initialize a speculative connection on a result. Speculative connections are only supported for a subset of all the results.

Speculative connect to:
  • Search engine heuristic results

  • autofill results

  • http/https results

  • result (UrlbarResult) – The result to speculative connect to.

  • context (UrlbarQueryContext) – The queryContext

  • reason (string) – Reason for the speculative connect request.


Takes a query context and starts the query based on the user input.

  • queryContext (UrlbarQueryContext) – The query details.