Bug 1888908 - Rename current onEngagement to onLegacyEngagement r=mak
Differential Revision: https://phabricator.services.mozilla.com/D206251
This commit is contained in:
@@ -604,8 +604,8 @@ export class UrlbarController {
|
|||||||
/**
|
/**
|
||||||
* Triggers a "dismiss" engagement for the selected result if one is selected
|
* Triggers a "dismiss" engagement for the selected result if one is selected
|
||||||
* and it's not the heuristic. Providers that can respond to dismissals of
|
* and it's not the heuristic. Providers that can respond to dismissals of
|
||||||
* their results should implement `onEngagement()`, handle the dismissal, and
|
* their results should implement `onLegacyEngagement()`, handle the
|
||||||
* call `controller.removeResult()`.
|
* dismissal, and call `controller.removeResult()`.
|
||||||
*
|
*
|
||||||
* @param {Event} event
|
* @param {Event} event
|
||||||
* The event that triggered dismissal.
|
* The event that triggered dismissal.
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class ProviderCalculator extends UrlbarProvider {
|
|||||||
return viewUpdate;
|
return viewUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details) {
|
onLegacyEngagement(state, queryContext, details) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName == this.name) {
|
if (result?.providerName == this.name) {
|
||||||
lazy.ClipboardHelper.copyString(result.payload.value);
|
lazy.ClipboardHelper.copyString(result.payload.value);
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class ProviderClipboard extends UrlbarProvider {
|
|||||||
addCallback(this, result);
|
addCallback(this, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
const visibleResults = controller.view?.visibleResults ?? [];
|
const visibleResults = controller.view?.visibleResults ?? [];
|
||||||
for (const result of visibleResults) {
|
for (const result of visibleResults) {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class ProviderContextualSearch extends UrlbarProvider {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName == this.name) {
|
if (result?.providerName == this.name) {
|
||||||
this.#pickResult(result, controller.browserWindow);
|
this.#pickResult(result, controller.browserWindow);
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class ProviderInputHistory extends UrlbarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name) {
|
if (result?.providerName != this.name) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -703,7 +703,7 @@ class ProviderInterventions extends UrlbarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
|
|
||||||
// `selType` is "tip" when the tip's main button is picked. Ignore clicks on
|
// `selType` is "tip" when the tip's main button is picked. Ignore clicks on
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ class ProviderOmnibox extends UrlbarProvider {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name) {
|
if (result?.providerName != this.name) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1517,7 +1517,7 @@ class ProviderPlaces extends UrlbarProvider {
|
|||||||
search.notifyResult(false);
|
search.notifyResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name) {
|
if (result?.providerName != this.name) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ class ProviderQuickActions extends UrlbarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
// Ignore engagements on other results that didn't end the session.
|
// Ignore engagements on other results that didn't end the session.
|
||||||
if (details.result?.providerName != this.name && details.isSessionOngoing) {
|
if (details.result?.providerName != this.name && details.isSessionOngoing) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class ProviderQuickSuggest extends UrlbarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
// Ignore engagements on other results that didn't end the session.
|
// Ignore engagements on other results that didn't end the session.
|
||||||
if (details.result?.providerName != this.name && details.isSessionOngoing) {
|
if (details.result?.providerName != this.name && details.isSessionOngoing) {
|
||||||
return;
|
return;
|
||||||
@@ -486,8 +486,8 @@ class ProviderQuickSuggest extends UrlbarProvider {
|
|||||||
* end of the engagement or that was dismissed. Null if no quick suggest
|
* end of the engagement or that was dismissed. Null if no quick suggest
|
||||||
* result was present.
|
* result was present.
|
||||||
* @param {object} details
|
* @param {object} details
|
||||||
* The `details` object that was passed to `onEngagement()`. It must look
|
* The `details` object that was passed to `onLegacyEngagement()`. It must
|
||||||
* like this: `{ selType, selIndex }`
|
* look like this: `{ selType, selIndex }`
|
||||||
*/
|
*/
|
||||||
#recordEngagement(queryContext, result, details) {
|
#recordEngagement(queryContext, result, details) {
|
||||||
let resultSelType = "";
|
let resultSelType = "";
|
||||||
@@ -781,8 +781,8 @@ class ProviderQuickSuggest extends UrlbarProvider {
|
|||||||
* True if the main part of the result's row was clicked; false if a button
|
* True if the main part of the result's row was clicked; false if a button
|
||||||
* like help or dismiss was clicked or if no part of the row was clicked.
|
* like help or dismiss was clicked or if no part of the row was clicked.
|
||||||
* @param {object} options.details
|
* @param {object} options.details
|
||||||
* The `details` object that was passed to `onEngagement()`. It must look
|
* The `details` object that was passed to `onLegacyEngagement()`. It must
|
||||||
* like this: `{ selType, selIndex }`
|
* look like this: `{ selType, selIndex }`
|
||||||
*/
|
*/
|
||||||
#recordNavSuggestionTelemetry({
|
#recordNavSuggestionTelemetry({
|
||||||
queryContext,
|
queryContext,
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class ProviderQuickSuggestContextualOptIn extends UrlbarProvider {
|
|||||||
row.ownerGlobal.A11yUtils.announce({ raw: alertText });
|
row.ownerGlobal.A11yUtils.announce({ raw: alertText });
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name) {
|
if (result?.providerName != this.name) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ProviderRecentSearches extends UrlbarProvider {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name) {
|
if (result?.providerName != this.name) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ class ProviderSearchSuggestions extends UrlbarProvider {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name) {
|
if (result?.providerName != this.name) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ class ProviderSearchTips extends UrlbarProvider {
|
|||||||
lazy.UrlbarPrefs.set(`tipShownCount.${tip}`, MAX_SHOWN_COUNT);
|
lazy.UrlbarPrefs.set(`tipShownCount.${tip}`, MAX_SHOWN_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
// Ignore engagements on other results that didn't end the session.
|
// Ignore engagements on other results that didn't end the session.
|
||||||
let { result } = details;
|
let { result } = details;
|
||||||
if (result?.providerName != this.name && details.isSessionOngoing) {
|
if (result?.providerName != this.name && details.isSessionOngoing) {
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class ProviderTabToSearch extends UrlbarProvider {
|
|||||||
* Called when a result from the provider is selected. "Selected" refers to
|
* Called when a result from the provider is selected. "Selected" refers to
|
||||||
* the user highlighing the result with the arrow keys/Tab, before it is
|
* the user highlighing the result with the arrow keys/Tab, before it is
|
||||||
* picked. onSelection is also called when a user clicks a result. In the
|
* picked. onSelection is also called when a user clicks a result. In the
|
||||||
* event of a click, onSelection is called just before onEngagement.
|
* event of a click, onSelection is called just before onLegacyEngagement.
|
||||||
*
|
*
|
||||||
* @param {UrlbarResult} result
|
* @param {UrlbarResult} result
|
||||||
* The result that was selected.
|
* The result that was selected.
|
||||||
@@ -226,7 +226,7 @@ class ProviderTabToSearch extends UrlbarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details) {
|
onLegacyEngagement(state, queryContext, details) {
|
||||||
let { result, element } = details;
|
let { result, element } = details;
|
||||||
if (
|
if (
|
||||||
result?.providerName == this.name &&
|
result?.providerName == this.name &&
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class ProviderTopSites extends UrlbarProvider {
|
|||||||
return site;
|
return site;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Store Sponsored Top Sites so we can use it in `onEngagement`
|
// Store Sponsored Top Sites so we can use it in `onLegacyEngagement`
|
||||||
if (sponsoredSites.length) {
|
if (sponsoredSites.length) {
|
||||||
this.sponsoredSites = sponsoredSites;
|
this.sponsoredSites = sponsoredSites;
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ class ProviderTopSites extends UrlbarProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext) {
|
onLegacyEngagement(state, queryContext) {
|
||||||
if (!queryContext.isPrivate && this.sponsoredSites) {
|
if (!queryContext.isPrivate && this.sponsoredSites) {
|
||||||
for (let site of this.sponsoredSites) {
|
for (let site of this.sponsoredSites) {
|
||||||
Services.telemetry.keyedScalarAdd(
|
Services.telemetry.keyedScalarAdd(
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class ProviderUnitConversion extends UrlbarProvider {
|
|||||||
addCallback(this, result);
|
addCallback(this, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details) {
|
onLegacyEngagement(state, queryContext, details) {
|
||||||
let { result, element } = details;
|
let { result, element } = details;
|
||||||
if (result?.providerName == this.name) {
|
if (result?.providerName == this.name) {
|
||||||
const { textContent } = element.querySelector(
|
const { textContent } = element.querySelector(
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class ProviderWeather extends UrlbarProvider {
|
|||||||
return lazy.QuickSuggest.weather.getViewUpdate(result);
|
return lazy.QuickSuggest.weather.getViewUpdate(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
// Ignore engagements on other results that didn't end the session.
|
// Ignore engagements on other results that didn't end the session.
|
||||||
if (details.result?.providerName != this.name && details.isSessionOngoing) {
|
if (details.result?.providerName != this.name && details.isSessionOngoing) {
|
||||||
return;
|
return;
|
||||||
@@ -243,7 +243,7 @@ class ProviderWeather extends UrlbarProvider {
|
|||||||
* A non-empty string means the user picked the weather row or some part of
|
* A non-empty string means the user picked the weather row or some part of
|
||||||
* it, and both impression and click telemetry will be recorded. The
|
* it, and both impression and click telemetry will be recorded. The
|
||||||
* non-empty-string values come from the `details.selType` passed in to
|
* non-empty-string values come from the `details.selType` passed in to
|
||||||
* `onEngagement()`; see `TelemetryEvent.typeFromElement()`.
|
* `onLegacyEngagement()`; see `TelemetryEvent.typeFromElement()`.
|
||||||
*/
|
*/
|
||||||
#recordEngagementTelemetry(result, isPrivate, selType) {
|
#recordEngagementTelemetry(result, isPrivate, selType) {
|
||||||
// Indexes recorded in quick suggest telemetry are 1-based, so add 1 to the
|
// Indexes recorded in quick suggest telemetry are 1-based, so add 1 to the
|
||||||
|
|||||||
@@ -334,7 +334,8 @@ class ProvidersManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies all providers when the user starts and ends an engagement with the
|
* Notifies all providers when the user starts and ends an engagement with the
|
||||||
* urlbar. For details on parameters, see UrlbarProvider.onEngagement().
|
* urlbar. For details on parameters, see
|
||||||
|
* UrlbarProvider.onLegacyEngagement().
|
||||||
*
|
*
|
||||||
* @param {string} state
|
* @param {string} state
|
||||||
* The state of the engagement, one of: engagement, abandonment
|
* The state of the engagement, one of: engagement, abandonment
|
||||||
@@ -348,7 +349,7 @@ class ProvidersManager {
|
|||||||
notifyEngagementChange(state, queryContext, details = {}, controller) {
|
notifyEngagementChange(state, queryContext, details = {}, controller) {
|
||||||
for (let provider of this.providers) {
|
for (let provider of this.providers) {
|
||||||
provider.tryMethod(
|
provider.tryMethod(
|
||||||
"onEngagement",
|
"onLegacyEngagement",
|
||||||
state,
|
state,
|
||||||
queryContext,
|
queryContext,
|
||||||
details,
|
details,
|
||||||
|
|||||||
@@ -2475,7 +2475,7 @@ export class UrlbarProvider {
|
|||||||
* @param {UrlbarController} _controller
|
* @param {UrlbarController} _controller
|
||||||
* The associated controller.
|
* The associated controller.
|
||||||
*/
|
*/
|
||||||
onEngagement(_state, _queryContext, _details, _controller) {}
|
onLegacyEngagement(_state, _queryContext, _details, _controller) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before a result from the provider is selected. See `onSelection`
|
* Called before a result from the provider is selected. See `onSelection`
|
||||||
@@ -2493,8 +2493,8 @@ export class UrlbarProvider {
|
|||||||
* Called when a result from the provider is selected. "Selected" refers to
|
* Called when a result from the provider is selected. "Selected" refers to
|
||||||
* the user highlighing the result with the arrow keys/Tab, before it is
|
* the user highlighing the result with the arrow keys/Tab, before it is
|
||||||
* picked. onSelection is also called when a user clicks a result. In the
|
* picked. onSelection is also called when a user clicks a result. In the
|
||||||
* event of a click, onSelection is called just before onEngagement. Note that
|
* event of a click, onSelection is called just before onLegacyEngagement.
|
||||||
* this is called when heuristic results are pre-selected.
|
* Note that this is called when heuristic results are pre-selected.
|
||||||
*
|
*
|
||||||
* @param {UrlbarResult} _result
|
* @param {UrlbarResult} _result
|
||||||
* The result that was selected.
|
* The result that was selected.
|
||||||
@@ -2577,8 +2577,8 @@ export class UrlbarProvider {
|
|||||||
/**
|
/**
|
||||||
* Gets the list of commands that should be shown in the result menu for a
|
* Gets the list of commands that should be shown in the result menu for a
|
||||||
* given result from the provider. All commands returned by this method should
|
* given result from the provider. All commands returned by this method should
|
||||||
* be handled by implementing `onEngagement()` with the possible exception of
|
* be handled by implementing `onLegacyEngagement()` with the possible
|
||||||
* commands automatically handled by the urlbar, like "help".
|
* exception of commands automatically handled by the urlbar, like "help".
|
||||||
*
|
*
|
||||||
* @param {UrlbarResult} _result
|
* @param {UrlbarResult} _result
|
||||||
* The menu will be shown for this result.
|
* The menu will be shown for this result.
|
||||||
@@ -2590,8 +2590,8 @@ export class UrlbarProvider {
|
|||||||
* {string} name
|
* {string} name
|
||||||
* The name of the command. Must be specified unless `children` is
|
* The name of the command. Must be specified unless `children` is
|
||||||
* present. When a command is picked, its name will be passed as
|
* present. When a command is picked, its name will be passed as
|
||||||
* `details.selType` to `onEngagement()`. The special name "separator"
|
* `details.selType` to `onLegacyEngagement()`. The special name
|
||||||
* will create a menu separator.
|
* "separator" will create a menu separator.
|
||||||
* {object} l10n
|
* {object} l10n
|
||||||
* An l10n object for the command's label: `{ id, args }`
|
* An l10n object for the command's label: `{ id, args }`
|
||||||
* Must be specified unless `name` is "separator".
|
* Must be specified unless `name` is "separator".
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ aren't relevant to dynamic result types, and you should choose values
|
|||||||
appropriate to your use case.
|
appropriate to your use case.
|
||||||
|
|
||||||
If any elements created in the view for your results can be picked with the
|
If any elements created in the view for your results can be picked with the
|
||||||
keyboard or mouse, then be sure to implement your provider's ``onEngagement``
|
keyboard or mouse, then be sure to implement your provider's
|
||||||
method.
|
``onLegacyEngagement`` method.
|
||||||
|
|
||||||
For help on implementing providers in general, see the address bar's
|
For help on implementing providers in general, see the address bar's
|
||||||
`Architecture Overview`__.
|
`Architecture Overview`__.
|
||||||
@@ -616,7 +616,7 @@ URL Navigation
|
|||||||
|
|
||||||
If a result's payload includes a string ``url`` property and a boolean
|
If a result's payload includes a string ``url`` property and a boolean
|
||||||
``shouldNavigate: true`` property, then picking the result will navigate to the
|
``shouldNavigate: true`` property, then picking the result will navigate to the
|
||||||
URL. The ``onEngagement`` method of the result's provider will still be called
|
URL. The ``onLegacyEngagement`` method of the result's provider will still be called
|
||||||
before navigation.
|
before navigation.
|
||||||
|
|
||||||
Text Highlighting
|
Text Highlighting
|
||||||
|
|||||||
@@ -1487,7 +1487,7 @@ class TestProvider extends UrlbarProvider {
|
|||||||
* @param {Function} [options.onSelection]
|
* @param {Function} [options.onSelection]
|
||||||
* If given, a function that will be called when
|
* If given, a function that will be called when
|
||||||
* {@link UrlbarView.#selectElement} method is called.
|
* {@link UrlbarView.#selectElement} method is called.
|
||||||
* @param {Function} [options.onEngagement]
|
* @param {Function} [options.onLegacyEngagement]
|
||||||
* If given, a function that will be called when engagement.
|
* If given, a function that will be called when engagement.
|
||||||
* @param {Function} [options.delayResultsPromise]
|
* @param {Function} [options.delayResultsPromise]
|
||||||
* If given, we'll await on this before returning results.
|
* If given, we'll await on this before returning results.
|
||||||
@@ -1500,7 +1500,7 @@ class TestProvider extends UrlbarProvider {
|
|||||||
addTimeout = 0,
|
addTimeout = 0,
|
||||||
onCancel = null,
|
onCancel = null,
|
||||||
onSelection = null,
|
onSelection = null,
|
||||||
onEngagement = null,
|
onLegacyEngagement = null,
|
||||||
delayResultsPromise = null,
|
delayResultsPromise = null,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (delayResultsPromise && addTimeout) {
|
if (delayResultsPromise && addTimeout) {
|
||||||
@@ -1517,7 +1517,7 @@ class TestProvider extends UrlbarProvider {
|
|||||||
this._type = type;
|
this._type = type;
|
||||||
this._onCancel = onCancel;
|
this._onCancel = onCancel;
|
||||||
this._onSelection = onSelection;
|
this._onSelection = onSelection;
|
||||||
this._onEngagement = onEngagement;
|
this._onLegacyEngagement = onLegacyEngagement;
|
||||||
|
|
||||||
// As this has been a common source of mistakes, auto-upgrade the provider
|
// As this has been a common source of mistakes, auto-upgrade the provider
|
||||||
// type to heuristic if any result is heuristic.
|
// type to heuristic if any result is heuristic.
|
||||||
@@ -1571,8 +1571,8 @@ class TestProvider extends UrlbarProvider {
|
|||||||
this._onSelection?.(result, element);
|
this._onSelection?.(result, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
this._onEngagement?.(state, queryContext, details, controller);
|
this._onLegacyEngagement?.(state, queryContext, details, controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ async function doTest({ click, buttonUrl = undefined, helpUrl = undefined }) {
|
|||||||
});
|
});
|
||||||
UrlbarProvidersManager.registerProvider(provider);
|
UrlbarProvidersManager.registerProvider(provider);
|
||||||
|
|
||||||
let onEngagementPromise = new Promise(
|
let onLegacyEngagementPromise = new Promise(
|
||||||
resolve => (provider.onEngagement = resolve)
|
resolve => (provider.onLegacyEngagement = resolve)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Do a search to show our tip result.
|
// Do a search to show our tip result.
|
||||||
@@ -142,8 +142,8 @@ async function doTest({ click, buttonUrl = undefined, helpUrl = undefined }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now pick the target and wait for provider.onEngagement to be called and
|
// Now pick the target and wait for provider.onLegacyEngagement to be called
|
||||||
// the URL to load if necessary.
|
// and the URL to load if necessary.
|
||||||
let loadPromise;
|
let loadPromise;
|
||||||
if (buttonUrl || helpUrl) {
|
if (buttonUrl || helpUrl) {
|
||||||
loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||||
@@ -160,7 +160,7 @@ async function doTest({ click, buttonUrl = undefined, helpUrl = undefined }) {
|
|||||||
EventUtils.synthesizeKey("KEY_Enter");
|
EventUtils.synthesizeKey("KEY_Enter");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await onEngagementPromise;
|
await onLegacyEngagementPromise;
|
||||||
await loadPromise;
|
await loadPromise;
|
||||||
|
|
||||||
// Check telemetry.
|
// Check telemetry.
|
||||||
|
|||||||
@@ -389,11 +389,11 @@ class TestProvider extends UrlbarTestUtils.TestProvider {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, controller) {
|
onLegacyEngagement(state, queryContext, details, controller) {
|
||||||
if (details.result?.providerName == this.name) {
|
if (details.result?.providerName == this.name) {
|
||||||
let { selType } = details;
|
let { selType } = details;
|
||||||
|
|
||||||
info(`onEngagement called, selType=` + selType);
|
info(`onLegacyEngagement called, selType=` + selType);
|
||||||
|
|
||||||
if (!this.commandCount.hasOwnProperty(selType)) {
|
if (!this.commandCount.hasOwnProperty(selType)) {
|
||||||
this.commandCount[selType] = 0;
|
this.commandCount[selType] = 0;
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ add_task(async function shouldNavigate() {
|
|||||||
await UrlbarTestUtils.promisePopupClose(window, () =>
|
await UrlbarTestUtils.promisePopupClose(window, () =>
|
||||||
EventUtils.synthesizeKey("KEY_Enter")
|
EventUtils.synthesizeKey("KEY_Enter")
|
||||||
);
|
);
|
||||||
// Verify that onEngagement was still called.
|
// Verify that onLegacyEngagement was still called.
|
||||||
let [result, pickedElement] = await pickPromise;
|
let [result, pickedElement] = await pickPromise;
|
||||||
Assert.equal(result, row.result, "Picked result");
|
Assert.equal(result, row.result, "Picked result");
|
||||||
Assert.equal(pickedElement, element, "Picked element");
|
Assert.equal(pickedElement, element, "Picked element");
|
||||||
@@ -904,7 +904,7 @@ class TestProvider extends UrlbarTestUtils.TestProvider {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(state, queryContext, details, _controller) {
|
onLegacyEngagement(state, queryContext, details, _controller) {
|
||||||
if (this._pickPromiseResolve) {
|
if (this._pickPromiseResolve) {
|
||||||
let { result, element } = details;
|
let { result, element } = details;
|
||||||
this._pickPromiseResolve([result, element]);
|
this._pickPromiseResolve([result, element]);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
// Tests the UrlbarProvider.onEngagement() method.
|
// Tests the UrlbarProvider.onLegacyEngagement() method.
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ async function doTest({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test provider that resolves promises when onEngagement is called.
|
* Test provider that resolves promises when onLegacyEngagement is called.
|
||||||
*/
|
*/
|
||||||
class TestProvider extends UrlbarTestUtils.TestProvider {
|
class TestProvider extends UrlbarTestUtils.TestProvider {
|
||||||
_resolves = [];
|
_resolves = [];
|
||||||
@@ -186,7 +186,7 @@ class TestProvider extends UrlbarTestUtils.TestProvider {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onEngagement(...args) {
|
onLegacyEngagement(...args) {
|
||||||
let resolve = this._resolves.shift();
|
let resolve = this._resolves.shift();
|
||||||
if (resolve) {
|
if (resolve) {
|
||||||
resolve(args);
|
resolve(args);
|
||||||
|
|||||||
@@ -201,10 +201,10 @@ add_task(async function firefoxSuggest() {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Implement the provider's `onEngagement()` so it removes the result.
|
// Implement the provider's `onLegacyEngagement()` so it removes the result.
|
||||||
let onEngagementCallCount = 0;
|
let onLegacyEngagementCallCount = 0;
|
||||||
provider.onEngagement = (state, queryContext, details, controller) => {
|
provider.onLegacyEngagement = (state, queryContext, details, controller) => {
|
||||||
onEngagementCallCount++;
|
onLegacyEngagementCallCount++;
|
||||||
controller.removeResult(details.result);
|
controller.removeResult(details.result);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -245,9 +245,9 @@ add_task(async function firefoxSuggest() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Assert.greater(
|
Assert.greater(
|
||||||
onEngagementCallCount,
|
onLegacyEngagementCallCount,
|
||||||
0,
|
0,
|
||||||
"onEngagement() should have been called"
|
"onLegacyEngagement() should have been called"
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
UrlbarTestUtils.getResultCount(window),
|
UrlbarTestUtils.getResultCount(window),
|
||||||
|
|||||||
@@ -344,8 +344,8 @@ async function impressions_test(isOnboarding) {
|
|||||||
5
|
5
|
||||||
);
|
);
|
||||||
|
|
||||||
// See javadoc for UrlbarProviderTabToSearch.onEngagement for discussion
|
// See javadoc for UrlbarProviderTabToSearch.onLegacyEngagement for
|
||||||
// about retained results.
|
// discussion about retained results.
|
||||||
info("Reopen the result set with retained results. Record impression.");
|
info("Reopen the result set with retained results. Record impression.");
|
||||||
await UrlbarTestUtils.promisePopupOpen(window, () => {
|
await UrlbarTestUtils.promisePopupOpen(window, () => {
|
||||||
EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {});
|
EventUtils.synthesizeMouseAtCenter(gURLBar.inputField, {});
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ add_task(async function selected_result_tip() {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
priority: 1,
|
priority: 1,
|
||||||
onEngagement: () => {
|
onLegacyEngagement: () => {
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ add_setup(async function () {
|
|||||||
await initExposureTest();
|
await initExposureTest();
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function exposureSponsoredOnEngagement() {
|
add_task(async function exposureSponsoredOnLegacyEngagement() {
|
||||||
await doExposureTest({
|
await doExposureTest({
|
||||||
prefs: [
|
prefs: [
|
||||||
["browser.urlbar.exposureResults", suggestResultType("adm_sponsored")],
|
["browser.urlbar.exposureResults", suggestResultType("adm_sponsored")],
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ add_task(async function () {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
priority: 999,
|
priority: 999,
|
||||||
onEngagement: () => {
|
onLegacyEngagement: () => {
|
||||||
info("Blur the address bar during the onEngagement notification");
|
info("Blur the address bar during the onLegacyEngagement notification");
|
||||||
gURLBar.blur();
|
gURLBar.blur();
|
||||||
// Run at the next tick to be sure spurious events would have happened.
|
// Run at the next tick to be sure spurious events would have happened.
|
||||||
TestUtils.waitForTick().then(() => {
|
TestUtils.waitForTick().then(() => {
|
||||||
@@ -37,7 +37,7 @@ add_task(async function () {
|
|||||||
});
|
});
|
||||||
UrlbarProvidersManager.registerProvider(provider);
|
UrlbarProvidersManager.registerProvider(provider);
|
||||||
// This should cover at least engagement and abandonment.
|
// This should cover at least engagement and abandonment.
|
||||||
let engagementSpy = sinon.spy(provider, "onEngagement");
|
let engagementSpy = sinon.spy(provider, "onLegacyEngagement");
|
||||||
|
|
||||||
let beforeRecordCall = false,
|
let beforeRecordCall = false,
|
||||||
recordReentered = false;
|
recordReentered = false;
|
||||||
@@ -68,7 +68,7 @@ add_task(async function () {
|
|||||||
Assert.equal(
|
Assert.equal(
|
||||||
engagementSpy.callCount,
|
engagementSpy.callCount,
|
||||||
1,
|
1,
|
||||||
"`onEngagement` was invoked twice"
|
"`onLegacyEngagement` was invoked twice"
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
engagementSpy.args[0][0],
|
engagementSpy.args[0][0],
|
||||||
|
|||||||
@@ -374,8 +374,11 @@ async function doEngagementWithoutAddingResultToView(
|
|||||||
let getPriorityStub = sandbox.stub(UrlbarProviderQuickSuggest, "getPriority");
|
let getPriorityStub = sandbox.stub(UrlbarProviderQuickSuggest, "getPriority");
|
||||||
getPriorityStub.returns(Infinity);
|
getPriorityStub.returns(Infinity);
|
||||||
|
|
||||||
// Spy on `UrlbarProviderQuickSuggest.onEngagement()`.
|
// Spy on `UrlbarProviderQuickSuggest.onLegacyEngagement()`.
|
||||||
let onEngagementSpy = sandbox.spy(UrlbarProviderQuickSuggest, "onEngagement");
|
let onLegacyEngagementSpy = sandbox.spy(
|
||||||
|
UrlbarProviderQuickSuggest,
|
||||||
|
"onLegacyEngagement"
|
||||||
|
);
|
||||||
|
|
||||||
let sandboxCleanup = () => {
|
let sandboxCleanup = () => {
|
||||||
getPriorityStub?.restore();
|
getPriorityStub?.restore();
|
||||||
@@ -452,7 +455,7 @@ async function doEngagementWithoutAddingResultToView(
|
|||||||
});
|
});
|
||||||
await loadPromise;
|
await loadPromise;
|
||||||
|
|
||||||
let engagementCalls = onEngagementSpy.getCalls().filter(call => {
|
let engagementCalls = onLegacyEngagementSpy.getCalls().filter(call => {
|
||||||
let state = call.args[0];
|
let state = call.args[0];
|
||||||
return state == "engagement";
|
return state == "engagement";
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3884,7 +3884,7 @@ async function checkSearch({ name, searchString, expectedResults }) {
|
|||||||
removeResult() {},
|
removeResult() {},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
UrlbarProviderQuickSuggest.onEngagement(
|
UrlbarProviderQuickSuggest.onLegacyEngagement(
|
||||||
"engagement",
|
"engagement",
|
||||||
context,
|
context,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ add_task(async function canceledQueries() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function endEngagement({ controller, context = null, state = "engagement" }) {
|
function endEngagement({ controller, context = null, state = "engagement" }) {
|
||||||
UrlbarProviderQuickSuggest.onEngagement(
|
UrlbarProviderQuickSuggest.onLegacyEngagement(
|
||||||
state,
|
state,
|
||||||
context ||
|
context ||
|
||||||
createContext("endEngagement", {
|
createContext("endEngagement", {
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ add_tasks_with_rust(async function block() {
|
|||||||
let result = context.results[0];
|
let result = context.results[0];
|
||||||
let provider = UrlbarProvidersManager.getProvider(result.providerName);
|
let provider = UrlbarProvidersManager.getProvider(result.providerName);
|
||||||
Assert.ok(provider, "Sanity check: Result provider found");
|
Assert.ok(provider, "Sanity check: Result provider found");
|
||||||
provider.onEngagement(
|
provider.onLegacyEngagement(
|
||||||
"engagement",
|
"engagement",
|
||||||
context,
|
context,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user