Bug 1496743 - Stop logging telemetry when pressing enter on the one-off search settings button in the urlbar. r=adw

Also add tests for the search settings button in the urlbar.

Differential Revision: https://phabricator.services.mozilla.com/D8146

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2018-10-10 07:21:23 +00:00
Родитель aace4e2e6a
Коммит 5a64fcf173
3 изменённых файлов: 85 добавлений и 3 удалений

Просмотреть файл

@ -96,6 +96,10 @@ support-files =
searchSuggestionEngine.xml
searchSuggestionEngine.sjs
[browser_urlbarOneOffs_searchSuggestions.js]
support-files =
searchSuggestionEngine.xml
searchSuggestionEngine.sjs
[browser_urlbarOneOffs_settings.js]
support-files =
searchSuggestionEngine.xml
searchSuggestionEngine.sjs

Просмотреть файл

@ -0,0 +1,78 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
let gMaxResults;
add_task(async function init() {
Services.prefs.setBoolPref("browser.urlbar.oneOffSearches", true);
gMaxResults = Services.prefs.getIntPref("browser.urlbar.maxRichResults");
// Add a search suggestion engine and move it to the front so that it appears
// as the first one-off.
let engine = await SearchTestUtils.promiseNewSearchEngine(
getRootDirectory(gTestPath) + TEST_ENGINE_BASENAME);
Services.search.moveEngine(engine, 0);
registerCleanupFunction(async function() {
await hidePopup();
await PlacesUtils.history.clear();
});
await PlacesUtils.history.clear();
let visits = [];
for (let i = 0; i < gMaxResults; i++) {
visits.push({
uri: makeURI("http://example.com/browser_urlbarOneOffs.js/?" + i),
// TYPED so that the visit shows up when the urlbar's drop-down arrow is
// pressed.
transition: Ci.nsINavHistoryService.TRANSITION_TYPED,
});
}
await PlacesTestUtils.addVisits(visits);
});
async function selectSettings(activateFn) {
await BrowserTestUtils.withNewTab({gBrowser, url: "about:blank"}, async browser => {
gURLBar.focus();
EventUtils.synthesizeKey("KEY_ArrowDown");
await promisePopupShown(gURLBar.popup);
await waitForAutocompleteResultAt(gMaxResults - 1);
let promiseHidden = promisePopupHidden(gURLBar.popup);
let prefPaneLoaded = TestUtils.topicObserved("sync-pane-loaded", () => true);
activateFn();
await prefPaneLoaded;
await promiseHidden;
Assert.equal(gBrowser.contentWindow.history.state, "paneSearch",
"Should have opened the search preferences pane");
});
}
add_task(async function test_open_settings_with_enter() {
await selectSettings(() => {
EventUtils.synthesizeKey("KEY_ArrowUp");
Assert.equal(gURLBar.popup.oneOffSearchButtons.selectedButton.getAttribute("anonid"),
"search-settings-compact", "Should have selected the settings button");
EventUtils.synthesizeKey("KEY_Enter");
});
});
add_task(async function test_open_settings_with_click() {
await selectSettings(() => {
gURLBar.popup.oneOffSearchButtons.settingsButton.click();
});
});
async function hidePopup() {
EventUtils.synthesizeKey("KEY_Escape");
await promisePopupHidden(gURLBar.popup);
}

Просмотреть файл

@ -652,9 +652,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
return;
}
BrowserUsageTelemetry.recordUrlbarSelectedResultMethod(
event, this.userSelectionBehavior);
// Determine whether to use the selected one-off search button. In
// one-off search buttons parlance, "selected" means that the button
// has been navigated to via the keyboard. So we want to use it if
@ -673,6 +670,9 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
return;
}
BrowserUsageTelemetry.recordUrlbarSelectedResultMethod(
event, this.userSelectionBehavior);
let where = openUILinkWhere || this._whereToOpen(event);
let url = this.value;