UrlbarQueryContext Reference
- class UrlbarQueryContext(options)
UrlbarQueryContext defines a user’s autocomplete input from within the urlbar. It supplements it with details of how the search results should be obtained and what they consist of.
Constructs the UrlbarQueryContext instance.
- Arguments:
options (object) – The initial options for UrlbarQueryContext.
options.sapName (string) – The search access point name of the UrlbarInput for use with telemetry or logging, e.g. urlbar, searchbar.
options.searchString (string) – The string the user entered in autocomplete. Could be the empty string in the case of the user opening the popup via the mouse.
options.isPrivate (boolean) – Set to true if this query was started from a private browsing window.
options.maxResults (number) – The maximum number of results that will be displayed for this query.
options.allowAutofill (boolean) – Whether or not to allow providers to include autofill results.
options.userContextId (number) – The container id where this context was generated, if any.
options.tabGroup (string|null) – The tab group where this context was generated, if any.
options.sources (Array) – A list of acceptable UrlbarShared.RESULT_SOURCE for the context.
options.searchMode (object) – The input’s current search mode. See UrlbarInput.setSearchMode for a description.
options.prohibitRemoteResults (boolean) – This provides a short-circuit override for context.allowRemoteResults. If it’s false, then allowRemoteResults will do its usual checks to determine whether remote results are allowed. If it’s true, then allowRemoteResults will immediately return false. Defaults to false.
- UrlbarQueryContext.allowAutofill
type: boolean
Whether or not to allow providers to include autofill results.
- UrlbarQueryContext.canceled
type: boolean
Whether or not the query has been cancelled.
- UrlbarQueryContext.currentPage
type: string
URL of the page that was loaded when the search began. Only set in a browser window; a content urlbar leaves it undefined.
- UrlbarQueryContext.excludeSponsoredResults
type: boolean
Whether or not to exclude sponsored results.
- UrlbarQueryContext.firstResult
type: UrlbarResult
The current firstResult.
- UrlbarQueryContext.firstResultChanged
type: boolean
Indicates if the first result has been changed changed.
- UrlbarQueryContext.fixupError
Returns the error that was thrown when fixupInfo was fetched, if any. If fixupInfo has not yet been fetched for this queryContext, it is fetched here.
- UrlbarQueryContext.fixupInfo
Caches and returns fixup info from URIFixup for the current search string. Only returns a subset of the properties from URIFixup. This is both to reduce the memory footprint of UrlbarQueryContexts and to keep them serializable so they can be sent to extensions.
IMPORTANT: This uses Services, so it only works in privileged code.
- UrlbarQueryContext.heuristicResult
type: UrlbarResult
The heuristic result associated with the context.
- UrlbarQueryContext.id
type: number
Identifies this query among the ones its input started. It survives the trip across the actor boundary, so a notification can be matched with the query it belongs to, and results of a superseded query discarded.
- UrlbarQueryContext.isPrivate
type: boolean
True if this query was started from a private browsing window.
- UrlbarQueryContext.isSearchbarSAP
type: boolean
Whether the query runs in a bar dedicated to search.
See UrlbarShared.isSearchbarSAP.
- UrlbarQueryContext.keywordEnabled
type: boolean
Whether a string that isn’t a URL may be searched for.
See UrlbarShared.keywordEnabled.
- UrlbarQueryContext.maxResults
type: number
The maximum number of results that will be displayed for this query.
- UrlbarQueryContext.muxer
type: string
The name of the muxer to use for this query.
type: boolean
Whether a string that is a URL may be navigated to.
See UrlbarShared.navigationEnabled.
type: boolean
Whether a string that is a URL may be navigated to in an engine search mode.
See UrlbarShared.navigationInSearchModeEnabled.
- UrlbarQueryContext.prohibitRemoteResults
type: boolean
Whether or not to prohibit remote results.
- UrlbarQueryContext.providers
type: Array.<string>
List of registered provider names. Providers can be registered through the ProvidersManager.
- UrlbarQueryContext.restrictSource
type: ?Values<typeof UrlbarShared.RESULT_SOURCE>
Set if this context is restricted to a single source.
- UrlbarQueryContext.restrictToken
type: UrlbarSearchStringTokenData
The restriction token used to restrict the sources for this search.
- UrlbarQueryContext.results
type: Array.<UrlbarResult>
The results associated with this context.
- UrlbarQueryContext.sapName
type: string
The search access point name of the UrlbarInput for use with telemetry or logging, e.g. urlbar, searchbar.
- UrlbarQueryContext.searchMode
type: UrlbarSearchModeData
Details about the search mode associated with this context.
- UrlbarQueryContext.searchString
type: string
The string the user entered in autocomplete.
- UrlbarQueryContext.sources
type: Values<typeof UrlbarShared.RESULT_SOURCE>[]
The possible sources of results for this context.
- UrlbarQueryContext.tabGroup
type: string|null
The tab group the query runs in. Only set in a browser window; a content urlbar keeps the default null.
- UrlbarQueryContext.tokens
type: Array.<UrlbarSearchStringTokenData>
A list of tokens extracted from the search string.
- UrlbarQueryContext.userContextId
type: number
The container id the query runs in, normalized to the id the open-pages table is keyed by (some providers read it directly). Only set in a browser window; a content urlbar keeps the default 0. Assign it from UrlbarShared.normalizedUserContextId().
- UrlbarQueryContext.allowRemoteResults(searchString, allowEmptySearchString=false)
Returns whether results from remote services are generally allowed for the context. Callers can impose further restrictions as appropriate, but typically they should not fetch remote results if this returns false.
- Arguments:
searchString (string) – Usually this is just the context’s search string, but if you need to fetch remote results based on a modified version, you can pass it here.
allowEmptySearchString (boolean) – Whether to check for the minimum length of the search string.
- Returns:
boolean – Whether remote results are allowed.
- UrlbarQueryContext.restrictInSearchMode()
Utility function to determine whether we should use the existence of searchMode to restrict the type of results to only search suggestions or the new behaviour behind historyInSearchMode pref that shows all types of results in searchMode, treating engine searchMode as “temporarily changed default search engine”.
- Returns:
boolean
- UrlbarQueryContext.toWire()
Serializes this context to a plain, structured-cloneable object for sending across the Urlbar actor boundary. The context’s own fields survive structured-clone on their own, but its nested UrlbarResults keep their data in private fields, so they’re replaced with their wire forms.
- Returns:
object – The wire representation; reconstruct with fromWire().
- static UrlbarQueryContext.fromWire(wire)
Reconstructs a UrlbarQueryContext from the plain object produced by toWire(), e.g. after it has crossed the Urlbar actor boundary: structured- clone preserved the context’s own fields but dropped its class identity and its results’ private-field data, so restore the prototype and rebuild the results.
- Arguments:
wire (object) – The wire representation from toWire().
- Returns:
UrlbarQueryContext – The reconstructed context.