зеркало из https://github.com/mozilla/gecko-dev.git
Bug 862148 - drop support for Sherlock plugins in window.sidebar.addSearchEngine, r=adw.
This commit is contained in:
Родитель
873bc3d810
Коммит
5eee2c7669
|
@ -8,11 +8,7 @@ function getString(key, ...params) {
|
|||
}
|
||||
|
||||
function AddSearchProvider(...args) {
|
||||
return gBrowser.addTab(ROOT + "webapi.html?AddSearchProvider:" + encodeURIComponent(JSON.stringify(args)));
|
||||
}
|
||||
|
||||
function addSearchEngine(...args) {
|
||||
return gBrowser.addTab(ROOT + "webapi.html?addSearchEngine:" + encodeURIComponent(JSON.stringify(args)));
|
||||
return gBrowser.addTab(ROOT + "webapi.html?" + encodeURIComponent(JSON.stringify(args)));
|
||||
}
|
||||
|
||||
function promiseDialogOpened() {
|
||||
|
@ -34,7 +30,7 @@ function promiseDialogOpened() {
|
|||
});
|
||||
}
|
||||
|
||||
add_task(function* test_working_AddSearchProvider() {
|
||||
add_task(function* test_working() {
|
||||
gBrowser.selectedTab = AddSearchProvider(ROOT + "testEngine.xml");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
|
@ -46,7 +42,7 @@ add_task(function* test_working_AddSearchProvider() {
|
|||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_HTTP_AddSearchProvider() {
|
||||
add_task(function* test_HTTP() {
|
||||
gBrowser.selectedTab = AddSearchProvider(ROOT.replace("http:", "HTTP:") + "testEngine.xml");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
|
@ -58,7 +54,7 @@ add_task(function* test_HTTP_AddSearchProvider() {
|
|||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_relative_AddSearchProvider() {
|
||||
add_task(function* test_relative() {
|
||||
gBrowser.selectedTab = AddSearchProvider("testEngine.xml");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
|
@ -70,7 +66,7 @@ add_task(function* test_relative_AddSearchProvider() {
|
|||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_invalid_AddSearchProvider() {
|
||||
add_task(function* test_invalid() {
|
||||
gBrowser.selectedTab = AddSearchProvider("z://foobar");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
|
@ -82,7 +78,7 @@ add_task(function* test_invalid_AddSearchProvider() {
|
|||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_missing_AddSearchProvider() {
|
||||
add_task(function* test_missing() {
|
||||
let url = ROOT + "foobar.xml";
|
||||
gBrowser.selectedTab = AddSearchProvider(url);
|
||||
|
||||
|
@ -94,88 +90,3 @@ add_task(function* test_missing_AddSearchProvider() {
|
|||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_working_addSearchEngine_xml() {
|
||||
gBrowser.selectedTab = addSearchEngine(ROOT + "testEngine.xml", "", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "confirmEx", "Should see the confirmation dialog.");
|
||||
is(dialog.args.text, getString("addEngineConfirmation", "Foo", "example.com"),
|
||||
"Should have seen the right install message");
|
||||
dialog.document.documentElement.cancelDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_working_addSearchEngine_src() {
|
||||
gBrowser.selectedTab = addSearchEngine(ROOT + "testEngine.src", "", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "confirmEx", "Should see the confirmation dialog.");
|
||||
is(dialog.args.text, getString("addEngineConfirmation", "Test Sherlock", "example.com"),
|
||||
"Should have seen the right install message");
|
||||
dialog.document.documentElement.cancelDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_relative_addSearchEngine_xml() {
|
||||
gBrowser.selectedTab = addSearchEngine("testEngine.xml", "", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "confirmEx", "Should see the confirmation dialog.");
|
||||
is(dialog.args.text, getString("addEngineConfirmation", "Foo", "example.com"),
|
||||
"Should have seen the right install message");
|
||||
dialog.document.documentElement.cancelDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_relative_addSearchEngine_src() {
|
||||
gBrowser.selectedTab = addSearchEngine("testEngine.src", "", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "confirmEx", "Should see the confirmation dialog.");
|
||||
is(dialog.args.text, getString("addEngineConfirmation", "Test Sherlock", "example.com"),
|
||||
"Should have seen the right install message");
|
||||
dialog.document.documentElement.cancelDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_invalid_addSearchEngine() {
|
||||
gBrowser.selectedTab = addSearchEngine("z://foobar", "", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "alert", "Should see the alert dialog.");
|
||||
is(dialog.args.text, getString("error_invalid_engine_msg", brandName),
|
||||
"Should have seen the right error message")
|
||||
dialog.document.documentElement.acceptDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_invalid_icon_addSearchEngine() {
|
||||
gBrowser.selectedTab = addSearchEngine(ROOT + "testEngine.src", "z://foobar", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "alert", "Should see the alert dialog.");
|
||||
is(dialog.args.text, getString("error_invalid_engine_msg", brandName),
|
||||
"Should have seen the right error message")
|
||||
dialog.document.documentElement.acceptDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(function* test_missing_addSearchEngine() {
|
||||
let url = ROOT + "foobar.xml";
|
||||
gBrowser.selectedTab = addSearchEngine(url, "", "", "");
|
||||
|
||||
let dialog = yield promiseDialogOpened();
|
||||
is(dialog.args.promptType, "alert", "Should see the alert dialog.");
|
||||
is(dialog.args.text, getString("error_loading_engine_msg2", brandName, url),
|
||||
"Should have seen the right error message")
|
||||
dialog.document.documentElement.acceptDialog();
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
|
|
@ -4,14 +4,10 @@
|
|||
<head>
|
||||
<script>
|
||||
function installEngine() {
|
||||
var query = window.location.search.substring(1).split(":");
|
||||
var func = query[0];
|
||||
var args = JSON.parse(decodeURIComponent(query[1]));
|
||||
var query = window.location.search.substring(1);
|
||||
var args = JSON.parse(decodeURIComponent(query));
|
||||
|
||||
if (func == "AddSearchProvider")
|
||||
window.external.AddSearchProvider(...args);
|
||||
else if (func == "addSearchEngine")
|
||||
window.sidebar.addSearchEngine(...args);
|
||||
window.external.AddSearchProvider(...args);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -24,20 +24,15 @@ MainProcessSingleton.prototype = {
|
|||
Services.obs.notifyObservers(logMsg, "console-api-log-event", null);
|
||||
},
|
||||
|
||||
// Called when a webpage calls either window.external.AddSearchProvider or
|
||||
// window.sidebar.addSearchEngine
|
||||
addSearchEngine: function({ target: browser, data: { pageURL, engineURL, iconURL, type } }) {
|
||||
// Called when a webpage calls window.external.AddSearchProvider
|
||||
addSearchEngine: function({ target: browser, data: { pageURL, engineURL, type } }) {
|
||||
pageURL = NetUtil.newURI(pageURL);
|
||||
engineURL = NetUtil.newURI(engineURL, null, pageURL);
|
||||
|
||||
if (iconURL) {
|
||||
iconURL = NetUtil.newURI(iconURL, null, pageURL);
|
||||
}
|
||||
else {
|
||||
let tabbrowser = browser.getTabBrowser();
|
||||
if (browser.mIconURL && (!tabbrowser || tabbrowser.shouldLoadFavIcon(pageURL)))
|
||||
iconURL = NetUtil.newURI(browser.mIconURL);
|
||||
}
|
||||
let iconURL;
|
||||
let tabbrowser = browser.getTabBrowser();
|
||||
if (browser.mIconURL && (!tabbrowser || tabbrowser.shouldLoadFavIcon(pageURL)))
|
||||
iconURL = NetUtil.newURI(browser.mIconURL);
|
||||
|
||||
try {
|
||||
// Make sure the URLs are HTTP, HTTPS, or FTP.
|
||||
|
@ -50,7 +45,7 @@ MainProcessSingleton.prototype = {
|
|||
throw "Unsupported search icon URL: " + iconURL;
|
||||
}
|
||||
catch(ex) {
|
||||
Cu.reportError("Invalid argument passed to window.sidebar.addSearchEngine: " + ex);
|
||||
Cu.reportError("Invalid argument passed to window.external.AddSearchProvider: " + ex);
|
||||
|
||||
var searchBundle = Services.strings.createBundle("chrome://global/locale/search/search.properties");
|
||||
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
||||
|
|
|
@ -22,24 +22,19 @@ nsSidebar.prototype = {
|
|||
.getInterface(Ci.nsIContentFrameMessageManager);
|
||||
},
|
||||
|
||||
// The suggestedTitle and suggestedCategory parameters are ignored, but remain
|
||||
// for backward compatibility.
|
||||
// Deprecated, only left here to avoid breaking old browser-detection scripts.
|
||||
addSearchEngine: function(engineURL, iconURL, suggestedTitle, suggestedCategory) {
|
||||
let dataType = SHERLOCK_FILE_EXT_REGEXP.test(engineURL) ?
|
||||
Ci.nsISearchEngine.DATA_TEXT :
|
||||
Ci.nsISearchEngine.DATA_XML;
|
||||
if (SHERLOCK_FILE_EXT_REGEXP.test(engineURL)) {
|
||||
Cu.reportError("Installing Sherlock search plugins is no longer supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.mm.sendAsyncMessage("Search:AddEngine", {
|
||||
pageURL: this.window.document.documentURIObject.spec,
|
||||
engineURL,
|
||||
type: dataType,
|
||||
iconURL
|
||||
});
|
||||
this.AddSearchProvider(engineURL);
|
||||
},
|
||||
|
||||
// This function exists largely to implement window.external.AddSearchProvider(),
|
||||
// to match other browsers' APIs. The capitalization, although nonstandard here,
|
||||
// is therefore important.
|
||||
// This function implements window.external.AddSearchProvider().
|
||||
// The capitalization, although nonstandard here, is to match other browsers'
|
||||
// APIs and is therefore important.
|
||||
AddSearchProvider: function(engineURL) {
|
||||
this.mm.sendAsyncMessage("Search:AddEngine", {
|
||||
pageURL: this.window.document.documentURIObject.spec,
|
||||
|
|
Загрузка…
Ссылка в новой задаче