Backed out changeset 16c09e5f2758 (bug 1380771) for failures in test_hasEngineWithURL.js and browser_ext_settings_overrides_search.js a=backout

MozReview-Commit-ID: 75JIIqWhS7W
This commit is contained in:
Wes Kocher 2017-08-11 15:53:50 -07:00
Родитель 722f78828d
Коммит d807031b06
4 изменённых файлов: 25 добавлений и 112 удалений

Просмотреть файл

@ -330,8 +330,6 @@ interface nsIBrowserSearchService : nsISupports
* @param iconURL
* Optional: A URL string pointing to the icon to be used to represent
* the engine.
* This is a jsval so that an object can be passed to replace the
* parameters below.
*
* @param alias
* Optional: A unique shortcut that can be used to retrieve the
@ -341,9 +339,8 @@ interface nsIBrowserSearchService : nsISupports
* Optional: a description of the search engine.
*
* @param method
* Optional: The HTTP request method used when submitting a search query.
* Case insensitive value of either "get" or "post".
* Defaults to "get".
* The HTTP request method used when submitting a search query.
* Must be a case insensitive value of either "get" or "post".
*
* @param url
* The URL to which search queries should be sent.
@ -351,29 +348,13 @@ interface nsIBrowserSearchService : nsISupports
*
* @param extensionID [optional]
* Optional: The correct extensionID if called by an add-on.
*
* Alternatively, all of these parameters except for name can be
* passed as an object in place of parameter two.
*
* Services.search.addEngineWithDetails("Example engine", {
* template: "http://example.com/?search={searchTerms}",
* description: "Example search engine description",
* suggestURL: http://example.com/?suggest={searchTerms},
* });
*
* Using this method, you can use a new parameter, suggestURL:
*
* @param suggestURL [optional]
* Optional: The URL to which search suggestion requests
* should be sent.
*
*/
void addEngineWithDetails(in AString name,
in jsval iconURL,
[optional] in AString alias,
[optional] in AString description,
[optional] in AString method,
[optional] in AString url,
in AString iconURL,
in AString alias,
in AString description,
in AString method,
in AString url,
[optional] in AString extensionID);
/**

Просмотреть файл

@ -1805,22 +1805,20 @@ Engine.prototype = {
/**
* Initialize this Engine object from a collection of metadata.
*/
_initFromMetadata: function SRCH_ENG_initMetaData(aName, aParams) {
_initFromMetadata: function SRCH_ENG_initMetaData(aName, aIconURL, aAlias,
aDescription, aMethod,
aTemplate, aExtensionID) {
ENSURE_WARN(!this._readOnly,
"Can't call _initFromMetaData on a readonly engine!",
Cr.NS_ERROR_FAILURE);
let method = aParams.method || "GET";
this._urls.push(new EngineURL(URLTYPE_SEARCH_HTML, method, aParams.template));
if (aParams.suggestURL) {
this._urls.push(new EngineURL(URLTYPE_SUGGEST_JSON, "GET", aParams.suggestURL));
}
this._urls.push(new EngineURL(URLTYPE_SEARCH_HTML, aMethod, aTemplate));
this._name = aName;
this.alias = aParams.alias;
this._description = aParams.description;
this._setIcon(aParams.iconURL, true);
this._extensionID = aParams.extensionID;
this.alias = aAlias;
this._description = aDescription;
this._setIcon(aIconURL, true);
this._extensionID = aExtensionID;
},
/**
@ -4010,37 +4008,25 @@ SearchService.prototype = {
return null;
},
addEngineWithDetails: function SRCH_SVC_addEWD(aName, iconURL, alias,
description, method,
template, extensionID) {
var params;
if (typeof arguments[1] == "object") {
params = iconURL;
} else {
params = {
iconURL,
alias,
description,
method,
template,
extensionID,
};
}
addEngineWithDetails: function SRCH_SVC_addEWD(aName, aIconURL, aAlias,
aDescription, aMethod,
aTemplate, aExtensionID) {
this._ensureInitialized();
if (!aName)
FAIL("Invalid name passed to addEngineWithDetails!");
if (!params.template)
if (!aMethod)
FAIL("Invalid method passed to addEngineWithDetails!");
if (!aTemplate)
FAIL("Invalid template passed to addEngineWithDetails!");
if (this._engines[aName])
FAIL("An engine with that name already exists!", Cr.NS_ERROR_FILE_ALREADY_EXISTS);
var engine = new Engine(sanitizeName(aName), false);
engine._initFromMetadata(aName, params);
engine._initFromMetadata(aName, aIconURL, aAlias, aDescription,
aMethod, aTemplate, aExtensionID);
engine._loadPath = "[other]addEngineWithDetails";
if (params.extensionID) {
engine._loadPath += ":" + params.extensionID;
if (aExtensionID) {
engine._loadPath += ":" + aExtensionID;
}
this._addEngineToStore(engine);
},

Просмотреть файл

@ -1,53 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const kSearchEngineID = "addEngineWithDetails_test_engine";
const kSearchEngineURL = "http://example.com/?search={searchTerms}";
const kSearchSuggestURL = "http://example.com/?suggest={searchTerms}";
const kIconURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";
const kDescription = "Test Description";
const kAlias = "alias_foo"
const kSearchTerm = "foo";
const kExtensionID = "test@example.com";
const URLTYPE_SUGGEST_JSON = "application/x-suggestions+json";
add_task(async function test_addEngineWithDetails() {
do_check_false(Services.search.isInitialized);
Services.prefs.getDefaultBranch(BROWSER_SEARCH_PREF)
.setBoolPref("reset.enabled", true);
await asyncInit();
Services.search.addEngineWithDetails(kSearchEngineID, {
template: kSearchEngineURL,
description: kDescription,
iconURL: kIconURL,
suggestURL: kSearchSuggestURL,
alias: "alias_foo",
extensionID: kExtensionID,
});
// An engine added with addEngineWithDetails should have a load path, even
// though we can't point to a specific file.
let engine = Services.search.getEngineByName(kSearchEngineID);
do_check_eq(engine.wrappedJSObject._loadPath, "[other]addEngineWithDetails:" + kExtensionID);
do_check_eq(engine.description, kDescription);
do_check_eq(engine.iconURI.spec, kIconURL);
do_check_eq(engine.alias, kAlias);
// Set the engine as default; this should set a loadPath verification hash,
// which should ensure we don't show the search reset prompt.
Services.search.currentEngine = engine;
let expectedURL = kSearchEngineURL.replace("{searchTerms}", kSearchTerm);
let submission =
Services.search.currentEngine.getSubmission(kSearchTerm, null, "searchbar");
do_check_eq(submission.uri.spec, expectedURL);
let expectedSuggestURL = kSearchSuggestURL.replace("{searchTerms}", kSearchTerm);
let submissionSuggest =
Services.search.currentEngine.getSubmission(kSearchTerm, URLTYPE_SUGGEST_JSON);
do_check_eq(submissionSuggest.uri.spec, expectedSuggestURL);
});

Просмотреть файл

@ -96,7 +96,6 @@ tags = addons
[test_svg_icon.js]
[test_searchReset.js]
[test_addEngineWithDetails.js]
[test_addEngineWithDetailsObject.js]
[test_addEngineWithExtensionID.js]
[test_chromeresource_icon1.js]
[test_chromeresource_icon2.js]