mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1822210: Check wheather the view is opening when recording r=mak
Differential Revision: https://phabricator.services.mozilla.com/D172098
This commit is contained in:
parent
06a7820749
commit
af6aa328d5
@ -1094,31 +1094,29 @@ class TelemetryEvent {
|
||||
);
|
||||
const search_mode = this.#getSearchMode(searchMode);
|
||||
const currentResults = queryContext?.view?.visibleResults ?? [];
|
||||
const numResults = currentResults.length;
|
||||
const groups = currentResults
|
||||
let numResults = currentResults.length;
|
||||
let groups = currentResults
|
||||
.map(r => lazy.UrlbarUtils.searchEngagementTelemetryGroup(r))
|
||||
.join(",");
|
||||
const results = currentResults
|
||||
let results = currentResults
|
||||
.map(r => lazy.UrlbarUtils.searchEngagementTelemetryType(r))
|
||||
.join(",");
|
||||
|
||||
let eventInfo;
|
||||
if (method === "engagement") {
|
||||
let selected_result;
|
||||
let selected_result_subtype;
|
||||
if (numResults) {
|
||||
const selectedResult = currentResults[selIndex];
|
||||
selected_result = lazy.UrlbarUtils.searchEngagementTelemetryType(
|
||||
selectedResult,
|
||||
selType
|
||||
);
|
||||
selected_result_subtype = lazy.UrlbarUtils.searchEngagementTelemetrySubtype(
|
||||
selectedResult,
|
||||
selectedElement
|
||||
);
|
||||
} else {
|
||||
selected_result = "input_field";
|
||||
selected_result_subtype = "";
|
||||
const selected_result = lazy.UrlbarUtils.searchEngagementTelemetryType(
|
||||
currentResults[selIndex],
|
||||
selType
|
||||
);
|
||||
const selected_result_subtype = lazy.UrlbarUtils.searchEngagementTelemetrySubtype(
|
||||
currentResults[selIndex],
|
||||
selectedElement
|
||||
);
|
||||
|
||||
if (selected_result === "input_field" && !queryContext?.view?.isOpen) {
|
||||
numResults = 0;
|
||||
groups = "";
|
||||
results = "";
|
||||
}
|
||||
|
||||
eventInfo = {
|
||||
|
@ -1318,7 +1318,7 @@ export var UrlbarUtils = {
|
||||
*/
|
||||
searchEngagementTelemetryType(result, selType = null) {
|
||||
if (!result) {
|
||||
return selType === "oneoff" ? "search_shortcut_button" : "unknown";
|
||||
return selType === "oneoff" ? "search_shortcut_button" : "input_field";
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -97,11 +97,12 @@ add_task(async function engagement_before_showing_results() {
|
||||
// Add a provider that add a result immediately as usual.
|
||||
UrlbarProvidersManager.registerProvider(anotherHeuristicProvider);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
const cleanup = () => {
|
||||
UrlbarProvidersManager.unregisterProvider(noResponseProvider);
|
||||
UrlbarProvidersManager.unregisterProvider(anotherHeuristicProvider);
|
||||
UrlbarProvidersManager._chunkResultsDelayMs = originalChuldResultDelayMs;
|
||||
});
|
||||
};
|
||||
registerCleanupFunction(cleanup);
|
||||
|
||||
await doTest(async browser => {
|
||||
// Try to show the results.
|
||||
@ -137,5 +138,46 @@ add_task(async function engagement_before_showing_results() {
|
||||
noResponseProvider.done();
|
||||
});
|
||||
|
||||
cleanup();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
add_task(async function engagement_after_closing_results() {
|
||||
const TRIGGERS = [
|
||||
() => EventUtils.synthesizeKey("KEY_Escape"),
|
||||
() =>
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
document.getElementById("customizableui-special-spring2"),
|
||||
{}
|
||||
),
|
||||
];
|
||||
|
||||
for (const trigger of TRIGGERS) {
|
||||
await doTest(async browser => {
|
||||
await openPopup("test");
|
||||
await UrlbarTestUtils.promisePopupClose(window, () => {
|
||||
trigger();
|
||||
});
|
||||
Assert.equal(
|
||||
gURLBar.value,
|
||||
"test",
|
||||
"The inputted text remains even if closing the results"
|
||||
);
|
||||
// The tested trigger should not record abandonment event.
|
||||
assertAbandonmentTelemetry([]);
|
||||
|
||||
// Endgagement.
|
||||
await doEnter();
|
||||
|
||||
assertEngagementTelemetry([
|
||||
{
|
||||
selected_result: "input_field",
|
||||
selected_result_subtype: "",
|
||||
provider: undefined,
|
||||
results: "",
|
||||
groups: "",
|
||||
},
|
||||
]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user