UrlbarChildController Reference

class UrlbarChildController(options)

The in-process face of the address bar controller. Lives next to the <moz-urlbar> custom element and forwards work that has to happen in the parent process to a paired UrlbarParentController via the UrlbarChild/UrlbarParent JSWindowActor pair. The actor owns the per-instance bookkeeping (instance id, lifetime); this wrapper just holds the controller it hands back.

The wrapper abstracts the transport: on the direct path (chrome <moz-urlbar>) the actor pair hands back the real UrlbarParentController and calls happen synchronously, while on the message path (a content-process <moz-urlbar>, or chrome with the pref) it gets a proxy implementing the same surface. Callers (UrlbarInput, UrlbarView) don’t distinguish them.

Arguments:
UrlbarChildController.UrlbarChildController
UrlbarChildController.input

type: unknown

UrlbarChildController.parentController

type: UrlbarParentController

The paired parent controller – the real UrlbarParentController on the direct path, or the UrlbarParentControllerProxy on the message path.

UrlbarChildController.userSelectionBehavior

type: “arrow”|”tab”|”none”

The selection behavior that the user has used to select a result. The setter ignores a change to “arrow” once “tab” has been recorded, since we want to know that tab was used first.

UrlbarChildController.focusBrowser(browserId)
Arguments:
  • browserId (number) – The browser the load resolved to, as returned by loadURL.

Returns:

Promise.<{focused: boolean}>|Object – Whether the browser was focused.

UrlbarChildController.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.

Arguments:
  • 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.

UrlbarChildController.isCanonizeKeyboardEvent(event)

Returns whether the passed-in event represents a canonization request.

Arguments:
  • event (Event) – An Event to examine.

Returns:

boolean – Whether the event is a KeyboardEvent that triggers canonization.

UrlbarChildController.keyEventMovesCaret(event)

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.

Arguments:
  • event (KeyboardEvent) – The DOM KeyboardEvent.

Returns:

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

UrlbarChildController.openSERP(engineId, searchTerms, where, inBackground)
UrlbarChildController.openSearchForm(engineId, where, inBackground)
UrlbarChildController.startQuery(queryContext)

Starts a query and returns the parent controller’s promise so callers (the input’s lastQueryContextPromise, which tests await) can track completion.

Arguments:
  • queryContext (UrlbarQueryContext)

Returns:

Promise.<UrlbarQueryContext> – Resolves with the finished context.

UrlbarChildController.whereToOpen(event)

Determines where a URL/page picked in <moz-urlbar> should be opened. Only the BrowserUtils.whereToOpenLink call is routed through the actor (a system module the content-web scope can’t import); everything else, including the guarded empty-tab read, is content-safe and stays here.

Arguments:
  • event (KeyboardEvent|MouseEvent) – The event that triggered the opening.

Returns:

"current"|"tabshifted"|"tab"|"save"|"window"