forked from mozilla/gecko-dev
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1660530 - Transition the docshell URIFixup tests to work with the…
… modern search engine configuration. r=mak Differential Revision: https://phabricator.services.mozilla.com/D87894
- Loading branch information
Showing
4 changed files
with
92 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,81 @@ | ||
/* 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/. */ | ||
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); | ||
|
||
var { XPCOMUtils } = ChromeUtils.import( | ||
"resource://gre/modules/XPCOMUtils.jsm" | ||
); | ||
|
||
XPCOMUtils.defineLazyModuleGetters(this, { | ||
AddonTestUtils: "resource://testing-common/AddonTestUtils.jsm", | ||
SearchUtils: "resource://gre/modules/SearchUtils.jsm", | ||
SearchTestUtils: "resource://testing-common/SearchTestUtils.jsm", | ||
Services: "resource://gre/modules/Services.jsm", | ||
}); | ||
|
||
var dirSvc = Services.dirSvc; | ||
var profileDir = do_get_profile(); | ||
|
||
const kSearchEngineID = "test_urifixup_search_engine"; | ||
const kSearchEngineURL = "https://www.example.org/?search={searchTerms}"; | ||
const kPrivateSearchEngineID = "test_urifixup_search_engine_private"; | ||
const kPrivateSearchEngineURL = | ||
"https://www.example.org/?private={searchTerms}"; | ||
|
||
const SEARCH_CONFIG = [ | ||
{ | ||
appliesTo: [ | ||
{ | ||
included: { | ||
everywhere: true, | ||
}, | ||
}, | ||
], | ||
default: "yes", | ||
webExtension: { | ||
id: "fixup_search@search.mozilla.org", | ||
}, | ||
}, | ||
]; | ||
|
||
async function setupSearchService() { | ||
SearchTestUtils.init(Assert, registerCleanupFunction); | ||
|
||
Services.prefs.setBoolPref("browser.search.modernConfig", true); | ||
AddonTestUtils.init(this); | ||
AddonTestUtils.overrideCertDB(); | ||
AddonTestUtils.createAppInfo( | ||
"xpcshell@tests.mozilla.org", | ||
"XPCShell", | ||
"1", | ||
"42" | ||
); | ||
|
||
await SearchTestUtils.useTestEngines(".", null, SEARCH_CONFIG); | ||
await AddonTestUtils.promiseStartupManager(); | ||
await Services.search.init(); | ||
} | ||
|
||
async function addTestEngines() { | ||
// This is a hack, ideally we should be setting up a configuration with | ||
// built-in engines, but the `chrome_settings_overrides` section that | ||
// WebExtensions need is only defined for browser/ | ||
await Services.search.addPolicyEngine({ | ||
description: "urifixup search engine", | ||
chrome_settings_overrides: { | ||
search_provider: { | ||
name: "test_urifixup_search_engine", | ||
search_url: "https://www.example.org/?search={searchTerms}", | ||
}, | ||
}, | ||
}); | ||
await Services.search.addPolicyEngine({ | ||
description: "urifixup private search engine", | ||
chrome_settings_overrides: { | ||
search_provider: { | ||
name: "test_urifixup_search_engine_private", | ||
search_url: "https://www.example.org/?private={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
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