forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1790790 - Add Nimbus flag to control Search Private Default. r=St…
…andard8 Differential Revision: https://phabricator.services.mozilla.com/D157605
- Loading branch information
1 parent
fbd9515
commit 7c34f31
Showing
8 changed files
with
200 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
browser/components/search/test/browser/browser_defaultPrivate_nimbus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const { ExperimentAPI, NimbusFeatures } = ChromeUtils.import( | ||
"resource://nimbus/ExperimentAPI.jsm" | ||
); | ||
const { ExperimentFakes } = ChromeUtils.import( | ||
"resource://testing-common/NimbusTestUtils.jsm" | ||
); | ||
|
||
ChromeUtils.defineESModuleGetters(this, { | ||
SearchTestUtils: "resource://testing-common/SearchTestUtils.sys.mjs", | ||
}); | ||
|
||
const CONFIG_DEFAULT = [ | ||
{ | ||
webExtension: { id: "[email protected]" }, | ||
appliesTo: [{ included: { everywhere: true } }], | ||
default: "yes", | ||
}, | ||
{ | ||
webExtension: { id: "[email protected]" }, | ||
appliesTo: [ | ||
{ | ||
experiment: "testing", | ||
included: { everywhere: true }, | ||
}, | ||
], | ||
defaultPrivate: "yes", | ||
}, | ||
]; | ||
|
||
SearchTestUtils.init(this); | ||
|
||
add_setup(async () => { | ||
// Use engines in test directory | ||
let searchExtensions = getChromeDir(getResolvedURI(gTestPath)); | ||
searchExtensions.append("search-engines"); | ||
await SearchTestUtils.useMochitestEngines(searchExtensions); | ||
|
||
// Current default values. | ||
await SpecialPowers.pushPrefEnv({ | ||
set: [ | ||
["browser.search.separatePrivateDefault.ui.enabled", false], | ||
["browser.search.separatePrivateDefault.urlbarResult.enabled", false], | ||
["browser.search.separatePrivateDefault", true], | ||
["browser.urlbar.suggest.searches", true], | ||
], | ||
}); | ||
|
||
SearchTestUtils.useMockIdleService(); | ||
await SearchTestUtils.updateRemoteSettingsConfig(CONFIG_DEFAULT); | ||
|
||
registerCleanupFunction(async () => { | ||
let settingsWritten = SearchTestUtils.promiseSearchNotification( | ||
"write-settings-to-disk-complete" | ||
); | ||
await SearchTestUtils.updateRemoteSettingsConfig(); | ||
await settingsWritten; | ||
}); | ||
}); | ||
|
||
add_task(async function test_nimbus_experiment() { | ||
Assert.equal( | ||
Services.search.defaultPrivateEngine.name, | ||
"basic", | ||
"Should have basic as private default while not in experiment" | ||
); | ||
await ExperimentAPI.ready(); | ||
|
||
let reloadObserved = SearchTestUtils.promiseSearchNotification( | ||
"engines-reloaded" | ||
); | ||
|
||
let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({ | ||
featureId: "search", | ||
value: { | ||
seperatePrivateDefaultUIEnabled: true, | ||
sseperatePrivateDefaultUrlbarResultEnabled: false, | ||
experiment: "testing", | ||
}, | ||
}); | ||
await reloadObserved; | ||
Assert.equal( | ||
Services.search.defaultPrivateEngine.name, | ||
"private", | ||
"Should have private as private default while in experiment" | ||
); | ||
reloadObserved = SearchTestUtils.promiseSearchNotification( | ||
"engines-reloaded" | ||
); | ||
await doExperimentCleanup(); | ||
await reloadObserved; | ||
Assert.equal( | ||
Services.search.defaultPrivateEngine.name, | ||
"basic", | ||
"Should turn off private default and restore default engine after experiment" | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
browser/components/search/test/browser/search-engines/basic/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "basic", | ||
"manifest_version": 2, | ||
"version": "1.0", | ||
"description": "basic", | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]" | ||
} | ||
}, | ||
"hidden": true, | ||
"chrome_settings_overrides": { | ||
"search_provider": { | ||
"name": "basic", | ||
"search_url": "https://mochi.test:8888/browser/browser/components/search/test/browser/?search={searchTerms}&foo=1", | ||
"suggest_url": "https://mochi.test:8888/browser/browser/modules/test/browser/usageTelemetrySearchSuggestions.sjs?{searchTerms}" | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
browser/components/search/test/browser/search-engines/private/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "private", | ||
"manifest_version": 2, | ||
"version": "1.0", | ||
"description": "A test private engine", | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]" | ||
} | ||
}, | ||
"hidden": true, | ||
"chrome_settings_overrides": { | ||
"search_provider": { | ||
"name": "private", | ||
"search_url": "https://example.com", | ||
"suggest_url": "https://example.com?search={searchTerms}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,12 @@ search: | |
extraParams: | ||
type: json | ||
description: Query parameters values for search engine configurations. | ||
seperatePrivateDefaultUIEnabled: | ||
type: boolean | ||
description: Whether the UI for the separate private default feature is enabled. | ||
seperatePrivateDefaultUrlbarResultEnabled: | ||
type: boolean | ||
description: Whether the urlbar result for the separate private default is shown. | ||
urlbar: | ||
description: The Address Bar | ||
owner: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters