mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 3448b7a9d7a5 (bug 890690)
This commit is contained in:
parent
ee2989b747
commit
ccd8854dc0
@ -294,6 +294,13 @@ function onSearchSubmit(aEvent)
|
||||
let searchURL = document.documentElement.getAttribute("searchEngineURL");
|
||||
|
||||
if (searchURL && searchTerms.length > 0) {
|
||||
const SEARCH_TOKENS = {
|
||||
"_searchTerms_": encodeURIComponent(searchTerms)
|
||||
}
|
||||
for (let key in SEARCH_TOKENS) {
|
||||
searchURL = searchURL.replace(key, SEARCH_TOKENS[key]);
|
||||
}
|
||||
|
||||
// Send an event that a search was performed. This was originally
|
||||
// added so Firefox Health Report could record that a search from
|
||||
// about:home had occurred.
|
||||
@ -301,42 +308,7 @@ function onSearchSubmit(aEvent)
|
||||
let event = new CustomEvent("AboutHomeSearchEvent", {detail: engineName});
|
||||
document.dispatchEvent(event);
|
||||
|
||||
const SEARCH_TOKEN = "_searchTerms_";
|
||||
let searchPostData = document.documentElement.getAttribute("searchEnginePostData");
|
||||
if (searchPostData) {
|
||||
// Check if a post form already exists. If so, remove it.
|
||||
const POST_FORM_NAME = "searchFormPost";
|
||||
let form = document.forms[POST_FORM_NAME];
|
||||
if (form) {
|
||||
form.parentNode.removeChild(form);
|
||||
}
|
||||
|
||||
// Create a new post form.
|
||||
form = document.body.appendChild(document.createElement("form"));
|
||||
form.setAttribute("name", POST_FORM_NAME);
|
||||
// Set the URL to submit the form to.
|
||||
form.setAttribute("action", searchURL.replace(SEARCH_TOKEN, searchTerms));
|
||||
form.setAttribute("method", "post");
|
||||
|
||||
// Create new <input type=hidden> elements for search param.
|
||||
searchPostData = searchPostData.split("&");
|
||||
for (let postVar of searchPostData) {
|
||||
let [name, value] = postVar.split("=");
|
||||
if (value == SEARCH_TOKEN) {
|
||||
value = searchTerms;
|
||||
}
|
||||
let input = document.createElement("input");
|
||||
input.setAttribute("type", "hidden");
|
||||
input.setAttribute("name", name);
|
||||
input.setAttribute("value", value);
|
||||
form.appendChild(input);
|
||||
}
|
||||
// Submit the form.
|
||||
form.submit();
|
||||
} else {
|
||||
searchURL = searchURL.replace(SEARCH_TOKEN, encodeURIComponent(searchTerms));
|
||||
window.location.href = searchURL;
|
||||
}
|
||||
window.location.href = searchURL;
|
||||
}
|
||||
|
||||
aEvent.preventDefault();
|
||||
|
@ -2310,9 +2310,6 @@ function BrowserOnAboutPageLoad(doc) {
|
||||
let updateSearchEngine = function() {
|
||||
let engine = AboutHomeUtils.defaultSearchEngine;
|
||||
docElt.setAttribute("searchEngineName", engine.name);
|
||||
docElt.setAttribute("searchEnginePostData", engine.postDataString || "");
|
||||
// Again, keep the searchEngineURL as the last attribute, because the
|
||||
// mutation observer in aboutHome.js is counting on that.
|
||||
docElt.setAttribute("searchEngineURL", engine.searchURL);
|
||||
};
|
||||
updateSearchEngine();
|
||||
|
@ -25,11 +25,13 @@ this.AboutHomeUtils = {
|
||||
get defaultSearchEngine() {
|
||||
let defaultEngine = Services.search.defaultEngine;
|
||||
let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage");
|
||||
if (submission.postData) {
|
||||
throw new Error("Home page does not support POST search engines.");
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
name: defaultEngine.name,
|
||||
searchURL: submission.uri.spec,
|
||||
postDataString: submission.postDataString
|
||||
searchURL: submission.uri.spec
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user