mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1181645 - Default invalid or empty purpose in getSubmission to searchbar, r=florian.
--HG-- extra : rebase_source : 45a9be2fc882b6158213b151c8e156f8d8bbeb4e
This commit is contained in:
parent
a9e6a477eb
commit
9813c51030
@ -18,7 +18,7 @@ function test() {
|
||||
|
||||
// Test search URLs (including purposes).
|
||||
url = engine.getSubmission("foo").uri.spec;
|
||||
is(url, base, "Check search URL for 'foo'");
|
||||
is(url, base + "&form=MOZSBR", "Check search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "contextmenu").uri.spec;
|
||||
is(url, base + "&form=MOZCON", "Check context menu search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "keyword").uri.spec;
|
||||
@ -39,7 +39,7 @@ function test() {
|
||||
name: "Bing",
|
||||
alias: null,
|
||||
description: "Bing. Search by Microsoft.",
|
||||
searchForm: "https://www.bing.com/search?q=&pc=MOZI",
|
||||
searchForm: "https://www.bing.com/search?q=&pc=MOZI&form=MOZSBR",
|
||||
hidden: false,
|
||||
wrappedJSObject: {
|
||||
queryCharset: "UTF-8",
|
||||
|
@ -23,7 +23,7 @@ function test() {
|
||||
|
||||
// Test search URLs (including purposes).
|
||||
url = engine.getSubmission("foo").uri.spec;
|
||||
is(url, base, "Check search URL for 'foo'");
|
||||
is(url, base + "&form=MOZSBR", "Check search URL for 'foo'");
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
@ -18,7 +18,21 @@ function test() {
|
||||
|
||||
// Test search URLs (including purposes).
|
||||
url = engine.getSubmission("foo").uri.spec;
|
||||
is(url, base, "Check search URL for 'foo'");
|
||||
is(url, base + "&hsimp=yhs-001", "Check search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "searchbar").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-001", "Check search bar search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "keyword").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-002", "Check keyword search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "homepage").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-003", "Check homepage search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "newtab").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-004", "Check newtab search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "contextmenu").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-005", "Check context menu search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "system").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-007", "Check system search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "invalid").uri.spec;
|
||||
is(url, base + "&hsimp=yhs-001", "Check invalid URL for 'foo'");
|
||||
|
||||
// Check search suggestion URL.
|
||||
url = engine.getSubmission("foo", "application/x-suggestions+json").uri.spec;
|
||||
@ -29,7 +43,7 @@ function test() {
|
||||
name: "Yahoo",
|
||||
alias: null,
|
||||
description: "Yahoo Search",
|
||||
searchForm: "https://search.yahoo.com/yhs/search?p=&ei=UTF-8&hspart=mozilla",
|
||||
searchForm: "https://search.yahoo.com/yhs/search?p=&ei=UTF-8&hspart=mozilla&hsimp=yhs-001",
|
||||
hidden: false,
|
||||
wrappedJSObject: {
|
||||
queryCharset: "UTF-8",
|
||||
|
@ -23,7 +23,7 @@ function test() {
|
||||
|
||||
// Test search URLs (including purposes).
|
||||
url = engine.getSubmission("foo").uri.spec;
|
||||
is(url, base, "Check search URL for 'foo'");
|
||||
is(url, base + "&hsimp=yhs-001", "Check search URL for 'foo'");
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<Param name="oe" value="utf-8"/>
|
||||
<Param name="client" value="firefox-b"/>
|
||||
<MozParam name="client" condition="purpose" purpose="keyword" value="firefox-b-ab"/>
|
||||
<MozParam name="client" condition="purpose" purpose="searchbar" value="firefox-b"/>
|
||||
</Url>
|
||||
</SearchPlugin>
|
||||
|
@ -1138,12 +1138,11 @@ EngineURL.prototype = {
|
||||
|
||||
getSubmission: function SRCH_EURL_getSubmission(aSearchTerms, aEngine, aPurpose) {
|
||||
var url = ParamSubstitution(this.template, aSearchTerms, aEngine);
|
||||
// Default to an empty string if the purpose is not provided so that default purpose params
|
||||
// (purpose="") work consistently rather than having to define "null" and "" purposes.
|
||||
var purpose = aPurpose || "";
|
||||
// Default to searchbar if the purpose is not provided
|
||||
var purpose = aPurpose || "searchbar";
|
||||
|
||||
// If the 'system' purpose isn't defined in the plugin, fallback to 'searchbar'.
|
||||
if (purpose == "system" && !this.params.some(p => p.purpose == "system"))
|
||||
// If a particular purpose isn't defined in the plugin, fallback to 'searchbar'.
|
||||
if (!this.params.some(p => p.purpose !== undefined && p.purpose == purpose))
|
||||
purpose = "searchbar";
|
||||
|
||||
// Create an application/x-www-form-urlencoded representation of our params
|
||||
|
@ -16,8 +16,8 @@
|
||||
</Url>
|
||||
<Url type="application/x-moz-default-purpose" method="GET" template="http://www.google.com/search" resultdomain="purpose.google.com">
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
<!-- MozParam with a default value if purpose is not specified -->
|
||||
<MozParam name="channel" condition="purpose" purpose="" value="none"/>
|
||||
<!-- MozParam uses searchbar if purpose is not specified -->
|
||||
<MozParam name="channel" condition="purpose" purpose="searchbar" value="ffsb"/>
|
||||
<MozParam name="channel" condition="purpose" purpose="contextmenu" value="rcs"/>
|
||||
<MozParam name="channel" condition="purpose" purpose="keyword" value="fflb"/>
|
||||
</Url>
|
||||
|
@ -43,12 +43,13 @@ add_task(function* test_purpose() {
|
||||
|
||||
// Tests for a param that varies with a purpose but has a default value.
|
||||
base = "http://www.google.com/search?q=foo";
|
||||
check_submission("&channel=none", "foo", "application/x-moz-default-purpose");
|
||||
check_submission("&channel=none", "foo", "application/x-moz-default-purpose", null);
|
||||
check_submission("&channel=none", "foo", "application/x-moz-default-purpose", "");
|
||||
check_submission("&channel=ffsb", "foo", "application/x-moz-default-purpose");
|
||||
check_submission("&channel=ffsb", "foo", "application/x-moz-default-purpose", null);
|
||||
check_submission("&channel=ffsb", "foo", "application/x-moz-default-purpose", "");
|
||||
check_submission("&channel=rcs", "foo", "application/x-moz-default-purpose", "contextmenu");
|
||||
check_submission("&channel=fflb", "foo", "application/x-moz-default-purpose", "keyword");
|
||||
check_submission("", "foo", "application/x-moz-default-purpose", "invalid");
|
||||
check_submission("&channel=ffsb", "foo", "application/x-moz-default-purpose", "searchbar");
|
||||
check_submission("&channel=ffsb", "foo", "application/x-moz-default-purpose", "invalid");
|
||||
|
||||
// Tests for a purpose on the search form (ie. empty query).
|
||||
engine = Services.search.getEngineByName("engine-rel-searchform-purpose");
|
||||
|
Loading…
Reference in New Issue
Block a user