author | Harry Twyford <htwyford@mozilla.com> |
Tue, 04 Feb 2020 21:36:10 +0000 | |
changeset 512561 | 5bb0a38b301ec4854add76b8bf55b5b5b4ec63ef |
parent 512560 | 154889e40d83d6e999656e00316cee3e8fe18eb2 |
child 512562 | 03d54624d4f2f719067048ed30e99493e55a77a8 |
push id | 106481 |
push user | htwyford@mozilla.com |
push date | Wed, 05 Feb 2020 08:59:42 +0000 |
treeherder | autoland@5bb0a38b301e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | adw |
bugs | 1613048 |
milestone | 74.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/components/urlbar/UrlbarProviderSearchTips.jsm +++ b/browser/components/urlbar/UrlbarProviderSearchTips.jsm @@ -35,16 +35,23 @@ XPCOMUtils.defineLazyGetter(this, "logge XPCOMUtils.defineLazyServiceGetter( this, "updateManager", "@mozilla.org/updates/update-manager;1", "nsIUpdateManager" ); +XPCOMUtils.defineLazyPreferenceGetter( + this, + "cfrFeaturesUserPref", + "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", + true +); + // The possible tips to show. const TIPS = { NONE: "", ONBOARD: "onboard", REDIRECT: "redirect", }; // This maps engine names to regexes matching their homepages. We show the @@ -118,17 +125,21 @@ class ProviderSearchTips extends UrlbarP /** * Whether this provider should be invoked for the given context. * If this method returns false, the providers manager won't start a query * with this provider, to save on resources. * @param {UrlbarQueryContext} queryContext The query context object * @returns {boolean} Whether this provider should be invoked for the search. */ isActive(queryContext) { - return UrlbarPrefs.get("update1.searchTips") && this.currentTip; + return ( + UrlbarPrefs.get("update1.searchTips") && + this.currentTip && + cfrFeaturesUserPref + ); } /** * Gets the provider's priority. * @param {UrlbarQueryContext} queryContext The query context object * @returns {number} The provider's priority for the given query. */ getPriority(queryContext) { @@ -308,16 +319,20 @@ class ProviderSearchTips extends UrlbarP // Start a search. setTimeout(() => { if (this._maybeShowTipForUrlInstance != instance) { return; } this.currentTip = tip; + if (!this.isActive()) { + return; + } + let window = BrowserWindowTracker.getTopWindow(); window.gURLBar.search("", { focus: tip == TIPS.ONBOARD }); }, SHOW_TIP_DELAY_MS); } } function isBrowserShowingNotification() { let window = BrowserWindowTracker.getTopWindow();
--- a/browser/components/urlbar/tests/browser/browser_search_tips.js +++ b/browser/components/urlbar/tests/browser/browser_search_tips.js @@ -571,16 +571,45 @@ add_task(async function ignoreEndsEngage await EventUtils.synthesizeMouseAtCenter(spring, {}); }); Assert.ok( !UrlbarProviderSearchTips.showedTipInCurrentEngagement, "The engagement should have ended after the tip was ignored." ); }); }); + resetProvider(); +}); + +// Since we coupled the logic that decides whether to show the tip with our +// gURLBar.search call, we should make sure search isn't called when +// the conditions for a tip are met but the provider is disabled. +add_task(async function noActionWhenDisabled() { + await setDefaultEngine("Bing"); + await withDNSRedirect("www.bing.com", "/", async url => { + await checkTab(window, url, TIPS.REDIRECT); + }); + + await SpecialPowers.pushPrefEnv({ + set: [ + [ + "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features", + false, + ], + ], + }); + + await withDNSRedirect("www.bing.com", "/", async url => { + Assert.ok( + !UrlbarTestUtils.isPopupOpen(window), + "The UrlbarView should not be open." + ); + }); + + await SpecialPowers.popPrefEnv(); }); async function checkTip(win, expectedTip, closeView = true) { if (!expectedTip) { // Wait a bit for the tip to not show up. // eslint-disable-next-line mozilla/no-arbitrary-setTimeout await new Promise(resolve => setTimeout(resolve, 3 * SHOW_TIP_DELAY_MS)); Assert.ok(!win.gURLBar.view.isOpen);