mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1103216: update Google parameters, r=gavin, f=mfinkle, test changes r=felipe
--HG-- extra : transplant_source : %12%07%00%00%E1kA%0E%0B%24%0A%89%94%9C%17%B5EE%1E%B9
This commit is contained in:
parent
4130d4a2f3
commit
8a42bcb8f2
@ -7,44 +7,12 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const BROWSER_SEARCH_PREF = "browser.search.";
|
||||
|
||||
const MOZ_PARAM_LOCALE_REGEX = /\{moz:locale\}/g;
|
||||
const MOZ_PARAM_DIST_ID_REGEX = /\{moz:distributionID\}/g;
|
||||
const MOZ_PARAM_OFFICIAL_REGEX = /\{moz:official\}/g;
|
||||
|
||||
// Custom search parameters
|
||||
const MOZ_OFFICIAL = Services.appinfo.isOfficialBranding ? "official" : "unofficial";
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "distributionID", () => {
|
||||
try {
|
||||
return Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID");
|
||||
} catch (ex) {
|
||||
return Services.appinfo.distributionID;
|
||||
}
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "GOOGLE_CLIENT", () => {
|
||||
switch (Services.appinfo.defaultUpdateChannel) {
|
||||
case "beta":
|
||||
return "firefox-beta";
|
||||
case "aurora":
|
||||
return "firefox-aurora";
|
||||
case "nightly":
|
||||
return "firefox-nightly";
|
||||
default:
|
||||
return "firefox-a";
|
||||
}
|
||||
});
|
||||
|
||||
function test() {
|
||||
// Bug 992270: Ignore uncaught about:home exceptions (related to snippets from IndexedDB)
|
||||
ignoreAllUncaughtExceptions(true);
|
||||
|
||||
function replaceUrl(base) {
|
||||
return base.replace(MOZ_PARAM_LOCALE_REGEX, getLocale())
|
||||
.replace(MOZ_PARAM_DIST_ID_REGEX, distributionID)
|
||||
.replace(MOZ_PARAM_OFFICIAL_REGEX, MOZ_OFFICIAL);
|
||||
return base;
|
||||
}
|
||||
|
||||
let gMutationObserver = null;
|
||||
@ -115,7 +83,7 @@ function test() {
|
||||
},
|
||||
{
|
||||
name: "Search with Google from about:home",
|
||||
searchURL: replaceUrl("https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8&aq=t&rls={moz:distributionID}:{moz:locale}:{moz:official}&client=" + GOOGLE_CLIENT + "&channel=np&source=hp"),
|
||||
searchURL: replaceUrl("https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8"),
|
||||
run: function () {
|
||||
verify_about_home_search("Google");
|
||||
}
|
||||
|
@ -7,52 +7,11 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const BROWSER_SEARCH_PREF = "browser.search.";
|
||||
|
||||
const MOZ_PARAM_LOCALE = /\{moz:locale\}/g;
|
||||
const MOZ_PARAM_DIST_ID = /\{moz:distributionID\}/g;
|
||||
const MOZ_PARAM_OFFICIAL = /\{moz:official\}/g;
|
||||
|
||||
let runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
|
||||
// Custom search parameters
|
||||
const MOZ_OFFICIAL = runtime.isOfficialBranding ? "official" : "unofficial";
|
||||
|
||||
var google_client;
|
||||
switch (runtime.defaultUpdateChannel) {
|
||||
case "beta":
|
||||
google_client = "firefox-beta";
|
||||
break;
|
||||
case "aurora":
|
||||
google_client = "firefox-aurora";
|
||||
break;
|
||||
case "nightly":
|
||||
google_client = "firefox-nightly";
|
||||
break;
|
||||
default:
|
||||
google_client = "firefox-a";
|
||||
break;
|
||||
}
|
||||
|
||||
const GOOGLE_CLIENT = google_client;
|
||||
const MOZ_DISTRIBUTION_ID = runtime.distributionID;
|
||||
|
||||
function test() {
|
||||
let engine = Services.search.getEngineByName("Google");
|
||||
ok(engine, "Google");
|
||||
|
||||
is(Services.search.defaultEngine, engine, "Check that Google is the default search engine");
|
||||
|
||||
let distributionID;
|
||||
try {
|
||||
distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID");
|
||||
} catch (ex) {
|
||||
distributionID = MOZ_DISTRIBUTION_ID;
|
||||
}
|
||||
|
||||
let base = "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8&aq=t&rls={moz:distributionID}:{moz:locale}:{moz:official}&client=" + GOOGLE_CLIENT;
|
||||
base = base.replace(MOZ_PARAM_LOCALE, getLocale());
|
||||
base = base.replace(MOZ_PARAM_DIST_ID, distributionID);
|
||||
base = base.replace(MOZ_PARAM_OFFICIAL, MOZ_OFFICIAL);
|
||||
let base = "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8";
|
||||
|
||||
let url;
|
||||
|
||||
@ -60,15 +19,15 @@ function test() {
|
||||
url = engine.getSubmission("foo").uri.spec;
|
||||
is(url, base, "Check search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "contextmenu").uri.spec;
|
||||
is(url, base + "&channel=rcs", "Check context menu search URL for 'foo'");
|
||||
is(url, base, "Check context menu search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "keyword").uri.spec;
|
||||
is(url, base + "&channel=fflb", "Check keyword search URL for 'foo'");
|
||||
is(url, base, "Check keyword search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "searchbar").uri.spec;
|
||||
is(url, base + "&channel=sb", "Check search bar search URL for 'foo'");
|
||||
is(url, base, "Check search bar search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "homepage").uri.spec;
|
||||
is(url, base + "&channel=np&source=hp", "Check homepage search URL for 'foo'");
|
||||
is(url, base, "Check homepage search URL for 'foo'");
|
||||
url = engine.getSubmission("foo", null, "newtab").uri.spec;
|
||||
is(url, base + "&channel=nts", "Check newtab search URL for 'foo'");
|
||||
is(url, base, "Check newtab search URL for 'foo'");
|
||||
|
||||
// Check search suggestion URL.
|
||||
url = engine.getSubmission("foo", "application/x-suggestions+json").uri.spec;
|
||||
@ -86,8 +45,7 @@ function test() {
|
||||
name: "Google",
|
||||
alias: null,
|
||||
description: "Google Search",
|
||||
searchForm: "https://www.google.com/search?q=&ie=utf-8&oe=utf-8&aq=t&rls=" +
|
||||
distributionID + ":" + getLocale() + ":" + MOZ_OFFICIAL + "&client=" + GOOGLE_CLIENT,
|
||||
searchForm: "https://www.google.com/search?q=&ie=utf-8&oe=utf-8",
|
||||
type: Ci.nsISearchEngine.TYPE_MOZSEARCH,
|
||||
hidden: false,
|
||||
wrappedJSObject: {
|
||||
@ -120,60 +78,8 @@ function test() {
|
||||
"value": "utf-8",
|
||||
"purpose": undefined,
|
||||
},
|
||||
{
|
||||
"name": "aq",
|
||||
"value": "t",
|
||||
"purpose": undefined,
|
||||
},
|
||||
{
|
||||
"name": "rls",
|
||||
"value": "{moz:distributionID}:{moz:locale}:{moz:official}",
|
||||
"purpose": undefined,
|
||||
},
|
||||
{
|
||||
"name": "client",
|
||||
"value": GOOGLE_CLIENT,
|
||||
"purpose": undefined,
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"value": "rcs",
|
||||
"purpose": "contextmenu",
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"value": "fflb",
|
||||
"purpose": "keyword",
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"value": "sb",
|
||||
"purpose": "searchbar",
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"value": "np",
|
||||
"purpose": "homepage",
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"value": "nts",
|
||||
"purpose": "newtab",
|
||||
},
|
||||
{
|
||||
"name": "source",
|
||||
"value": "hp",
|
||||
"purpose": "homepage",
|
||||
},
|
||||
],
|
||||
mozparams: {
|
||||
"client": {
|
||||
"name": "client",
|
||||
"falseValue": "firefox",
|
||||
"trueValue": GOOGLE_CLIENT,
|
||||
"condition": "defaultEngine",
|
||||
"mozparam": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -7,52 +7,14 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const BROWSER_SEARCH_PREF = "browser.search.";
|
||||
|
||||
const MOZ_PARAM_LOCALE = /\{moz:locale\}/g;
|
||||
const MOZ_PARAM_DIST_ID = /\{moz:distributionID\}/g;
|
||||
const MOZ_PARAM_OFFICIAL = /\{moz:official\}/g;
|
||||
|
||||
let runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
|
||||
// Custom search parameters
|
||||
const MOZ_OFFICIAL = runtime.isOfficialBranding ? "official" : "unofficial";
|
||||
|
||||
var google_client;
|
||||
switch (runtime.defaultUpdateChannel) {
|
||||
case "beta":
|
||||
google_client = "firefox-beta";
|
||||
break;
|
||||
case "aurora":
|
||||
google_client = "firefox-aurora";
|
||||
break;
|
||||
case "nightly":
|
||||
google_client = "firefox-nightly";
|
||||
break;
|
||||
default:
|
||||
google_client = "firefox-a";
|
||||
break;
|
||||
}
|
||||
|
||||
const GOOGLE_CLIENT = google_client;
|
||||
const MOZ_DISTRIBUTION_ID = runtime.distributionID;
|
||||
|
||||
function test() {
|
||||
let engine = Services.search.getEngineByName("Google");
|
||||
ok(engine, "Google is installed");
|
||||
|
||||
is(Services.search.defaultEngine, engine, "Check that Google is the default search engine");
|
||||
let previouslySelectedEngine = Services.search.currentEngine;
|
||||
Services.search.currentEngine = engine;
|
||||
|
||||
let distributionID;
|
||||
try {
|
||||
distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID");
|
||||
} catch (ex) {
|
||||
distributionID = MOZ_DISTRIBUTION_ID;
|
||||
}
|
||||
|
||||
let base = "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8&aq=t&rls={moz:distributionID}:{moz:locale}:{moz:official}&client=" + GOOGLE_CLIENT;
|
||||
base = base.replace(MOZ_PARAM_LOCALE, getLocale());
|
||||
base = base.replace(MOZ_PARAM_DIST_ID, distributionID);
|
||||
base = base.replace(MOZ_PARAM_OFFICIAL, MOZ_OFFICIAL);
|
||||
let base = "https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8";
|
||||
|
||||
let url;
|
||||
|
||||
@ -66,7 +28,7 @@ function test() {
|
||||
var gTests = [
|
||||
{
|
||||
name: "context menu search",
|
||||
searchURL: base + "&channel=rcs",
|
||||
searchURL: base,
|
||||
run: function () {
|
||||
// Simulate a contextmenu search
|
||||
// FIXME: This is a bit "low-level"...
|
||||
@ -75,7 +37,7 @@ function test() {
|
||||
},
|
||||
{
|
||||
name: "keyword search",
|
||||
searchURL: base + "&channel=fflb",
|
||||
searchURL: base,
|
||||
run: function () {
|
||||
gURLBar.value = "? foo";
|
||||
gURLBar.focus();
|
||||
@ -84,7 +46,7 @@ function test() {
|
||||
},
|
||||
{
|
||||
name: "search bar search",
|
||||
searchURL: base + "&channel=sb",
|
||||
searchURL: base,
|
||||
run: function () {
|
||||
let sb = BrowserSearch.searchBar;
|
||||
sb.focus();
|
||||
@ -97,7 +59,7 @@ function test() {
|
||||
},
|
||||
{
|
||||
name: "new tab search",
|
||||
searchURL: base + "&channel=nts",
|
||||
searchURL: base,
|
||||
run: function () {
|
||||
function doSearch(doc) {
|
||||
// Re-add the listener, and perform a search
|
||||
@ -177,6 +139,7 @@ function test() {
|
||||
registerCleanupFunction(function () {
|
||||
gBrowser.removeProgressListener(listener);
|
||||
gBrowser.removeTab(tab);
|
||||
Services.search.currentEngine = previouslySelectedEngine;
|
||||
});
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function load() {
|
||||
|
@ -14,22 +14,5 @@
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<Param name="oe" value="utf-8"/>
|
||||
<Param name="aq" value="t"/>
|
||||
<Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
|
||||
#if MOZ_UPDATE_CHANNEL == beta
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-beta" falseValue="firefox"/>
|
||||
#elif MOZ_UPDATE_CHANNEL == aurora
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-aurora" falseValue="firefox"/>
|
||||
#elif MOZ_UPDATE_CHANNEL == nightly
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-nightly" falseValue="firefox"/>
|
||||
#else
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
|
||||
#endif
|
||||
<MozParam name="channel" condition="purpose" purpose="contextmenu" value="rcs"/>
|
||||
<MozParam name="channel" condition="purpose" purpose="keyword" value="fflb"/>
|
||||
<MozParam name="channel" condition="purpose" purpose="searchbar" value="sb"/>
|
||||
<MozParam name="channel" condition="purpose" purpose="homepage" value="np"/>
|
||||
<MozParam name="channel" condition="purpose" purpose="newtab" value="nts"/>
|
||||
<MozParam name="source" condition="purpose" purpose="homepage" value="hp"/>
|
||||
</Url>
|
||||
</SearchPlugin>
|
||||
|
@ -11,9 +11,6 @@
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<Param name="oe" value="utf-8"/>
|
||||
<Param name="aq" value="t"/>
|
||||
<!-- Dynamic parameters -->
|
||||
<Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
|
||||
</Url>
|
||||
<SearchForm>https://www.google.com</SearchForm>
|
||||
</SearchPlugin>
|
||||
|
Loading…
Reference in New Issue
Block a user