Commit d61834e5 authored by Mark Banner's avatar Mark Banner
Browse files

Bug 1545395 - Handle Search Engine urls properly where the search terms are in...

Bug 1545395 - Handle Search Engine urls properly where the search terms are in the url rather than as parameters. r=daleharvey

Differential Revision:

extra : moz-landing-system : lando
parent 38ce44ca
......@@ -195,3 +195,39 @@ add_task(async function test_extension_post_params() {
await ext1.unload();
add_task(async function test_extension_no_query_params() {
const ext1 = ExtensionTestUtils.loadExtension({
manifest: {
"chrome_settings_overrides": {
"search_provider": {
"name": "MozSearch",
"keyword": "MozSearch",
"search_url": "{searchTerms}",
"suggest_url": "{searchTerms}",
useAddonManager: "temporary",
await ext1.startup();
await AddonTestUtils.waitForSearchProviderStartup(ext1);
let engine ="MozSearch");
ok(engine, "Engine should exist.");
const encodedSubmissionURL = engine.getSubmission(kSearchTermIntl).uri.spec;
const testSubmissionURL = "" + encodeURIComponent(kSearchTermIntl);
equal(encodedSubmissionURL, testSubmissionURL, "Encoded UTF-8 URLs should match");
const expectedSuggestURL = "" + kSearchTerm;
let submissionSuggest = engine.getSubmission(kSearchTerm, URLTYPE_SUGGEST_JSON);
equal(submissionSuggest.uri.spec, expectedSuggestURL, "Suggest URLs should match");
await ext1.unload();
await delay();
engine ="MozSearch");
ok(!engine, "Engine should not exist");
......@@ -4057,7 +4057,9 @@ SearchService.prototype = {
description: extension.manifest.description,
searchForm: searchProvider.search_form,
template: searchProvider.search_url,
// AddonManager will sometimes encode the URL via `new URL()`. We want
// to ensure we're always dealing with decoded urls.
template: decodeURI(searchProvider.search_url),
searchGetParams: searchProvider.search_url_get_params,
searchPostParams: searchProvider.search_url_post_params,
iconURL: searchProvider.favicon_url || preferredIconUrl,
......@@ -4065,6 +4067,7 @@ SearchService.prototype = {
alias: searchProvider.keyword,
isBuiltin: extension.addonData.builtIn,
// suggest_url doesn't currently get encoded.
suggestURL: searchProvider.suggest_url,
suggestPostParams: searchProvider.suggest_url_post_params,
suggestGetParams: searchProvider.suggest_url_get_params,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment