Bug 1665049 - Remove browser.urlbar.update2.oneOffsRefresh. r=harry

Differential Revision: https://phabricator.services.mozilla.com/D99793
This commit is contained in:
Marco Bonardo 2020-12-18 09:58:17 +00:00
Родитель 26dfd39dc6
Коммит 63f7262ffb
44 изменённых файлов: 227 добавлений и 1597 удалений

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

@ -369,10 +369,6 @@ pref("browser.urlbar.shortcuts.bookmarks", true);
pref("browser.urlbar.shortcuts.tabs", true); pref("browser.urlbar.shortcuts.tabs", true);
pref("browser.urlbar.shortcuts.history", true); pref("browser.urlbar.shortcuts.history", true);
// Whether the urlbar one-offs act as search filters instead of executing a
// search immediately.
pref("browser.urlbar.update2.oneOffsRefresh", true);
pref("browser.urlbar.eventTelemetry.enabled", false); pref("browser.urlbar.eventTelemetry.enabled", false);
// Controls when to DNS resolve single word search strings, after they were // Controls when to DNS resolve single word search strings, after they were

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

@ -109,127 +109,6 @@ add_task(async function test_searchBarChangeEngine_privateWindow() {
await BrowserTestUtils.closeWindow(win); await BrowserTestUtils.closeWindow(win);
}); });
async function testUrlBarChangeEngine(win, testPrivate, isPrivateWindow) {
info(
`Testing urlbar with testPrivate: ${testPrivate} isPrivateWindow: ${isPrivateWindow}`
);
// This function and the subtests that call it can be removed with the update2
// pref.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
// Ensure the engine is reset.
await resetEngines();
const urlbar = win.document.getElementById("urlbar");
const urlBarOneOff = UrlbarTestUtils.getOneOffSearchButtons(win);
let oneOffButton = await openPopupAndGetEngineButton(
false,
null,
urlBarOneOff,
URLBAR_BASE_ID,
TEST_ENGINE_NAME
);
const setDefaultEngineMenuItem = urlBarOneOff.querySelector(
".search-one-offs-context-set-default" + (testPrivate ? "-private" : "")
);
// Click the set default engine menu item.
let promise = promiseDefaultEngineChanged(testPrivate);
EventUtils.synthesizeMouseAtCenter(setDefaultEngineMenuItem, {}, win);
// This also checks the engine correctly changed.
await promise;
let defaultEngine = await Services.search[
testPrivate ? "getDefaultPrivate" : "getDefault"
]();
// For the urlbar, we should keep the new engine's icon.
Assert.equal(
oneOffButton.id,
URLBAR_BASE_ID + defaultEngine.name,
"Should now have the original engine's id for the button"
);
Assert.equal(
oneOffButton.getAttribute("tooltiptext"),
defaultEngine.name,
"Should now have the original engine's name for the tooltip"
);
Assert.equal(
oneOffButton.image,
defaultEngine.iconURI.spec,
"Should now have the original engine's uri for the image"
);
await UrlbarTestUtils.promisePopupClose(win);
// Move the cursor out of the panel area to avoid messing with other tests.
await EventUtils.synthesizeNativeMouseMove(urlbar);
}
// This subtest can be removed with the update2 pref.
add_task(async function test_urlBarChangeEngine_normal_legacy() {
await testUrlBarChangeEngine(window, false, false);
await testUrlBarChangeEngine(window, true, false);
});
// This subtest can be removed with the update2 pref.
add_task(async function test_urlBarChangeEngine_private_legacy() {
const win = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
await testUrlBarChangeEngine(win, true, true);
await BrowserTestUtils.closeWindow(win);
});
async function testUrlbarEngineDefaultDisabled(isPrivate) {
const originalDefault = await Services.search[
isPrivate ? "getDefaultPrivate" : "getDefault"
]();
const urlBarOneOff = UrlbarTestUtils.getOneOffSearchButtons(window);
const oneOffButton = await openPopupAndGetEngineButton(
false,
null,
urlBarOneOff,
URLBAR_BASE_ID,
originalDefault.name
);
Assert.equal(
oneOffButton.id,
URLBAR_BASE_ID + originalDefault.name,
"Should now have the original engine's id for the button"
);
const setDefaultEngineMenuItem = urlBarOneOff.querySelector(
".search-one-offs-context-set-default" + (isPrivate ? "-private" : "")
);
Assert.equal(
setDefaultEngineMenuItem.disabled,
true,
"Should have disabled the setting as default for the default engine"
);
await UrlbarTestUtils.promisePopupClose(window);
}
add_task(async function test_urlBarEngineDefaultDisabled_normal() {
await testUrlbarEngineDefaultDisabled(false);
});
add_task(async function test_urlBarEngineDefaultDisabled_private() {
await testUrlbarEngineDefaultDisabled(true);
});
/** /**
* Promises that an engine change has happened for the current engine, which * Promises that an engine change has happened for the current engine, which
* has resulted in the test engine now being the current engine. * has resulted in the test engine now being the current engine.

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

@ -13,13 +13,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
UrlbarTestUtils.init(this); UrlbarTestUtils.init(this);
add_task(async function test() { add_task(async function test() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// Open the urlbar view and enter search mode. // Open the urlbar view and enter search mode.
await UrlbarTestUtils.promiseAutocompleteResultPopup({ await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, window,

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

@ -1539,22 +1539,18 @@ class UrlbarInput {
* instead. * instead.
*/ */
searchModeShortcut() { searchModeShortcut() {
if (this.view.oneOffsRefresh) { // We restrict to search results when entering search mode from this
// We restrict to search results when entering search mode from this // shortcut to honor historical behaviour.
// shortcut to honor historical behaviour. this.searchMode = {
this.searchMode = { source: UrlbarUtils.RESULT_SOURCE.SEARCH,
source: UrlbarUtils.RESULT_SOURCE.SEARCH, engineName: UrlbarSearchUtils.getDefaultEngine(this.isPrivate).name,
engineName: UrlbarSearchUtils.getDefaultEngine(this.isPrivate).name, entry: "shortcut",
entry: "shortcut", };
}; // The searchMode setter clears the input if pageproxystate is valid, so
// The searchMode setter clears the input if pageproxystate is valid, so // we know at this point this.value will either be blank or the user's
// we know at this point this.value will either be blank or the user's // typed string.
// typed string. this.search(this.value);
this.search(this.value); this.select();
this.select();
} else {
this.search(UrlbarTokenizer.RESTRICT.SEARCH);
}
} }
/** /**

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

@ -197,10 +197,6 @@ const PREF_URLBAR_DEFAULTS = new Map([
// 1 - Show search history // 1 - Show search history
// 2 - Show search and browsing history // 2 - Show search and browsing history
["update2.emptySearchBehavior", 0], ["update2.emptySearchBehavior", 0],
// Whether the urlbar one-offs act as search filters instead of executing a
// search immediately.
["update2.oneOffsRefresh", true],
]); ]);
const PREF_OTHER_DEFAULTS = new Map([ const PREF_OTHER_DEFAULTS = new Map([
["keyword.enabled", true], ["keyword.enabled", true],

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

@ -206,10 +206,9 @@ class UrlbarSearchOneOffs extends SearchOneOffs {
// Some key combinations should execute a search immediately. We handle // Some key combinations should execute a search immediately. We handle
// these here, outside the switch statement. // these here, outside the switch statement.
if ( if (
!this.view.oneOffsRefresh || userTypedSearchString &&
(userTypedSearchString && engine &&
engine && (event.shiftKey || where != "current")
(event.shiftKey || where != "current"))
) { ) {
this.input.handleNavigation({ this.input.handleNavigation({
event, event,
@ -310,11 +309,7 @@ class UrlbarSearchOneOffs extends SearchOneOffs {
// Invalidate the engine cache when the local-one-offs-related prefs change // Invalidate the engine cache when the local-one-offs-related prefs change
// so that the one-offs rebuild themselves the next time the view opens. // so that the one-offs rebuild themselves the next time the view opens.
if ( if (
[ [...UrlbarUtils.LOCAL_SEARCH_MODES.map(m => m.pref)].includes(changedPref)
"update2",
"update2.oneOffsRefresh",
...UrlbarUtils.LOCAL_SEARCH_MODES.map(m => m.pref),
].includes(changedPref)
) { ) {
this.invalidateCache(); this.invalidateCache();
} }
@ -329,10 +324,6 @@ class UrlbarSearchOneOffs extends SearchOneOffs {
_rebuildEngineList(engines) { _rebuildEngineList(engines) {
super._rebuildEngineList(engines); super._rebuildEngineList(engines);
if (!this.view.oneOffsRefresh) {
return;
}
for (let { source, pref, restrict } of UrlbarUtils.LOCAL_SEARCH_MODES) { for (let { source, pref, restrict } of UrlbarUtils.LOCAL_SEARCH_MODES) {
if (!UrlbarPrefs.get(pref)) { if (!UrlbarPrefs.get(pref)) {
continue; continue;
@ -357,11 +348,6 @@ class UrlbarSearchOneOffs extends SearchOneOffs {
* The click event. * The click event.
*/ */
_on_click(event) { _on_click(event) {
if (!this.view.oneOffsRefresh) {
super._on_click(event);
return;
}
// Ignore right clicks. // Ignore right clicks.
if (event.button == 2) { if (event.button == 2) {
return; return;
@ -387,12 +373,7 @@ class UrlbarSearchOneOffs extends SearchOneOffs {
* The contextmenu event. * The contextmenu event.
*/ */
_on_contextmenu(event) { _on_contextmenu(event) {
// Prevent the context menu from appearing when update2 is enabled. // Prevent the context menu from appearing.
if (this.view.oneOffsRefresh) { event.preventDefault();
event.preventDefault();
return;
}
super._on_contextmenu(event);
} }
} }

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

@ -98,18 +98,8 @@ class UrlbarView {
} }
/** /**
* Whether the panel is open.
* @returns {boolean} * @returns {boolean}
* Whether the update2 one-offs are used.
*/
get oneOffsRefresh() {
return (
UrlbarPrefs.get("update2") && UrlbarPrefs.get("update2.oneOffsRefresh")
);
}
/**
* @returns {boolean}
* Whether the panel is open.
*/ */
get isOpen() { get isOpen() {
return this.input.hasAttribute("open"); return this.input.hasAttribute("open");
@ -631,13 +621,12 @@ class UrlbarView {
}); });
// Show the one-off search buttons unless any of the following are true: // Show the one-off search buttons unless any of the following are true:
// // * The first result is a search tip
// * The update 2 refresh is enabled but the first result is a search tip // * The search string is empty
// * The update 2 refresh is disabled and the search string is empty // * The search string starts with an `@` or a search restriction
// * The search string starts with an `@` or search restriction character // character
this.oneOffSearchButtons.enable( this.oneOffSearchButtons.enable(
((this.oneOffsRefresh && (firstResult.providerName != "UrlbarProviderSearchTips" ||
firstResult.providerName != "UrlbarProviderSearchTips") ||
queryContext.trimmedSearchString) && queryContext.trimmedSearchString) &&
queryContext.trimmedSearchString[0] != "@" && queryContext.trimmedSearchString[0] != "@" &&
(queryContext.trimmedSearchString[0] != (queryContext.trimmedSearchString[0] !=
@ -1953,7 +1942,6 @@ class UrlbarView {
// query. Don't change the heuristic result because it would be // query. Don't change the heuristic result because it would be
// immediately replaced with the search mode heuristic, causing flicker. // immediately replaced with the search mode heuristic, causing flicker.
if ( if (
this.oneOffsRefresh &&
result.heuristic && result.heuristic &&
!engine && !engine &&
!localSearchMode && !localSearchMode &&
@ -1993,20 +1981,11 @@ class UrlbarView {
} }
} }
// When update2 is disabled, we only update search results when a search
// engine one-off is selected.
if (
!this.oneOffsRefresh &&
result.type != UrlbarUtils.RESULT_TYPE.SEARCH
) {
continue;
}
// If the result is the heuristic and a one-off is selected (i.e., // If the result is the heuristic and a one-off is selected (i.e.,
// localSearchMode || engine), then restyle it to look like a search // localSearchMode || engine), then restyle it to look like a search
// result; otherwise, remove such styling. For restyled results, we // result; otherwise, remove such styling. For restyled results, we
// override the usual result-picking behaviour in UrlbarInput.pickResult. // override the usual result-picking behaviour in UrlbarInput.pickResult.
if (this.oneOffsRefresh && result.heuristic) { if (result.heuristic) {
title.textContent = title.textContent =
localSearchMode || engine localSearchMode || engine
? this._queryContext.searchString ? this._queryContext.searchString
@ -2061,9 +2040,6 @@ class UrlbarView {
iconOverride = UrlbarUtils.ICON.SEARCH_GLASS; iconOverride = UrlbarUtils.ICON.SEARCH_GLASS;
} }
if ( if (
// Don't update the favicon on non-heuristic results when update2 is
// enabled.
!this.oneOffsRefresh ||
result.heuristic || result.heuristic ||
(result.payload.inPrivateWindow && !result.payload.isPrivateEngine) (result.payload.inPrivateWindow && !result.payload.isPrivateEngine)
) { ) {

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

@ -294,20 +294,12 @@ add_task(async function oncePerSession() {
}); });
}); });
// When update 2 is enabled, the one-off search buttons should not be shown when // The one-off search buttons should not be shown when
// a search tip is shown even though the search string is empty. // a search tip is shown even though the search string is empty.
add_task(async function update2() { add_task(async function update2() {
// Set the update2 prefs.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await checkTab( await checkTab(
window, window,
"about:newtab", "about:newtab",
UrlbarProviderSearchTips.TIP_TYPE.ONBOARD UrlbarProviderSearchTips.TIP_TYPE.ONBOARD
); );
await SpecialPowers.popPrefEnv();
}); });

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

@ -105,7 +105,6 @@ support-files =
file_urlbar_edit_dos.html file_urlbar_edit_dos.html
[browser_new_tab_urlbar_reset.js] [browser_new_tab_urlbar_reset.js]
[browser_oneOffs_contextMenu.js] [browser_oneOffs_contextMenu.js]
[browser_oneOffs_contextMenu_legacy.js]
support-files = support-files =
searchSuggestionEngine.xml searchSuggestionEngine.xml
searchSuggestionEngine.sjs searchSuggestionEngine.sjs

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

@ -332,12 +332,6 @@ add_task(async function test_adaptive_mouse() {
add_task(async function test_adaptive_searchmode() { add_task(async function test_adaptive_searchmode() {
info("Check adaptive history is not shown in search mode."); info("Check adaptive history is not shown in search mode.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
let suggestionsEngine = await SearchTestUtils.promiseNewSearchEngine( let suggestionsEngine = await SearchTestUtils.promiseNewSearchEngine(
getRootDirectory(gTestPath) + "searchSuggestionEngine.xml" getRootDirectory(gTestPath) + "searchSuggestionEngine.xml"
@ -364,6 +358,4 @@ add_task(async function test_adaptive_searchmode() {
await UrlbarTestUtils.enterSearchMode(window, { await UrlbarTestUtils.enterSearchMode(window, {
engineName: suggestionsEngine.name, engineName: suggestionsEngine.name,
}); });
await SpecialPowers.popPrefEnv();
}); });

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

@ -128,14 +128,6 @@ add_task(async function noOneOffs_legacy() {
// Opens the view without showing the one-offs. They should be hidden and arrow // Opens the view without showing the one-offs. They should be hidden and arrow
// key selection should work properly. // key selection should work properly.
add_task(async function noOneOffs() { add_task(async function noOneOffs() {
// Set the update2 prefs.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// Do a search for "@" since we hide the one-offs in that case. // Do a search for "@" since we hide the one-offs in that case.
let value = "@"; let value = "@";
await UrlbarTestUtils.promiseAutocompleteResultPopup({ await UrlbarTestUtils.promiseAutocompleteResultPopup({
@ -188,19 +180,10 @@ add_task(async function noOneOffs() {
assertState(-1, -1, value); assertState(-1, -1, value);
await hidePopup(); await hidePopup();
await SpecialPowers.popPrefEnv();
}); });
// Opens the top-sites view. The one-offs should be shown. // Opens the top-sites view. The one-offs should be shown.
add_task(async function topSites() { add_task(async function topSites() {
// Set the update2 prefs.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// Do a search that shows top sites. // Do a search that shows top sites.
await UrlbarTestUtils.promiseAutocompleteResultPopup({ await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, window,
@ -263,7 +246,6 @@ add_task(async function topSites() {
assertState(-1, -1, ""); assertState(-1, -1, "");
await hidePopup(); await hidePopup();
await SpecialPowers.popPrefEnv();
}); });
// Keys up and down through the non-top-sites view, i.e., the view that's shown // Keys up and down through the non-top-sites view, i.e., the view that's shown
@ -448,47 +430,23 @@ add_task(async function oneOffClick() {
// stricter. Even if it looks like a url, we should search. // stricter. Even if it looks like a url, we should search.
let typedValue = "foo.bar"; let typedValue = "foo.bar";
for (let refresh of [true, false]) { await UrlbarTestUtils.promiseAutocompleteResultPopup({
await SpecialPowers.pushPrefEnv({ window,
set: [ value: typedValue,
["browser.urlbar.update2", refresh], });
["browser.urlbar.update2.oneOffsRefresh", refresh], await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
], assertState(0, -1, typedValue);
}); let oneOffs = oneOffSearchButtons.getSelectableButtons(true);
await UrlbarTestUtils.promiseAutocompleteResultPopup({ let searchPromise = UrlbarTestUtils.promiseSearchComplete(window);
window, EventUtils.synthesizeMouseAtCenter(oneOffs[0], {});
value: typedValue, await searchPromise;
}); Assert.ok(UrlbarTestUtils.isPopupOpen(window), "Urlbar view is still open.");
await UrlbarTestUtils.getDetailsOfResultAt(window, 0); await UrlbarTestUtils.assertSearchMode(window, {
assertState(0, -1, typedValue); engineName: oneOffs[0].engine.name,
let oneOffs = oneOffSearchButtons.getSelectableButtons(true); entry: "oneoff",
});
if (refresh) { await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
let searchPromise = UrlbarTestUtils.promiseSearchComplete(window);
EventUtils.synthesizeMouseAtCenter(oneOffs[0], {});
await searchPromise;
Assert.ok(
UrlbarTestUtils.isPopupOpen(window),
"Urlbar view is still open."
);
await UrlbarTestUtils.assertSearchMode(window, {
engineName: oneOffs[0].engine.name,
entry: "oneoff",
});
await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
} else {
let resultsPromise = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
"http://mochi.test:8888/?terms=foo.bar"
);
EventUtils.synthesizeMouseAtCenter(oneOffs[0], {});
await resultsPromise;
}
await SpecialPowers.popPrefEnv();
}
gBrowser.removeTab(gBrowser.selectedTab); gBrowser.removeTab(gBrowser.selectedTab);
await UrlbarTestUtils.formHistory.clear(); await UrlbarTestUtils.formHistory.clear();
@ -502,52 +460,28 @@ add_task(async function oneOffReturn() {
// stricter. Even if it looks like a url, we should search. // stricter. Even if it looks like a url, we should search.
let typedValue = "foo.bar"; let typedValue = "foo.bar";
for (let refresh of [true, false]) { await UrlbarTestUtils.promiseAutocompleteResultPopup({
await SpecialPowers.pushPrefEnv({ window,
set: [ value: typedValue,
["browser.urlbar.update2", refresh], fireInputEvent: true,
["browser.urlbar.update2.oneOffsRefresh", refresh], });
], await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
}); assertState(0, -1, typedValue);
let oneOffs = oneOffSearchButtons.getSelectableButtons(true);
await UrlbarTestUtils.promiseAutocompleteResultPopup({ // Alt+Down to select the first one-off.
window, EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
value: typedValue, assertState(0, 0, typedValue);
fireInputEvent: true,
});
await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
assertState(0, -1, typedValue);
let oneOffs = oneOffSearchButtons.getSelectableButtons(true);
// Alt+Down to select the first one-off. let searchPromise = UrlbarTestUtils.promiseSearchComplete(window);
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); EventUtils.synthesizeKey("KEY_Enter");
assertState(0, 0, typedValue); await searchPromise;
Assert.ok(UrlbarTestUtils.isPopupOpen(window), "Urlbar view is still open.");
if (refresh) { await UrlbarTestUtils.assertSearchMode(window, {
let searchPromise = UrlbarTestUtils.promiseSearchComplete(window); engineName: oneOffs[0].engine.name,
EventUtils.synthesizeKey("KEY_Enter"); entry: "oneoff",
await searchPromise; });
Assert.ok( await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
UrlbarTestUtils.isPopupOpen(window),
"Urlbar view is still open."
);
await UrlbarTestUtils.assertSearchMode(window, {
engineName: oneOffs[0].engine.name,
entry: "oneoff",
});
await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
} else {
let resultsPromise = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
"http://mochi.test:8888/?terms=foo.bar"
);
EventUtils.synthesizeKey("KEY_Enter");
await resultsPromise;
}
await SpecialPowers.popPrefEnv();
}
gBrowser.removeTab(gBrowser.selectedTab); gBrowser.removeTab(gBrowser.selectedTab);
await UrlbarTestUtils.formHistory.clear(); await UrlbarTestUtils.formHistory.clear();
@ -671,13 +605,6 @@ add_task(async function localShortcuts() {
// Clicks a local shortcut button. // Clicks a local shortcut button.
add_task(async function localShortcutClick() { add_task(async function localShortcutClick() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// We are explicitly using something that looks like a url, to make the test // We are explicitly using something that looks like a url, to make the test
// stricter. Even if it looks like a url, we should search. // stricter. Even if it looks like a url, we should search.
let typedValue = "foo.bar"; let typedValue = "foo.bar";
@ -713,18 +640,10 @@ add_task(async function localShortcutClick() {
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
await hidePopup(); await hidePopup();
await SpecialPowers.popPrefEnv();
}); });
// Presses the Return key when a local shortcut is selected. // Presses the Return key when a local shortcut is selected.
add_task(async function localShortcutReturn() { add_task(async function localShortcutReturn() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// We are explicitly using something that looks like a url, to make the test // We are explicitly using something that looks like a url, to make the test
// stricter. Even if it looks like a url, we should search. // stricter. Even if it looks like a url, we should search.
let typedValue = "foo.bar"; let typedValue = "foo.bar";
@ -786,19 +705,11 @@ add_task(async function localShortcutReturn() {
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
await hidePopup(); await hidePopup();
await SpecialPowers.popPrefEnv();
}); });
// With an empty search string, clicking a local shortcut should result in no // With an empty search string, clicking a local shortcut should result in no
// heuristic result. // heuristic result.
add_task(async function localShortcutEmptySearchString() { add_task(async function localShortcutEmptySearchString() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
oneOffSearchButtons.invalidateCache(); oneOffSearchButtons.invalidateCache();
let rebuildPromise = BrowserTestUtils.waitForEvent( let rebuildPromise = BrowserTestUtils.waitForEvent(
oneOffSearchButtons, oneOffSearchButtons,
@ -858,7 +769,6 @@ add_task(async function localShortcutEmptySearchString() {
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
await hidePopup(); await hidePopup();
await SpecialPowers.popPrefEnv();
}); });
// Trigger SearchOneOffs.willHide() outside of SearchOneOffs.__rebuild(). Ensure // Trigger SearchOneOffs.willHide() outside of SearchOneOffs.__rebuild(). Ensure
@ -869,11 +779,7 @@ add_task(async function avoidWillHideRace() {
// UrlbarView calling SearchOneOffs.willHide(). That only happens when the // UrlbarView calling SearchOneOffs.willHide(). That only happens when the
// Urlbar is in search mode after a query that returned no results. // Urlbar is in search mode after a query that returned no results.
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.urlbar.maxHistoricalSearchSuggestions", 0]],
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
["browser.urlbar.maxHistoricalSearchSuggestions", 0],
],
}); });
oneOffSearchButtons.invalidateCache(); oneOffSearchButtons.invalidateCache();
@ -1089,13 +995,6 @@ add_task(async function localShortcutsShownWhenEnginesHidden() {
* Checks that the local shortcuts are shown correctly. * Checks that the local shortcuts are shown correctly.
*/ */
async function doLocalShortcutsShownTest() { async function doLocalShortcutsShownTest() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
let rebuildPromise = BrowserTestUtils.waitForEvent( let rebuildPromise = BrowserTestUtils.waitForEvent(
oneOffSearchButtons, oneOffSearchButtons,
"rebuild" "rebuild"
@ -1135,7 +1034,6 @@ async function doLocalShortcutsShownTest() {
} }
await hidePopup(); await hidePopup();
await SpecialPowers.popPrefEnv();
} }
function assertState(result, oneOff, textValue = undefined) { function assertState(result, oneOff, textValue = undefined) {

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

@ -18,15 +18,6 @@ XPCOMUtils.defineLazyGetter(this, "oneOffSearchButtons", () => {
let originalEngine; let originalEngine;
let newEngine; let newEngine;
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
});
// The one-off context menu should not be shown. // The one-off context menu should not be shown.
add_task(async function contextMenu_not_shown() { add_task(async function contextMenu_not_shown() {
// Add a popupshown listener on the context menu that sets this // Add a popupshown listener on the context menu that sets this

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

@ -1,195 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests that the right-click menu works correctly for the one-off buttons.
* This test can be removed with the update2 pref.
*/
const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
let gMaxResults;
XPCOMUtils.defineLazyGetter(this, "oneOffSearchButtons", () => {
return UrlbarTestUtils.getOneOffSearchButtons(window);
});
let originalEngine;
let newEngine;
add_task(async function setup() {
SpecialPowers.pushPrefEnv({
set: [
// Avoid hitting the network with search suggestions.
["browser.urlbar.suggest.searches", false],
["browser.tabs.loadInBackground", true],
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
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.
originalEngine = await Services.search.getDefault();
newEngine = await SearchTestUtils.promiseNewSearchEngine(
getRootDirectory(gTestPath) + TEST_ENGINE_BASENAME
);
await Services.search.moveEngine(newEngine, 0);
registerCleanupFunction(async function() {
await PlacesUtils.history.clear();
await UrlbarTestUtils.formHistory.clear();
await Services.search.setDefault(originalEngine);
});
await PlacesUtils.history.clear();
await UrlbarTestUtils.formHistory.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 searchInTab(checkFn) {
// Ensure we've got a different engine selected to the one we added. so that
// it is a different engine to select.
await Services.search.setDefault(originalEngine);
await BrowserTestUtils.withNewTab({ gBrowser }, async testBrowser => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "foo",
});
let contextMenu = oneOffSearchButtons.querySelector(
".search-one-offs-context-menu"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
);
let oneOffs = oneOffSearchButtons.getSelectableButtons(true);
EventUtils.synthesizeMouseAtCenter(oneOffs[0], {
type: "contextmenu",
button: 2,
});
await popupShownPromise;
let tabOpenAndLoaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
let openInTab = oneOffSearchButtons.querySelector(
".search-one-offs-context-open-in-new-tab"
);
EventUtils.synthesizeMouseAtCenter(openInTab, {});
let newTab = await tabOpenAndLoaded;
checkFn(testBrowser, newTab);
BrowserTestUtils.removeTab(newTab);
await UrlbarTestUtils.formHistory.clear();
});
}
add_task(async function searchInNewTab_opensBackground() {
await SpecialPowers.pushPrefEnv({
set: [["browser.tabs.loadInBackground", true]],
});
await searchInTab((testBrowser, newTab) => {
Assert.equal(
newTab.linkedBrowser.currentURI.spec,
"http://mochi.test:8888/?terms=foo",
"Should have loaded the expected URI in a new tab."
);
Assert.equal(
testBrowser.currentURI.spec,
"about:blank",
"Should not have touched the original tab"
);
Assert.equal(
testBrowser,
gBrowser.selectedTab.linkedBrowser,
"Should not have changed the selected tab"
);
});
await SpecialPowers.popPrefEnv();
});
add_task(async function searchInNewTab_opensForeground() {
await SpecialPowers.pushPrefEnv({
set: [["browser.tabs.loadInBackground", false]],
});
await searchInTab((testBrowser, newTab) => {
Assert.equal(
newTab.linkedBrowser.currentURI.spec,
"http://mochi.test:8888/?terms=foo",
"Should have loaded the expected URI in a new tab."
);
Assert.equal(
testBrowser.currentURI.spec,
"about:blank",
"Should not have touched the original tab"
);
Assert.equal(
newTab,
gBrowser.selectedTab,
"Should have changed the selected tab"
);
});
await SpecialPowers.popPrefEnv();
});
add_task(async function switchDefaultEngine() {
await Services.search.setDefault(originalEngine);
await BrowserTestUtils.withNewTab({ gBrowser }, async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "foo",
});
let contextMenu = oneOffSearchButtons.querySelector(
".search-one-offs-context-menu"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
);
let oneOffs = oneOffSearchButtons.getSelectableButtons(true);
EventUtils.synthesizeMouseAtCenter(oneOffs[0], {
type: "contextmenu",
button: 2,
});
await popupShownPromise;
let engineChangedPromise = SearchTestUtils.promiseSearchNotification(
"engine-default",
"browser-search-engine-modified"
);
let setDefault = oneOffSearchButtons.querySelector(
".search-one-offs-context-set-default"
);
EventUtils.synthesizeMouseAtCenter(setDefault, {});
await engineChangedPromise;
Assert.equal(
await Services.search.getDefault(),
newEngine,
"Should have correctly changed the engine to the new one"
);
});
});

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

@ -255,11 +255,7 @@ add_task(async function init() {
}); });
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.urlbar.suggest.searches", false]],
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
["browser.urlbar.suggest.searches", false],
],
}); });
// Move the mouse away from the view so that a result or one-off isn't // Move the mouse away from the view so that a result or one-off isn't

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

@ -37,12 +37,7 @@ add_task(async function init() {
await Services.search.moveEngine(engine, 0); await Services.search.moveEngine(engine, 0);
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.search.separatePrivateDefault.ui.enabled", false]],
["browser.search.separatePrivateDefault.ui.enabled", false],
// This test is only concerned with update2 behaviour.
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
}); });
registerCleanupFunction(async function() { registerCleanupFunction(async function() {

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

@ -103,66 +103,9 @@ async function selectSecondSuggestion(index, isFormHistory) {
}); });
} }
// Presses the Return key when a one-off is selected after selecting a search
// suggestion.
// Can be removed with the update2 prefs.
add_task(async function test_returnAfterSuggestion_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory);
// Alt+Down to select the first one-off.
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
await assertState({
inputValue: "foobar",
resultIndex: index + 1,
oneOffIndex: 0,
suggestion: {
isFormHistory: usingFormHistory,
},
});
let heuristicResult = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
Assert.ok(
!BrowserTestUtils.is_visible(heuristicResult.element.action),
"The heuristic action should not be visible"
);
await UrlbarTestUtils.formHistory.clear();
let formHistoryPromise = UrlbarTestUtils.formHistory.promiseChanged("add");
let resultsPromise = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
`http://mochi.test:8888/?terms=foobar`
);
EventUtils.synthesizeKey("KEY_Enter");
await resultsPromise;
await formHistoryPromise;
let entries = (
await UrlbarTestUtils.formHistory.search({
value: "foobar",
source: gEngine.name,
})
).map(entry => entry.value);
Assert.ok(entries.includes("foobar"));
});
await SpecialPowers.popPrefEnv();
});
// Presses the Return key when a one-off is selected after selecting a search // Presses the Return key when a one-off is selected after selecting a search
// suggestion. // suggestion.
add_task(async function test_returnAfterSuggestion() { add_task(async function test_returnAfterSuggestion() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await withSuggestions(async (index, usingFormHistory) => { await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory); await selectSecondSuggestion(index, usingFormHistory);
@ -192,19 +135,12 @@ add_task(async function test_returnAfterSuggestion() {
}); });
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
}); });
await SpecialPowers.popPrefEnv();
}); });
// Presses the Return key when a non-default one-off is selected after selecting // Presses the Return key when a non-default one-off is selected after selecting
// a search suggestion. // a search suggestion.
// Can be removed with the update2 prefs. // Can be removed with the update2 prefs.
add_task(async function test_returnAfterSuggestion_nonDefault_legacy() { add_task(async function test_returnAfterSuggestion_nonDefault_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
await withSuggestions(async (index, usingFormHistory) => { await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory); await selectSecondSuggestion(index, usingFormHistory);
@ -228,18 +164,11 @@ add_task(async function test_returnAfterSuggestion_nonDefault_legacy() {
EventUtils.synthesizeKey("KEY_Enter"); EventUtils.synthesizeKey("KEY_Enter");
await resultsPromise; await resultsPromise;
}); });
await SpecialPowers.popPrefEnv();
}); });
// Presses the Return key when a non-default one-off is selected after selecting // Presses the Return key when a non-default one-off is selected after selecting
// a search suggestion. // a search suggestion.
add_task(async function test_returnAfterSuggestion_nonDefault() { add_task(async function test_returnAfterSuggestion_nonDefault() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await withSuggestions(async (index, usingFormHistory) => { await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory); await selectSecondSuggestion(index, usingFormHistory);
@ -264,43 +193,10 @@ add_task(async function test_returnAfterSuggestion_nonDefault() {
}); });
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
}); });
await SpecialPowers.popPrefEnv();
});
// Clicks a one-off engine after selecting a search suggestion.
// Can be removed with the update2 prefs.
add_task(async function test_clickAfterSuggestion_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory);
let oneOffs = UrlbarTestUtils.getOneOffSearchButtons(
window
).getSelectableButtons(true);
let resultsPromise = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
`http://mochi.test:8888/?terms=foobar`
);
EventUtils.synthesizeMouseAtCenter(oneOffs[0], {});
await resultsPromise;
});
await SpecialPowers.popPrefEnv();
}); });
// Clicks a one-off engine after selecting a search suggestion. // Clicks a one-off engine after selecting a search suggestion.
add_task(async function test_clickAfterSuggestion() { add_task(async function test_clickAfterSuggestion() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await withSuggestions(async (index, usingFormHistory) => { await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory); await selectSecondSuggestion(index, usingFormHistory);
@ -316,43 +212,10 @@ add_task(async function test_clickAfterSuggestion() {
}); });
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
}); });
await SpecialPowers.popPrefEnv();
});
// Clicks a non-default one-off engine after selecting a search suggestion.
// Can be removed with the update2 prefs.
add_task(async function test_clickAfterSuggestion_nonDefault_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory);
let oneOffs = UrlbarTestUtils.getOneOffSearchButtons(
window
).getSelectableButtons(true);
let resultsPromise = BrowserTestUtils.browserLoaded(
gBrowser.selectedBrowser,
false,
`http://localhost:20709/?terms=foobar`
);
EventUtils.synthesizeMouseAtCenter(oneOffs[1], {});
await resultsPromise;
});
await SpecialPowers.popPrefEnv();
}); });
// Clicks a non-default one-off engine after selecting a search suggestion. // Clicks a non-default one-off engine after selecting a search suggestion.
add_task(async function test_clickAfterSuggestion_nonDefault() { add_task(async function test_clickAfterSuggestion_nonDefault() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await withSuggestions(async (index, usingFormHistory) => { await withSuggestions(async (index, usingFormHistory) => {
await selectSecondSuggestion(index, usingFormHistory); await selectSecondSuggestion(index, usingFormHistory);
@ -368,7 +231,6 @@ add_task(async function test_clickAfterSuggestion_nonDefault() {
}); });
await UrlbarTestUtils.exitSearchMode(window, { backspace: true }); await UrlbarTestUtils.exitSearchMode(window, { backspace: true });
}); });
await SpecialPowers.popPrefEnv();
}); });
// Selects a non-default one-off engine and then clicks a search suggestion. // Selects a non-default one-off engine and then clicks a search suggestion.

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

@ -272,14 +272,6 @@ add_task(async function test_search_mode_history() {
* The expected l10n object for the one-off. * The expected l10n object for the one-off.
*/ */
async function doSearchModeTest(expectedSearchMode, expectedPlaceholderL10n) { async function doSearchModeTest(expectedSearchMode, expectedPlaceholderL10n) {
// Enable update2.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// Click the urlbar to open the top-sites view. // Click the urlbar to open the top-sites view.
if (gURLBar.getAttribute("pageproxystate") == "invalid") { if (gURLBar.getAttribute("pageproxystate") == "invalid") {
gURLBar.handleRevert(); gURLBar.handleRevert();
@ -300,5 +292,4 @@ async function doSearchModeTest(expectedSearchMode, expectedPlaceholderL10n) {
await UrlbarTestUtils.exitSearchMode(window, { clickClose: true }); await UrlbarTestUtils.exitSearchMode(window, { clickClose: true });
await UrlbarTestUtils.promisePopupClose(window); await UrlbarTestUtils.promisePopupClose(window);
await SpecialPowers.popPrefEnv();
} }

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

@ -177,8 +177,6 @@ add_task(async function test_searchMode_removeRestyledHistory() {
set: [ set: [
["browser.urlbar.suggest.searches", true], ["browser.urlbar.suggest.searches", true],
["browser.urlbar.maxHistoricalSearchSuggestions", 1], ["browser.urlbar.maxHistoricalSearchSuggestions", 1],
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
], ],
}); });

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

@ -109,12 +109,6 @@ add_task(async function searchRestriction() {
}); });
add_task(async function historyRestriction() { add_task(async function historyRestriction() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
gURLBar.blur(); gURLBar.blur();
await UrlbarTestUtils.promisePopupOpen(window, () => await UrlbarTestUtils.promisePopupOpen(window, () =>
gURLBar.search(UrlbarTokenizer.RESTRICT.HISTORY) gURLBar.search(UrlbarTokenizer.RESTRICT.HISTORY)
@ -128,16 +122,9 @@ add_task(async function historyRestriction() {
Assert.ok(!gURLBar.value, "The Urlbar has no value."); Assert.ok(!gURLBar.value, "The Urlbar has no value.");
await UrlbarTestUtils.exitSearchMode(window); await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window); await UrlbarTestUtils.promisePopupClose(window);
await SpecialPowers.popPrefEnv();
}); });
add_task(async function historyRestrictionWithString() { add_task(async function historyRestrictionWithString() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
gURLBar.blur(); gURLBar.blur();
// The leading and trailing spaces are intentional to verify that search() // The leading and trailing spaces are intentional to verify that search()
// preserves them. // preserves them.
@ -162,7 +149,6 @@ add_task(async function historyRestrictionWithString() {
assertOneOffButtonsVisible(true); assertOneOffButtonsVisible(true);
await UrlbarTestUtils.exitSearchMode(window); await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window); await UrlbarTestUtils.promisePopupClose(window);
await SpecialPowers.popPrefEnv();
}); });
add_task(async function tagRestriction() { add_task(async function tagRestriction() {

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

@ -34,13 +34,6 @@ add_task(async function setup() {
await Services.search.removeEngine(aliasEngine); await Services.search.removeEngine(aliasEngine);
Services.search.setDefault(oldDefaultEngine); Services.search.setDefault(oldDefaultEngine);
}); });
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
}); });
// An incomplete alias should not be replaced. // An incomplete alias should not be replaced.

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

@ -11,14 +11,6 @@
const DEFAULT_ENGINE_NAME = "Test"; const DEFAULT_ENGINE_NAME = "Test";
add_task(async function setup() { add_task(async function setup() {
// This test requires update2.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
await PlacesTestUtils.addVisits([{ uri: "http://example.com/" }]); await PlacesTestUtils.addVisits([{ uri: "http://example.com/" }]);
} }

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

@ -11,15 +11,6 @@
const LINK_PAGE_URL = const LINK_PAGE_URL =
"http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/dummy_page.html"; "http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/dummy_page.html";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
});
// Opens a new tab containing a link, enters search mode, and clicks the link. // Opens a new tab containing a link, enters search mode, and clicks the link.
// Uses a variety of search strings and link hrefs in order to hit different // Uses a variety of search strings and link hrefs in order to hit different
// branches in setURI. Search mode should be exited in all cases, and the href // branches in setURI. Search mode should be exited in all cases, and the href

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

@ -7,15 +7,6 @@
"use strict"; "use strict";
add_task(async function init() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
});
// Tests that we exit search mode in the active tab when the search mode engine // Tests that we exit search mode in the active tab when the search mode engine
// is removed. // is removed.
add_task(async function activeTab() { add_task(async function activeTab() {

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

@ -15,8 +15,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
["browser.urlbar.suggest.searches", false], ["browser.urlbar.suggest.searches", false],
["browser.urlbar.autoFill", false], ["browser.urlbar.autoFill", false],
// Special prefs for remote tabs. // Special prefs for remote tabs.

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

@ -8,13 +8,6 @@
"use strict"; "use strict";
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await PlacesUtils.history.clear(); await PlacesUtils.history.clear();
await PlacesUtils.bookmarks.eraseEverything(); await PlacesUtils.bookmarks.eraseEverything();

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

@ -62,11 +62,7 @@ add_task(async function setup() {
); );
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.search.separatePrivateDefault.ui.enabled", false]],
["browser.search.separatePrivateDefault.ui.enabled", false],
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
}); });
}); });

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

@ -15,11 +15,7 @@ let engine;
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.urlbar.suggest.searches", true]],
["browser.urlbar.suggest.searches", true],
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
}); });
engine = await SearchTestUtils.promiseNewSearchEngine( engine = await SearchTestUtils.promiseNewSearchEngine(
getRootDirectory(gTestPath) + SUGGESTIONS_ENGINE_NAME getRootDirectory(gTestPath) + SUGGESTIONS_ENGINE_NAME

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

@ -10,13 +10,6 @@
const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml"; const TEST_ENGINE_BASENAME = "searchSuggestionEngine.xml";
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// In order to open the view without any results, we need to be in search mode // In order to open the view without any results, we need to be in search mode
// with an empty search string so that no heuristic result is shown, and the // with an empty search string so that no heuristic result is shown, and the
// empty search must yield zero additional results. We'll enter search mode // empty search must yield zero additional results. We'll enter search mode

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

@ -16,13 +16,6 @@ const TEST_ENGINE = {
}; };
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
const engine = await Services.search.addEngineWithDetails( const engine = await Services.search.addEngineWithDetails(
TEST_ENGINE.name, TEST_ENGINE.name,
TEST_ENGINE.details TEST_ENGINE.details

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

@ -10,13 +10,6 @@
const BOOKMARK_URL = "http://www.example.com/browser_searchMode_pickResult.js"; const BOOKMARK_URL = "http://www.example.com/browser_searchMode_pickResult.js";
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// Add a bookmark so we can enter bookmarks search mode and pick it. // Add a bookmark so we can enter bookmarks search mode and pick it.
await PlacesUtils.bookmarks.eraseEverything(); await PlacesUtils.bookmarks.eraseEverything();
await PlacesUtils.bookmarks.insert({ await PlacesUtils.bookmarks.insert({

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

@ -13,8 +13,6 @@ const TEST_ENGINE_DOMAIN = "example.com";
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
// TODO (Bug 1675558) - This should not be a requirement for the whole test. // TODO (Bug 1675558) - This should not be a requirement for the whole test.
["browser.urlbar.update2.emptySearchBehavior", 2], ["browser.urlbar.update2.emptySearchBehavior", 2],
], ],

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

@ -19,15 +19,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
// bug 1671087, but it's not clear. Regardless, a longer timeout won't hurt. // bug 1671087, but it's not clear. Regardless, a longer timeout won't hurt.
requestLongerTimeout(5); requestLongerTimeout(5);
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
});
const SEARCH_STRING = "test browser_sessionStore.js"; const SEARCH_STRING = "test browser_sessionStore.js";
const URL = "http://example.com/"; const URL = "http://example.com/";

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

@ -8,15 +8,6 @@
"use strict"; "use strict";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
});
// Opens a new tab, does a search, enters search mode, and then manually calls // Opens a new tab, does a search, enters search mode, and then manually calls
// setURI. Uses a variety of initial URLs, search strings, and setURI arguments // setURI. Uses a variety of initial URLs, search strings, and setURI arguments
// in order to hit different branches in setURI. Search mode should remain // in order to hit different branches in setURI. Search mode should remain

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

@ -71,11 +71,7 @@ add_task(async function setup() {
}); });
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.search.separatePrivateDefault.ui.enabled", false]],
["browser.search.separatePrivateDefault.ui.enabled", false],
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
}); });
}); });

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

@ -7,15 +7,6 @@
"use strict"; "use strict";
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
});
// Enters search mode using the one-off buttons. // Enters search mode using the one-off buttons.
add_task(async function switchTabs() { add_task(async function switchTabs() {
// Open three tabs. We'll enter search mode in tabs 0 and 2. // Open three tabs. We'll enter search mode in tabs 0 and 2.

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

@ -138,78 +138,78 @@ add_task(async function test_search_disabled_suggestions() {
// TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2 // TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2
// pref on. // pref on.
add_task(async function test_oneoff_selected_keyboard() { // add_task(async function test_oneoff_selected_keyboard() {
info( // info(
"Test that 'Search in a Private Window' with keyboard opens the selected one-off engine if there's no private engine" // "Test that 'Search in a Private Window' with keyboard opens the selected one-off engine if there's no private engine"
); // );
await SpecialPowers.pushPrefEnv({ // await SpecialPowers.pushPrefEnv({
set: [ // set: [
["browser.urlbar.update2", false], // ["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false], // ["browser.urlbar.update2.oneOffsRefresh", false],
], // ],
}); // });
await UrlbarTestUtils.promiseAutocompleteResultPopup({ // await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, // window,
value: "unique198273982173", // value: "unique198273982173",
}); // });
await AssertPrivateResult(window, await Services.search.getDefault(), false); // await AssertPrivateResult(window, await Services.search.getDefault(), false);
// Select the 'Search in a Private Window' result, alt down to select the // // Select the 'Search in a Private Window' result, alt down to select the
// first one-off button, Enter. It should open a pb window, but using the // // first one-off button, Enter. It should open a pb window, but using the
// selected one-off engine. // // selected one-off engine.
let promiseWindow = BrowserTestUtils.waitForNewWindow({ // let promiseWindow = BrowserTestUtils.waitForNewWindow({
url: // url:
"http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/print_postdata.sjs", // "http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/print_postdata.sjs",
}); // });
// Select the private result. // // Select the private result.
EventUtils.synthesizeKey("KEY_ArrowDown"); // EventUtils.synthesizeKey("KEY_ArrowDown");
// Select the first one-off button. // // Select the first one-off button.
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); // EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
EventUtils.synthesizeKey("VK_RETURN"); // EventUtils.synthesizeKey("VK_RETURN");
let win = await promiseWindow; // let win = await promiseWindow;
Assert.ok( // Assert.ok(
PrivateBrowsingUtils.isWindowPrivate(win), // PrivateBrowsingUtils.isWindowPrivate(win),
"Should open a private window" // "Should open a private window"
); // );
await BrowserTestUtils.closeWindow(win); // await BrowserTestUtils.closeWindow(win);
await SpecialPowers.popPrefEnv(); // await SpecialPowers.popPrefEnv();
}); // });
// TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2 // TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2
// pref on. // pref on.
add_task(async function test_oneoff_selected_mouse() { // add_task(async function test_oneoff_selected_mouse() {
info( // info(
"Test that 'Search in a Private Window' with mouse opens the selected one-off engine if there's no private engine" // "Test that 'Search in a Private Window' with mouse opens the selected one-off engine if there's no private engine"
); // );
await SpecialPowers.pushPrefEnv({ // await SpecialPowers.pushPrefEnv({
set: [ // set: [
["browser.urlbar.update2", false], // ["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false], // ["browser.urlbar.update2.oneOffsRefresh", false],
], // ],
}); // });
await UrlbarTestUtils.promiseAutocompleteResultPopup({ // await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, // window,
value: "unique198273982173", // value: "unique198273982173",
}); // });
await AssertPrivateResult(window, await Services.search.getDefault(), false); // await AssertPrivateResult(window, await Services.search.getDefault(), false);
// Select the 'Search in a Private Window' result, alt down to select the // // Select the 'Search in a Private Window' result, alt down to select the
// first one-off button, Enter. It should open a pb window, but using the // // first one-off button, Enter. It should open a pb window, but using the
// selected one-off engine. // // selected one-off engine.
let promiseWindow = BrowserTestUtils.waitForNewWindow({ // let promiseWindow = BrowserTestUtils.waitForNewWindow({
url: // url:
"http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/print_postdata.sjs", // "http://mochi.test:8888/browser/browser/components/urlbar/tests/browser/print_postdata.sjs",
}); // });
// Select the private result. // // Select the private result.
EventUtils.synthesizeKey("KEY_ArrowDown"); // EventUtils.synthesizeKey("KEY_ArrowDown");
// Select the first one-off button. // // Select the first one-off button.
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); // EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
// Click on the result. // // Click on the result.
let element = UrlbarTestUtils.getSelectedRow(window); // let element = UrlbarTestUtils.getSelectedRow(window);
EventUtils.synthesizeMouseAtCenter(element, {}); // EventUtils.synthesizeMouseAtCenter(element, {});
let win = await promiseWindow; // let win = await promiseWindow;
Assert.ok( // Assert.ok(
PrivateBrowsingUtils.isWindowPrivate(win), // PrivateBrowsingUtils.isWindowPrivate(win),
"Should open a private window" // "Should open a private window"
); // );
await BrowserTestUtils.closeWindow(win); // await BrowserTestUtils.closeWindow(win);
await SpecialPowers.popPrefEnv(); // await SpecialPowers.popPrefEnv();
}); // });

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

@ -177,102 +177,99 @@ add_task(async function test_openPBWindow() {
// TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2 // TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2
// pref on. // pref on.
add_task(async function test_oneoff_selected_with_private_engine_mouse() { // add_task(async function test_oneoff_selected_with_private_engine_mouse() {
info( // info(
"Test that 'Search in a Private Window' opens the private engine even if a one-off is selected" // "Test that 'Search in a Private Window' opens the private engine even if a one-off is selected"
); // );
await SpecialPowers.pushPrefEnv({ // await SpecialPowers.pushPrefEnv({
set: [ // set: [
["browser.urlbar.update2", false], // ["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false], // ["browser.urlbar.update2.oneOffsRefresh", false],
], // ],
}); // });
await UrlbarTestUtils.promiseAutocompleteResultPopup({ // await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, // window,
value: "unique198273982173", // value: "unique198273982173",
}); // });
await AssertPrivateResult( // await AssertPrivateResult(
window, // window,
await Services.search.getDefaultPrivate(), // await Services.search.getDefaultPrivate(),
true // true
); // );
await withHttpServer(serverInfo, async () => { // await withHttpServer(serverInfo, async () => {
// Select the 'Search in a Private Window' result, alt down to select the // // Select the 'Search in a Private Window' result, alt down to select the
// first one-off button, Click on the result. It should open a pb window using // // first one-off button, Click on the result. It should open a pb window using
// the private search engine, because it has been set. // // the private search engine, because it has been set.
let promiseWindow = BrowserTestUtils.waitForNewWindow({ // let promiseWindow = BrowserTestUtils.waitForNewWindow({
url: "http://localhost:20709/?terms=unique198273982173", // url: "http://localhost:20709/?terms=unique198273982173",
maybeErrorPage: true, // maybeErrorPage: true,
}); // });
// Select the private result. // // Select the private result.
EventUtils.synthesizeKey("KEY_ArrowDown"); // EventUtils.synthesizeKey("KEY_ArrowDown");
// Select the first one-off button. // // Select the first one-off button.
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); // EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
// Click on the result. // // Click on the result.
let element = UrlbarTestUtils.getSelectedRow(window); // let element = UrlbarTestUtils.getSelectedRow(window);
EventUtils.synthesizeMouseAtCenter(element, {}); // EventUtils.synthesizeMouseAtCenter(element, {});
let win = await promiseWindow; // let win = await promiseWindow;
Assert.ok( // Assert.ok(
PrivateBrowsingUtils.isWindowPrivate(win), // PrivateBrowsingUtils.isWindowPrivate(win),
"Should open a private window" // "Should open a private window"
); // );
await BrowserTestUtils.closeWindow(win); // await BrowserTestUtils.closeWindow(win);
}); // });
await SpecialPowers.popPrefEnv(); // await SpecialPowers.popPrefEnv();
}); // });
// TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2 // TODO: (Bug 1658620) Write a new subtest for this behaviour with the update2
// pref on. // pref on.
add_task(async function test_oneoff_selected_with_private_engine_keyboard() { // add_task(async function test_oneoff_selected_with_private_engine_keyboard() {
info( // info(
"Test that 'Search in a Private Window' opens the private engine even if a one-off is selected" // "Test that 'Search in a Private Window' opens the private engine even if a one-off is selected"
); // );
await SpecialPowers.pushPrefEnv({ // await SpecialPowers.pushPrefEnv({
set: [ // set: [
["browser.urlbar.update2", false], // ["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false], // ["browser.urlbar.update2.oneOffsRefresh", false],
], // ],
}); // });
await UrlbarTestUtils.promiseAutocompleteResultPopup({ // await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, // window,
value: "unique198273982173", // value: "unique198273982173",
}); // });
await AssertPrivateResult( // await AssertPrivateResult(
window, // window,
await Services.search.getDefaultPrivate(), // await Services.search.getDefaultPrivate(),
true // true
); // );
await withHttpServer(serverInfo, async () => { // await withHttpServer(serverInfo, async () => {
// Select the 'Search in a Private Window' result, alt down to select the // // Select the 'Search in a Private Window' result, alt down to select the
// first one-off button, Enter. It should open a pb window, but using the // // first one-off button, Enter. It should open a pb window, but using the
// selected one-off engine. // // selected one-off engine.
let promiseWindow = BrowserTestUtils.waitForNewWindow({ // let promiseWindow = BrowserTestUtils.waitForNewWindow({
url: "http://localhost:20709/?terms=unique198273982173", // url: "http://localhost:20709/?terms=unique198273982173",
maybeErrorPage: true, // maybeErrorPage: true,
}); // });
// Select the private result. // // Select the private result.
EventUtils.synthesizeKey("KEY_ArrowDown"); // EventUtils.synthesizeKey("KEY_ArrowDown");
// Select the first one-off button. // // Select the first one-off button.
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); // EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
EventUtils.synthesizeKey("VK_RETURN"); // EventUtils.synthesizeKey("VK_RETURN");
let win = await promiseWindow; // let win = await promiseWindow;
Assert.ok( // Assert.ok(
PrivateBrowsingUtils.isWindowPrivate(win), // PrivateBrowsingUtils.isWindowPrivate(win),
"Should open a private window" // "Should open a private window"
); // );
await BrowserTestUtils.closeWindow(win); // await BrowserTestUtils.closeWindow(win);
}); // });
await SpecialPowers.popPrefEnv(); // await SpecialPowers.popPrefEnv();
}); // });
add_task(async function test_alias_no_query() { add_task(async function test_alias_no_query() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.urlbar.update2.emptySearchBehavior", 2]],
["browser.urlbar.update2", true],
["browser.urlbar.update2.emptySearchBehavior", 2],
],
}); });
info( info(
"Test that 'Search in a Private Window' doesn't appear if an alias is typed with no query" "Test that 'Search in a Private Window' doesn't appear if an alias is typed with no query"
@ -295,10 +292,7 @@ add_task(async function test_alias_no_query() {
add_task(async function test_alias_query() { add_task(async function test_alias_query() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [["browser.urlbar.update2.emptySearchBehavior", 2]],
["browser.urlbar.update2", true],
["browser.urlbar.update2.emptySearchBehavior", 2],
],
}); });
info( info(
"Test that 'Search in a Private Window' appears when an alias is typed with a query" "Test that 'Search in a Private Window' appears when an alias is typed with a query"

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

@ -182,12 +182,6 @@ add_task(async function tabSearchModePreview() {
add_task(async function tabTabToSearch() { add_task(async function tabTabToSearch() {
info("Tab past a tab-to-search result after focusing with the keyboard."); info("Tab past a tab-to-search result after focusing with the keyboard.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
let engineDomain = "example.com"; let engineDomain = "example.com";
let testEngine = await Services.search.addEngineWithDetails("Test", { let testEngine = await Services.search.addEngineWithDetails("Test", {
template: `http://${engineDomain}/?search={searchTerms}`, template: `http://${engineDomain}/?search={searchTerms}`,
@ -223,19 +217,12 @@ add_task(async function tabTabToSearch() {
}); });
await PlacesUtils.history.clear(); await PlacesUtils.history.clear();
await Services.search.removeEngine(testEngine); await Services.search.removeEngine(testEngine);
await SpecialPowers.popPrefEnv();
}); });
add_task(async function tabNoSearchStringSearchMode() { add_task(async function tabNoSearchStringSearchMode() {
info( info(
"Tab through the toolbar when refocusing a Urlbar in search mode with the keyboard." "Tab through the toolbar when refocusing a Urlbar in search mode with the keyboard."
); );
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await UrlbarTestUtils.promiseAutocompleteResultPopup({ await UrlbarTestUtils.promiseAutocompleteResultPopup({
window, window,
value: "", value: "",
@ -261,7 +248,6 @@ add_task(async function tabNoSearchStringSearchMode() {
}); });
await UrlbarTestUtils.exitSearchMode(window); await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window); await UrlbarTestUtils.promisePopupClose(window);
await SpecialPowers.popPrefEnv();
}); });
async function expectTabThroughResults(options = { reverse: false }) { async function expectTabThroughResults(options = { reverse: false }) {

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

@ -22,8 +22,6 @@ add_task(async function setup() {
await PlacesUtils.history.clear(); await PlacesUtils.history.clear();
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
// Disable onboarding results for general tests. They are enabled in tests // Disable onboarding results for general tests. They are enabled in tests
// that specifically address onboarding. // that specifically address onboarding.
["browser.urlbar.tabToSearch.onboard.interactionsLeft", 0], ["browser.urlbar.tabToSearch.onboard.interactionsLeft", 0],

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

@ -23,14 +23,6 @@ if (AppConstants.platform == "macosx") {
} }
add_task(async function init() { add_task(async function init() {
// This test requires update2. See also browser_tokenAlias_legacy.js.
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
// Add a default engine with suggestions, to avoid hitting the network when // Add a default engine with suggestions, to avoid hitting the network when
// fetching them. // fetching them.
let defaultEngine = await SearchTestUtils.promiseNewSearchEngine( let defaultEngine = await SearchTestUtils.promiseNewSearchEngine(

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

@ -116,49 +116,8 @@ const tests = [
}; };
}, },
async function(win) {
info("Type something, click one-off. Update2 disabled.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
win.gURLBar.select();
let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window: win,
value: "moz",
fireInputEvent: true,
});
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }, win);
UrlbarTestUtils.getOneOffSearchButtons(win).selectedButton.click();
await promise;
await SpecialPowers.popPrefEnv();
return {
category: "urlbar",
method: "engagement",
object: "click",
value: "typed",
extra: {
elapsed: val => parseInt(val) > 0,
numChars: "3",
numWords: "1",
selIndex: "0",
selType: "oneoff",
provider: "HeuristicFallback",
},
};
},
async function(win) { async function(win) {
info("Type something, click one-off and press enter."); info("Type something, click one-off and press enter.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
win.gURLBar.select(); win.gURLBar.select();
let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser); let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
await UrlbarTestUtils.promiseAutocompleteResultPopup({ await UrlbarTestUtils.promiseAutocompleteResultPopup({
@ -180,7 +139,6 @@ const tests = [
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise; await promise;
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "engagement", method: "engagement",
@ -197,52 +155,10 @@ const tests = [
}; };
}, },
async function(win) {
info("Type something, select one-off, Enter. Update2 disabled.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
win.gURLBar.select();
let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window: win,
value: "moz",
fireInputEvent: true,
});
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }, win);
Assert.ok(UrlbarTestUtils.getOneOffSearchButtons(win).selectedButton);
EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise;
await SpecialPowers.popPrefEnv();
return {
category: "urlbar",
method: "engagement",
object: "enter",
value: "typed",
extra: {
elapsed: val => parseInt(val) > 0,
numChars: "3",
numWords: "1",
selIndex: "0",
selType: "oneoff",
provider: "HeuristicFallback",
},
};
},
async function(win) { async function(win) {
info( info(
"Type something, select one-off with enter, and select result with enter." "Type something, select one-off with enter, and select result with enter."
); );
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
win.gURLBar.select(); win.gURLBar.select();
let searchPromise = UrlbarTestUtils.promiseSearchComplete(win); let searchPromise = UrlbarTestUtils.promiseSearchComplete(win);
@ -262,7 +178,6 @@ const tests = [
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise; await promise;
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "engagement", method: "engagement",
@ -558,6 +473,7 @@ const tests = [
} }
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise; await promise;
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "engagement", method: "engagement",
@ -574,50 +490,8 @@ const tests = [
}; };
}, },
async function(win) {
info("Type @, Enter on a keywordoffer. Update 2 disabled.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
win.gURLBar.select();
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window: win,
value: "@",
fireInputEvent: true,
});
while (win.gURLBar.untrimmedValue != `${TEST_ENGINE_ALIAS} `) {
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
}
EventUtils.synthesizeKey("VK_RETURN", {}, win);
await UrlbarTestUtils.promiseSearchComplete(win);
await SpecialPowers.popPrefEnv();
return {
category: "urlbar",
method: "engagement",
object: "enter",
value: "typed",
extra: {
elapsed: val => parseInt(val) > 0,
numChars: "1",
numWords: "1",
selIndex: val => parseInt(val) > 0,
selType: "keywordoffer",
provider: "TokenAliasEngines",
},
};
},
async function(win) { async function(win) {
info("Type @, enter on a keywordoffer, then search and press enter."); info("Type @, enter on a keywordoffer, then search and press enter.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
win.gURLBar.select(); win.gURLBar.select();
await UrlbarTestUtils.promiseAutocompleteResultPopup({ await UrlbarTestUtils.promiseAutocompleteResultPopup({
window: win, window: win,
@ -640,7 +514,6 @@ const tests = [
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise; await promise;
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "engagement", method: "engagement",
@ -659,13 +532,6 @@ const tests = [
async function(win) { async function(win) {
info("Type an @alias, then space, then search and press enter."); info("Type an @alias, then space, then search and press enter.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
const alias = "testalias"; const alias = "testalias";
let aliasEngine = await Services.search.addEngineWithDetails("AliasTest", { let aliasEngine = await Services.search.addEngineWithDetails("AliasTest", {
alias, alias,
@ -692,7 +558,6 @@ const tests = [
await promise; await promise;
await Services.search.removeEngine(aliasEngine); await Services.search.removeEngine(aliasEngine);
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "engagement", method: "engagement",
@ -851,7 +716,6 @@ const tests = [
await UrlbarTestUtils.promisePopupOpen(win, () => { await UrlbarTestUtils.promisePopupOpen(win, () => {
win.document.getElementById("Browser:OpenLocation").doCommand(); win.document.getElementById("Browser:OpenLocation").doCommand();
}); });
await SpecialPowers.popPrefEnv();
await UrlbarTestUtils.promiseSearchComplete(win); await UrlbarTestUtils.promiseSearchComplete(win);
while (win.gURLBar.untrimmedValue != "http://example.org/") { while (win.gURLBar.untrimmedValue != "http://example.org/") {
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win); EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
@ -882,7 +746,6 @@ const tests = [
await UrlbarTestUtils.promisePopupOpen(win, () => { await UrlbarTestUtils.promisePopupOpen(win, () => {
win.document.getElementById("Browser:OpenLocation").doCommand(); win.document.getElementById("Browser:OpenLocation").doCommand();
}); });
await SpecialPowers.popPrefEnv();
await UrlbarTestUtils.promiseSearchComplete(win); await UrlbarTestUtils.promiseSearchComplete(win);
while (win.gURLBar.untrimmedValue != "http://example.com/") { while (win.gURLBar.untrimmedValue != "http://example.com/") {
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win); EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
@ -1012,12 +875,6 @@ const tests = [
async function(win) { async function(win) {
info("Open search mode with a keyboard shortcut."); info("Open search mode with a keyboard shortcut.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
let defaultEngine = await Services.search.getDefault(); let defaultEngine = await Services.search.getDefault();
win.gURLBar.select(); win.gURLBar.select();
EventUtils.synthesizeKey("k", { accelKey: true }); EventUtils.synthesizeKey("k", { accelKey: true });
@ -1037,7 +894,6 @@ const tests = [
EventUtils.synthesizeKey("VK_RETURN", {}, win); EventUtils.synthesizeKey("VK_RETURN", {}, win);
await promise; await promise;
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "engagement", method: "engagement",
@ -1337,12 +1193,6 @@ const tests = [
async function(win) { async function(win) {
info("Enter search mode from Top Sites."); info("Enter search mode from Top Sites.");
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
await updateTopSites(sites => true, /* enableSearchShorcuts */ true); await updateTopSites(sites => true, /* enableSearchShorcuts */ true);
win.gURLBar.value = ""; win.gURLBar.value = "";
@ -1377,7 +1227,6 @@ const tests = [
win.gURLBar.blur(); win.gURLBar.blur();
}); });
await SpecialPowers.popPrefEnv();
return { return {
category: "urlbar", category: "urlbar",
method: "abandonment", method: "abandonment",

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

@ -242,12 +242,6 @@ add_task(async function test_simpleQuery() {
}); });
add_task(async function test_searchMode_enter() { add_task(async function test_searchMode_enter() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
Services.telemetry.clearEvents(); Services.telemetry.clearEvents();
@ -326,217 +320,11 @@ add_task(async function test_searchMode_enter() {
); );
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
});
// This subtest can be removed with the update2 pref.
add_task(async function test_searchAlias_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
Services.telemetry.clearScalars();
Services.telemetry.clearEvents();
let resultIndexHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_INDEX"
);
let resultTypeHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_TYPE_2"
);
let resultIndexByTypeHist = TelemetryTestUtils.getAndClearKeyedHistogram(
"FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE_2"
);
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD"
);
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
info("Search using a search alias.");
let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await searchInAwesomebar("mozalias query");
EventUtils.synthesizeKey("KEY_Enter");
await p;
// Check if the scalars contain the expected values.
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
TelemetryTestUtils.assertKeyedScalar(
scalars,
SCALAR_URLBAR,
"search_alias",
1
);
Assert.equal(
Object.keys(scalars[SCALAR_URLBAR]).length,
1,
"This search must only increment one entry in the scalar."
);
// Also check events.
TelemetryTestUtils.assertEvents(
[
[
"navigation",
"search",
"urlbar",
"alias",
{ engine: "other-MozSearch" },
],
],
{ category: "navigation", method: "search" }
);
// Check the histograms as well.
TelemetryTestUtils.assertHistogram(resultIndexHist, 0, 1);
TelemetryTestUtils.assertHistogram(
resultTypeHist,
UrlbarUtils.SELECTED_RESULT_TYPES.searchengine,
1
);
TelemetryTestUtils.assertKeyedHistogramValue(
resultIndexByTypeHist,
"searchengine",
0,
1
);
TelemetryTestUtils.assertHistogram(
resultMethodHist,
UrlbarTestUtils.SELECTED_RESULT_METHODS.enter,
1
);
BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
});
// Performs a search using the first result, a one-off button, and the Return
// (Enter) key.
// This subtest can be removed with the update2 pref.
add_task(async function test_oneOff_enter_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
Services.telemetry.clearScalars();
Services.telemetry.clearEvents();
let resultIndexHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_INDEX"
);
let resultTypeHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_TYPE_2"
);
let resultIndexByTypeHist = TelemetryTestUtils.getAndClearKeyedHistogram(
"FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE_2"
);
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD"
);
let search_hist = TelemetryTestUtils.getAndClearKeyedHistogram(
"SEARCH_COUNTS"
);
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
info("Perform a one-off search using the first engine. Update 2 disabled.");
let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await searchInAwesomebar("query");
info("Pressing Alt+Down to take us to the first one-off engine.");
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
EventUtils.synthesizeKey("KEY_Enter");
await p;
// Check if the scalars contain the expected values.
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
TelemetryTestUtils.assertKeyedScalar(
scalars,
SCALAR_URLBAR,
"search_oneoff",
1
);
Assert.equal(
Object.keys(scalars[SCALAR_URLBAR]).length,
1,
"This search must only increment one entry in the scalar."
);
// SEARCH_COUNTS should be incremented, but only the urlbar source since an
// internal @search keyword was not used.
TelemetryTestUtils.assertKeyedHistogramSum(
search_hist,
"other-MozSearch.urlbar",
1
);
TelemetryTestUtils.assertKeyedHistogramSum(
search_hist,
"other-MozSearch.alias",
undefined
);
// Also check events.
TelemetryTestUtils.assertEvents(
[
[
"navigation",
"search",
"urlbar",
"oneoff",
{ engine: "other-MozSearch" },
],
],
{ category: "navigation", method: "search" }
);
// Check the histograms as well.
TelemetryTestUtils.assertHistogram(resultIndexHist, 0, 1);
TelemetryTestUtils.assertHistogram(
resultTypeHist,
UrlbarUtils.SELECTED_RESULT_TYPES.searchengine,
1
);
TelemetryTestUtils.assertKeyedHistogramValue(
resultIndexByTypeHist,
"searchengine",
0,
1
);
TelemetryTestUtils.assertHistogram(
resultMethodHist,
UrlbarTestUtils.SELECTED_RESULT_METHODS.enter,
1
);
BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
}); });
// Performs a search using the first result, a one-off button, and the Return // Performs a search using the first result, a one-off button, and the Return
// (Enter) key. // (Enter) key.
add_task(async function test_oneOff_enter() { add_task(async function test_oneOff_enter() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
Services.telemetry.clearEvents(); Services.telemetry.clearEvents();
@ -646,67 +434,12 @@ add_task(async function test_oneOff_enter() {
); );
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
});
// Performs a search using the second result, a one-off button, and the Return
// (Enter) key. This only tests the FX_URLBAR_SELECTED_RESULT_METHOD histogram
// since test_oneOff_enter covers everything else.
// This subtest can be removed with the update2 pref.
add_task(async function test_oneOff_enterSelection_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD"
);
await withNewSearchEngine(async function() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
info(
"Type a query. Suggestions should be generated by the test engine. Update2 disabled."
);
let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await searchInAwesomebar("query");
info(
"Select the second result, press Alt+Down to take us to the first one-off engine."
);
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
EventUtils.synthesizeKey("KEY_Enter");
await p;
TelemetryTestUtils.assertHistogram(
resultMethodHist,
UrlbarTestUtils.SELECTED_RESULT_METHODS.arrowEnterSelection,
1
);
BrowserTestUtils.removeTab(tab);
});
await SpecialPowers.popPrefEnv();
}); });
// Performs a search using the second result, a one-off button, and the Return // Performs a search using the second result, a one-off button, and the Return
// (Enter) key. This only tests the FX_URLBAR_SELECTED_RESULT_METHOD histogram // (Enter) key. This only tests the FX_URLBAR_SELECTED_RESULT_METHOD histogram
// since test_oneOff_enter covers everything else. // since test_oneOff_enter covers everything else.
add_task(async function test_oneOff_enterSelection() { add_task(async function test_oneOff_enterSelection() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram( let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD" "FX_URLBAR_SELECTED_RESULT_METHOD"
@ -750,61 +483,12 @@ add_task(async function test_oneOff_enterSelection() {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
}); });
await SpecialPowers.popPrefEnv();
});
// Performs a search using a click on a one-off button. This only tests the
// FX_URLBAR_SELECTED_RESULT_METHOD histogram since test_oneOff_enter covers
// everything else.
// This subtest can be removed with the update2 pref.
add_task(async function test_oneOff_click_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD"
);
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
info("Type a query.");
let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
await searchInAwesomebar("query");
info("Click the first one-off button. Update2 disabled");
UrlbarTestUtils.getOneOffSearchButtons(window)
.getSelectableButtons(false)[0]
.click();
await p;
TelemetryTestUtils.assertHistogram(
resultMethodHist,
UrlbarTestUtils.SELECTED_RESULT_METHODS.click,
1
);
BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
}); });
// Performs a search using a click on a one-off button. This only tests the // Performs a search using a click on a one-off button. This only tests the
// FX_URLBAR_SELECTED_RESULT_METHOD histogram since test_oneOff_enter covers // FX_URLBAR_SELECTED_RESULT_METHOD histogram since test_oneOff_enter covers
// everything else. // everything else.
add_task(async function test_oneOff_click() { add_task(async function test_oneOff_click() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram( let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
@ -846,7 +530,6 @@ add_task(async function test_oneOff_click() {
); );
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
}); });
// Clicks the first suggestion offered by the test search engine. // Clicks the first suggestion offered by the test search engine.
@ -1046,12 +729,6 @@ add_task(async function test_suggestion_enterSelection() {
// Clicks the first suggestion offered by the test search engine when in search // Clicks the first suggestion offered by the test search engine when in search
// mode. // mode.
add_task(async function test_searchmode_suggestion_click() { add_task(async function test_searchmode_suggestion_click() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
Services.telemetry.clearEvents(); Services.telemetry.clearEvents();
@ -1147,7 +824,6 @@ add_task(async function test_searchmode_suggestion_click() {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
}); });
await SpecialPowers.popPrefEnv();
}); });
// Selects and presses the Return (Enter) key on the first suggestion offered by // Selects and presses the Return (Enter) key on the first suggestion offered by
@ -1155,12 +831,6 @@ add_task(async function test_searchmode_suggestion_click() {
// FX_URLBAR_SELECTED_RESULT_METHOD histogram since // FX_URLBAR_SELECTED_RESULT_METHOD histogram since
// test_searchmode_suggestion_click covers everything else. // test_searchmode_suggestion_click covers everything else.
add_task(async function test_searchmode_suggestion_arrowEnterSelection() { add_task(async function test_searchmode_suggestion_arrowEnterSelection() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram( let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD" "FX_URLBAR_SELECTED_RESULT_METHOD"
@ -1190,18 +860,11 @@ add_task(async function test_searchmode_suggestion_arrowEnterSelection() {
); );
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
}); });
await SpecialPowers.popPrefEnv();
}); });
// Selects through tab and presses the Return (Enter) key on the first // Selects through tab and presses the Return (Enter) key on the first
// suggestion offered by the test search engine in search mode. // suggestion offered by the test search engine in search mode.
add_task(async function test_suggestion_tabEnterSelection() { add_task(async function test_suggestion_tabEnterSelection() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram( let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD" "FX_URLBAR_SELECTED_RESULT_METHOD"
@ -1232,18 +895,11 @@ add_task(async function test_suggestion_tabEnterSelection() {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
}); });
await SpecialPowers.popPrefEnv();
}); });
// Selects through code and presses the Return (Enter) key on the first // Selects through code and presses the Return (Enter) key on the first
// suggestion offered by the test search engine in search mode. // suggestion offered by the test search engine in search mode.
add_task(async function test_suggestion_enterSelection() { add_task(async function test_suggestion_enterSelection() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
Services.telemetry.clearScalars(); Services.telemetry.clearScalars();
let resultMethodHist = TelemetryTestUtils.getAndClearHistogram( let resultMethodHist = TelemetryTestUtils.getAndClearHistogram(
"FX_URLBAR_SELECTED_RESULT_METHOD" "FX_URLBAR_SELECTED_RESULT_METHOD"
@ -1274,7 +930,6 @@ add_task(async function test_suggestion_enterSelection() {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
}); });
await SpecialPowers.popPrefEnv();
}); });
// Clicks a form history result. // Clicks a form history result.

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

@ -85,8 +85,6 @@ function assertSearchModeScalars(entry, engineOrSource, resultIndex = -1) {
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
set: [ set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
// Disable tab-to-search onboarding results for general tests. They are // Disable tab-to-search onboarding results for general tests. They are
// enabled in tests that specifically address onboarding. // enabled in tests that specifically address onboarding.
["browser.urlbar.tabToSearch.onboard.interactionsLeft", 0], ["browser.urlbar.tabToSearch.onboard.interactionsLeft", 0],

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

@ -308,13 +308,6 @@ add_task(async function test_about_newtab() {
}); });
add_task(async function test_urlbar_oneOff_click() { add_task(async function test_urlbar_oneOff_click() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", true],
["browser.urlbar.update2.oneOffsRefresh", true],
],
});
let tab = await BrowserTestUtils.openNewForegroundTab( let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser, gBrowser,
"about:blank" "about:blank"
@ -355,59 +348,6 @@ add_task(async function test_urlbar_oneOff_click() {
BrowserTestUtils.removeTab(tab); BrowserTestUtils.removeTab(tab);
gRequests = []; gRequests = [];
await SpecialPowers.popPrefEnv();
});
add_task(async function test_urlbar_oneOff_click_legacy() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.urlbar.update2", false],
["browser.urlbar.update2.oneOffsRefresh", false],
],
});
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
info("Type a query.");
let promiseLoad = BrowserTestUtils.waitForDocLoadAndStopIt(
"https://mochi.test:8888/browser/browser/components/search/test/browser/?search=query&foo=1",
tab
);
await searchInAwesomebar("query");
info("Click the first one-off button.");
UrlbarTestUtils.getOneOffSearchButtons(window)
.getSelectableButtons(false)[0]
.click();
await promiseLoad;
await BrowserTestUtils.waitForCondition(
() => gRequests.length == 1,
"Should have received an attribution submission"
);
Assert.equal(
gRequests[0].getHeader("X-Region"),
Region.home,
"Should have set the region correctly"
);
Assert.equal(
gRequests[0].getHeader("X-Source"),
"searchurl",
"Should have set the source correctly"
);
Assert.equal(
gRequests[0].getHeader("X-Target-url"),
"https://mochi.test:8888/browser/browser/components/search/test/browser/?foo=1",
"Should have set the target url correctly and stripped the search terms"
);
BrowserTestUtils.removeTab(tab);
gRequests = [];
await SpecialPowers.popPrefEnv();
}); });
add_task(async function test_searchbar_oneOff_click() { add_task(async function test_searchbar_oneOff_click() {