зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1218324 - Correctly report when a search engine could not be installed due to an invalid format. r=florian
MozReview-Commit-ID: Cqw0uKDWguy --HG-- extra : rebase_source : 50f852a20e8e46500e7728d3ebdceca39f9784d0
This commit is contained in:
Родитель
be70ef51b5
Коммит
bdb3d1158d
|
@ -9,6 +9,7 @@ support-files =
|
|||
testEngine.xml
|
||||
testEngine_diacritics.xml
|
||||
testEngine_dupe.xml
|
||||
testEngine_missing_namespace.xml
|
||||
testEngine_mozsearch.xml
|
||||
tooManyEnginesOffered.html
|
||||
webapi.html
|
||||
|
|
|
@ -67,11 +67,12 @@ add_task(function* test_relative() {
|
|||
});
|
||||
|
||||
add_task(function* test_invalid() {
|
||||
gBrowser.selectedTab = AddSearchProvider("z://foobar");
|
||||
let url = "z://foobar";
|
||||
gBrowser.selectedTab = AddSearchProvider(url);
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "alert", "Should see the alert dialog.");
|
||||
is(dialog.args.text, getString("error_invalid_engine_msg", brandName),
|
||||
is(dialog.args.text, getString("error_invalid_engine_msg2", brandName, url),
|
||||
"Should have seen the right error message")
|
||||
dialog.document.documentElement.acceptDialog();
|
||||
|
||||
|
@ -90,3 +91,16 @@ add_task(function* test_missing() {
|
|||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_missing_namespace() {
|
||||
let url = ROOT + "testEngine_missing_namespace.xml";
|
||||
gBrowser.selectedTab = AddSearchProvider(url);
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "alert", "Should see the alert dialog.");
|
||||
is(dialog.args.text, getString("error_invalid_engine_msg2", brandName, url),
|
||||
"Should have seen the right error message")
|
||||
dialog.document.documentElement.acceptDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<OpenSearchDescription>
|
||||
<ShortName>Foo</ShortName>
|
||||
<Description>Foo Search</Description>
|
||||
<InputEncoding>utf-8</InputEncoding>
|
||||
<Image width="16" height="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC</Image>
|
||||
<Url type="text/html" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/?search">
|
||||
<Param name="test" value="{searchTerms}"/>
|
||||
</Url>
|
||||
<moz:SearchForm>http://mochi.test:8888/browser/browser/components/search/test/</moz:SearchForm>
|
||||
<moz:Alias>fooalias</moz:Alias>
|
||||
</OpenSearchDescription>
|
|
@ -49,9 +49,9 @@ MainProcessSingleton.prototype = {
|
|||
var searchBundle = Services.strings.createBundle("chrome://global/locale/search/search.properties");
|
||||
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
||||
var brandName = brandBundle.GetStringFromName("brandShortName");
|
||||
var title = searchBundle.GetStringFromName("error_invalid_engine_title");
|
||||
var msg = searchBundle.formatStringFromName("error_invalid_engine_msg",
|
||||
[brandName], 1);
|
||||
var title = searchBundle.GetStringFromName("error_invalid_format_title");
|
||||
var msg = searchBundle.formatStringFromName("error_invalid_engine_msg2",
|
||||
[brandName, engineURL.spec], 2);
|
||||
Services.ww.getNewPrompter(browser.ownerGlobal).alert(title, msg);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1611,7 +1611,13 @@ Engine.prototype = {
|
|||
} catch (ex) {
|
||||
LOG("_onLoad: Failed to init engine!\n" + ex);
|
||||
// Report an error to the user
|
||||
promptError();
|
||||
if (ex.result == Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||
promptError({ error: "error_invalid_engine_msg2",
|
||||
title: "error_invalid_format_title"
|
||||
});
|
||||
} else {
|
||||
promptError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1833,9 +1839,10 @@ Engine.prototype = {
|
|||
|
||||
this._parse();
|
||||
|
||||
} else
|
||||
FAIL(this._location + " is not a valid search plugin.", Cr.NS_ERROR_FAILURE);
|
||||
|
||||
} else {
|
||||
Cu.reportError("Invalid search plugin due to namespace not matching.");
|
||||
FAIL(this._location + " is not a valid search plugin.", Cr.NS_ERROR_FILE_CORRUPTED);
|
||||
}
|
||||
// No need to keep a ref to our data (which in some cases can be a document
|
||||
// element) past this point
|
||||
this._data = null;
|
||||
|
|
|
@ -13,8 +13,8 @@ error_loading_engine_msg2=%S could not download the search plugin from:\n%S
|
|||
error_duplicate_engine_msg=%S could not install the search plugin from “%S” because an engine with the same name already exists.
|
||||
|
||||
error_invalid_engine_title=Install Error
|
||||
# LOCALIZATION NOTE (error_invalid_engine_msg): %S = brandShortName
|
||||
error_invalid_engine_msg=This search engine isn’t supported by %S and can’t be installed.
|
||||
error_invalid_format_title=Invalid Format
|
||||
# LOCALIZATION NOTE (error_invalid_engine_msg2): %1$S = brandShortName, %2$S = location (url)
|
||||
error_invalid_engine_msg2=%1$S could not install the search engine from: %2$S
|
||||
|
||||
suggestion_label=Suggestions
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче