Bug 1964507 - Only offer "Add Search Engine" for GET forms. r=search-reviewers,Standard8

Differential Revision: https://phabricator.services.mozilla.com/D250020
This commit is contained in:
Moritz Beier
2025-05-20 09:27:11 +00:00
committed by mbeier@mozilla.com
parent 440978fd41
commit 108352951c
2 changed files with 8 additions and 26 deletions

View File

@@ -27,18 +27,6 @@ const TESTS = [
submission: "kitten",
expected: "https://example.org/search?q=kitten&utf8%E2%9C%93=%E2%9C%93",
},
{
action: "/search",
method: "POST",
charset: "UTF-8",
fields: [
{ name: "q", value: "Some initial value", main: true },
{ name: "utf8✓", value: "✓", hidden: true },
],
submission: "kitten",
expected: "https://example.org/search",
expectedPost: "q=kitten&utf8%E2%9C%93=%E2%9C%93",
},
{
action: "/search",
method: "GET",
@@ -51,18 +39,6 @@ const TESTS = [
submission: "caff\u00E8+",
expected: "https://example.org/search?q=caff%E8%2B&cb=true",
},
{
action: "/search",
method: "POST",
charset: "windows-1252",
fields: [
{ name: "q", main: true },
{ name: "foo", value: "bar" },
],
submission: "caff\u00E8+",
expected: "https://example.org/search",
expectedPost: "q=caff%E8%2B&foo=bar",
},
];
const URL_UTF_8 =
@@ -249,6 +225,10 @@ add_task(async function testSearchFieldDetection() {
Assert.equal(isSearchField, false, "Method=dialog means no search field");
form.method = "POST";
isSearchField = SpellCheckHelper.isTargetASearchEngineField(input, window);
Assert.equal(isSearchField, false, "Method=post means no search field");
form.method = "GET";
delete input.removeAttribute("name");
isSearchField = SpellCheckHelper.isTargetASearchEngineField(input, window);

View File

@@ -500,8 +500,10 @@ export var SpellCheckHelper = {
return (
// Forms without an explicit action often don't work, see Bug 1960237.
form.hasAttribute("action") &&
// The only other method is dialog.
(method == "GET" || method == "POST") &&
// The other methods are post and dialog.
// Post forms are rarely search forms, see discussion in Bug 1964507.
// Dialog forms are not supported for obvious reasons.
method == "GET" &&
// SearchEngine objects currently only support urlencoded requests.
form.enctype == "application/x-www-form-urlencoded" &&
// Don't allow forms with file inputs.