UrlbarResult Reference
- class UrlbarResult(params)
Class used to create a single result.
- Arguments:
params (object)
params.type (Values<typeof UrlbarShared.RESULT_TYPE>)
params.source (Values<typeof UrlbarShared.RESULT_SOURCE>)
params.autofill (UrlbarAutofillData)
params.exposureTelemetry (number)
params.group (Values<typeof UrlbarShared.RESULT_GROUP>)
params.heuristic (boolean)
params.hideRowLabel (boolean)
params.isBestMatch (boolean)
params.isBottomUrlSuggestion (boolean)
params.isRichSuggestion (boolean)
params.isSuggestedIndexRelativeToGroup (boolean)
params.providerName (string)
params.resultSpan (number)
params.richSuggestionIconSize (number)
params.richSuggestionIconVariation (string)
params.rowLabel ({id: string, args?: L10nArgs})
params.showFeedbackMenu (boolean)
params.suggestedIndex (number)
params.payload (Payload)
params.highlights (Highlights)
params.testForceNewContent (boolean) – Used for test only.
params.skipPayloadValidation (boolean) – Skips payload schema validation. Set by UrlbarResult.fromWire when reconstructing a result that was already validated before serialization; the wire payload can carry internal fields added after validation.
- UrlbarResult.autofill
type: UrlbarAutofillData|undefined
The text to autofill in the input when the result is selected, if any.
- UrlbarResult.commands
type: ?Array.<UrlbarResultCommand>|undefined
The result menu commands the result’s provider offers, computed eagerly by the providers manager when the result is finalized. Undefined if the provider offers none.
- UrlbarResult.exposureTelemetry
type: number
Whether exposure telemetry is recorded for the result, and whether the result is then shown or hidden. One of UrlbarShared.EXPOSURE_TELEMETRY.
- UrlbarResult.group
The group the muxer places the result in, one of UrlbarShared.RESULT_GROUP. Undefined if the muxer picks the group.
- UrlbarResult.hasSuggestedIndex
Returns whether the result’s suggestedIndex property is defined. suggestedIndex is an optional hint to the muxer that can be set to suggest a specific position among the results.
- UrlbarResult.heuristic
type: boolean
Whether the result is the heuristic result, the one that is picked when the user presses Enter without selecting a result.
- UrlbarResult.hideRowLabel
type: boolean
Whether the view hides the group label above the result’s row.
- UrlbarResult.icon
Returns an icon url.
- UrlbarResult.id
type: number
A stable id assigned once when the result is finalized by UrlbarProvidersManager. Unlike rowIndex it never changes and is independent of the results’ order, so it matches this result to its context entry and view row across the actor boundary.
- UrlbarResult.isBestMatch
type: boolean
Whether the result is a best match, which the view shows as a top pick.
- UrlbarResult.isBottomUrlSuggestion
type: boolean
Whether the view shows the result as a URL row at the bottom of the results.
- UrlbarResult.isHiddenExposure
Convenience getter that returns whether the result’s exposure telemetry indicates it should be hidden.
- UrlbarResult.isRichSuggestion
type: boolean
Whether the view shows the result as a rich suggestion, with a larger icon and a description. Always true for a tip.
- UrlbarResult.isSERP
type: boolean
Whether the result’s URL is a search engine results page. Resolved when the result is finalized, since it takes the search service, which only the parent process has.
- UrlbarResult.isSuggestedIndexRelativeToGroup
type: boolean
Whether suggestedIndex is relative to the result’s group instead of the entire result set.
- UrlbarResult.payload
The result’s data. Which properties it holds depends on type, and UrlbarUtils.RESULT_PAYLOAD_SCHEMA describes them.
- UrlbarResult.providerName
type: string
The name of the provider that created the result.
- UrlbarResult.providerType
type: ?Values<typeof UrlbarShared.PROVIDER_TYPE>
The type of the UrlbarProvider providing the result.
- UrlbarResult.resultSpan
type: number
The number of rows the result spans in the view. Undefined to use the default for the result’s type, which UrlbarShared.getSpanForResult returns.
- UrlbarResult.richSuggestionIconSize
type: number
The size in pixels of the rich suggestion icon. 24 for a tip.
- UrlbarResult.richSuggestionIconVariation
type: string
The variation of the rich suggestion icon, which the view sets as the row’s icon-variation attribute for the stylesheet to match.
- UrlbarResult.rowIndex
type: number
The index of the row where this result is in the suggestions. This is updated by UrlbarView when new result sets are displayed.
- UrlbarResult.rowLabel
type: object
The group label to show above the result’s row, as a { id, args } l10n object, overriding the label the view picks.
- UrlbarResult.showFeedbackMenu
type: boolean
Whether the result’s menu button is labeled as a feedback menu.
- UrlbarResult.source
The data the result was derived from, one of UrlbarShared.RESULT_SOURCE. A result derived from several sources uses the most privacy-restricted one.
- UrlbarResult.suggestedIndex
type: number
A preferred position for the result within the result set, or within its group if isSuggestedIndexRelativeToGroup is true. A negative index counts from the end. Undefined if the result has none.
- UrlbarResult.type
The kind of result, one of UrlbarShared.RESULT_TYPE. It decides which payload properties the result has and how the view shows it.
- UrlbarResult.getDisplayableValueAndHighlights(payloadName, options)
Get value and highlights of given payloadName that can display in the view.
- Arguments:
payloadName (string) – The payload name to want to get the value.
options (object)
options.tokens (object) – Make highlighting that matches this tokens. If no specific tokens, this function returns only value.
options.isURL (object) – If true, the value will be from UrlbarShared.prepareUrlForDisplay().
- UrlbarResult.toString()
This is useful for logging results. If you need the full payload, then it’s better to JSON.stringify the result object itself.
- Returns:
string – string representation of the result.
- UrlbarResult.toWire()
Serializes this result to a plain, structured-cloneable object for sending across the Urlbar actor boundary. Most data lives in private fields that a bare structuredClone() would drop, so capture it explicitly; id, rowIndex, commands, and isSERP are the public own properties.
- Returns:
object – The wire representation; reconstruct with fromWire().
- static UrlbarResult.fromWire(wire, liveResults=null)
Reconstructs a UrlbarResult from the plain object produced by toWire(), e.g. after it has crossed the Urlbar actor boundary.
Structured clone strips data that doesn’t survive it (e.g. a Rust suggestion’s UniFFI Suggestion class), so a reconstruction is a lossy object distinct from the one that was serialized. Where the originals are still around – the parent’s own query results – pass them as liveResults to get the original back instead, carrying over the view-assigned rowIndex the wire preserves (the original never went through a view).
- Arguments:
wire (object) – The wire representation from toWire().
liveResults (Array.<UrlbarResult>) – Results to match wire against by id.
- Returns:
UrlbarResult – The matching result from liveResults, else the reconstruction.