Bug 1730218 - Fix suggest_url in policies. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D131291
This commit is contained in:
Mike Kaply 2021-11-29 17:27:40 +00:00
parent 4c184ca81b
commit 342e6a407b
2 changed files with 40 additions and 2 deletions

View File

@ -1962,7 +1962,7 @@ var Policies = {
newEngine.Method == "POST"
? newEngine.PostData
: undefined,
suggestUrlGetParams: newEngine.SuggestURLTemplate,
suggest_url: newEngine.SuggestURLTemplate,
},
},
};

View File

@ -349,7 +349,7 @@ add_task(async function test_install_with_encoding() {
is(
Services.search.getEngineByName("Encoding"),
null,
'Engine "Foo" should not be present when test starts'
'Engine "Encoding" should not be present when test starts'
);
await setupPolicyEngineWithJson({
@ -430,3 +430,41 @@ add_task(async function test_install_and_update() {
await Services.search.removeEngine(engine);
EnterprisePolicyTesting.resetRunOnceState();
});
add_task(async function test_install_with_suggest() {
// Make sure we are starting in an expected state to avoid false positive
// test results.
is(
Services.search.getEngineByName("Suggest"),
null,
'Engine "Suggest" should not be present when test starts'
);
await setupPolicyEngineWithJson({
policies: {
SearchEngines: {
Add: [
{
Name: "Suggest",
URLTemplate: "http://example.com/?q={searchTerms}",
SuggestURLTemplate: "http://suggest.example.com/?q={searchTerms}",
},
],
},
},
});
// Get in line, because the Search policy callbacks are async.
await TestUtils.waitForTick();
let engine = Services.search.getEngineByName("Suggest");
is(
engine.getSubmission("test", "application/x-suggestions+json").uri.spec,
"http://suggest.example.com/?q=test",
"Updated Submission URL should be correct."
);
// Clean up
await Services.search.removeEngine(engine);
EnterprisePolicyTesting.resetRunOnceState();
});