author | Florian Quèze <florian@queze.net> |
Wed, 23 Sep 2015 12:05:36 +0200 | |
changeset 264074 | 923c13d8a0cfaa830e0656830c1c86a84cfd3f66 |
parent 264073 | 015612bc220813fe1007173c9b2ebfe7471537fd |
child 264075 | ce4065567b884b38758ce0956b9fb65f7a5facac |
push id | 65512 |
push user | kwierso@gmail.com |
push date | Wed, 23 Sep 2015 20:23:51 +0000 |
treeherder | mozilla-inbound@b00078e693a0 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | adw |
bugs | 862148 |
milestone | 44.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/components/search/test/browser_webapi.js +++ b/browser/components/search/test/browser_webapi.js @@ -3,21 +3,17 @@ const searchBundle = Services.strings.cr const brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties"); const brandName = brandBundle.GetStringFromName("brandShortName"); function getString(key, ...params) { return searchBundle.formatStringFromName(key, params, params.length); } 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() { return new Promise((resolve, reject) => { Services.wm.addListener({ onOpenWindow: function(xulWin) { Services.wm.removeListener(this); @@ -29,153 +25,68 @@ function promiseDialogOpened() { else reject(); }, win); } }); }); } -add_task(function* test_working_AddSearchProvider() { +add_task(function* test_working() { gBrowser.selectedTab = AddSearchProvider(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_HTTP_AddSearchProvider() { +add_task(function* test_HTTP() { gBrowser.selectedTab = AddSearchProvider(ROOT.replace("http:", "HTTP:") + "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_AddSearchProvider() { +add_task(function* test_relative() { gBrowser.selectedTab = AddSearchProvider("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_invalid_AddSearchProvider() { +add_task(function* test_invalid() { gBrowser.selectedTab = AddSearchProvider("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_AddSearchProvider() { +add_task(function* test_missing() { let url = ROOT + "foobar.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_loading_engine_msg2", brandName, url), "Should have seen the right error message") dialog.document.documentElement.acceptDialog(); 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(); -});
--- a/browser/components/search/test/webapi.html +++ b/browser/components/search/test/webapi.html @@ -1,20 +1,16 @@ <!DOCTYPE html> <html> <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> <body onload="installEngine()"> </body> </html>
--- a/toolkit/components/processsingleton/MainProcessSingleton.js +++ b/toolkit/components/processsingleton/MainProcessSingleton.js @@ -19,43 +19,38 @@ MainProcessSingleton.prototype = { Ci.nsISupportsWeakReference]), logConsoleMessage: function(message) { let logMsg = message.data; logMsg.wrappedJSObject = logMsg; 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. let isWeb = ["https", "http", "ftp"]; if (isWeb.indexOf(engineURL.scheme) < 0) throw "Unsupported search engine URL: " + engineURL; if (iconURL && isWeb.indexOf(iconURL.scheme) < 0) 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"); var brandName = brandBundle.GetStringFromName("brandShortName"); var title = searchBundle.GetStringFromName("error_invalid_engine_title"); var msg = searchBundle.formatStringFromName("error_invalid_engine_msg", [brandName], 1); Services.ww.getNewPrompter(browser.ownerDocument.defaultView).alert(title, msg);
--- a/toolkit/components/search/nsSidebar.js +++ b/toolkit/components/search/nsSidebar.js @@ -17,34 +17,29 @@ nsSidebar.prototype = { init: function(window) { this.window = window; this.mm = window.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDocShell) .QueryInterface(Ci.nsIInterfaceRequestor) .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, engineURL, type: Ci.nsISearchEngine.DATA_XML }); },