Commit 7b340f96 authored by Butkovits Atila's avatar Butkovits Atila
Browse files

Backed out 15 changesets (bug 1612824, bug 1661234, bug 1619926, bug 1612380,...

Backed out 15 changesets (bug 1612824, bug 1661234, bug 1619926, bug 1612380, bug 1559530, bug 1642990) for Xpc failures. CLOSED TREE

Backed out changeset 426d017d7e46 (bug 1642990)
Backed out changeset 84ab4021d403 (bug 1559530)
Backed out changeset 82a8305543e5 (bug 1559530)
Backed out changeset 38832c1185b8 (bug 1559530)
Backed out changeset f16918c10a6b (bug 1661234)
Backed out changeset 3a13258fbd51 (bug 1661234)
Backed out changeset abf8d8b24845 (bug 1612824)
Backed out changeset 7dfeb065a385 (bug 1619926)
Backed out changeset bc9d3e210fe7 (bug 1619926)
Backed out changeset 786164c461ae (bug 1619926)
Backed out changeset d89793e9d17d (bug 1619926)
Backed out changeset d665885bc912 (bug 1619926)
Backed out changeset 9260b6620943 (bug 1619926)
Backed out changeset af69a4896f2f (bug 1619926)
Backed out changeset b9cd6b7047b9 (bug 1612380)
parent 92522114
...@@ -421,6 +421,10 @@ pref("browser.helperApps.showOpenOptionForViewableInternally", true); ...@@ -421,6 +421,10 @@ pref("browser.helperApps.showOpenOptionForViewableInternally", true);
// search engines URL // search engines URL
pref("browser.search.searchEnginesURL", "https://addons.mozilla.org/%LOCALE%/firefox/search-engines/"); pref("browser.search.searchEnginesURL", "https://addons.mozilla.org/%LOCALE%/firefox/search-engines/");
// Market-specific search defaults
pref("browser.search.geoSpecificDefaults", true);
pref("browser.search.geoSpecificDefaults.url", "https://search.services.mozilla.com/1/%APP%/%VERSION%/%CHANNEL%/%LOCALE%/%REGION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%");
// search bar results always open in a new tab // search bar results always open in a new tab
pref("browser.search.openintab", false); pref("browser.search.openintab", false);
...@@ -441,6 +445,8 @@ pref("browser.search.widget.inNavBar", false); ...@@ -441,6 +445,8 @@ pref("browser.search.widget.inNavBar", false);
// The maximum amount of times the private default banner is shown. // The maximum amount of times the private default banner is shown.
pref("browser.search.separatePrivateDefault.ui.banner.max", 0); pref("browser.search.separatePrivateDefault.ui.banner.max", 0);
pref("browser.search.modernConfig", true);
pref("browser.sessionhistory.max_entries", 50); pref("browser.sessionhistory.max_entries", 50);
// Built-in default permissions. // Built-in default permissions.
......
...@@ -4,7 +4,15 @@ ...@@ -4,7 +4,15 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
Classes = [] Classes = [
{
'cid': '{6deb193c-f87d-4078-bc78-5e64655b4d62}',
'contract_ids': ['@mozilla.org/browser/directory-provider;1'],
'type': 'mozilla::browser::DirectoryProvider',
'headers': ['mozilla/browser/DirectoryProvider.h'],
'categories': {'xpcom-directory-providers': 'browser-directory-provider'},
},
]
TOOLKIT = buildconfig.substs['MOZ_WIDGET_TOOLKIT'] TOOLKIT = buildconfig.substs['MOZ_WIDGET_TOOLKIT']
......
...@@ -16,6 +16,7 @@ FINAL_LIBRARY = 'xul' ...@@ -16,6 +16,7 @@ FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [
'../about', '../about',
'../dirprovider',
'../migration', '../migration',
'../sessionstore', '../sessionstore',
'../shell', '../shell',
......
...@@ -39,3 +39,11 @@ ...@@ -39,3 +39,11 @@
0xb1, 0x31, 0xd9, 0x3d, 0x7d, 0x70, 0x4f, 0x64 \ 0xb1, 0x31, 0xd9, 0x3d, 0x7d, 0x70, 0x4f, 0x64 \
} \ } \
} }
// {6DEB193C-F87D-4078-BC78-5E64655B4D62}
#define NS_BROWSERDIRECTORYPROVIDER_CID \
{ \
0x6deb193c, 0xf87d, 0x4078, { \
0xbc, 0x78, 0x5e, 0x64, 0x65, 0x5b, 0x4d, 0x62 \
} \
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DirectoryProvider.h"
#include "nsIFile.h"
#include "nsISimpleEnumerator.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsArrayEnumerator.h"
#include "nsEnumeratorUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceDefs.h"
#include "nsCategoryManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsCOMArray.h"
#include "nsDirectoryServiceUtils.h"
#include "mozilla/ModuleUtils.h"
#include "mozilla/intl/LocaleService.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
#include "nsXULAppAPI.h"
using mozilla::intl::LocaleService;
namespace mozilla {
namespace browser {
NS_IMPL_ISUPPORTS(DirectoryProvider, nsIDirectoryServiceProvider,
nsIDirectoryServiceProvider2)
NS_IMETHODIMP
DirectoryProvider::GetFile(const char* aKey, bool* aPersist,
nsIFile** aResult) {
return NS_ERROR_FAILURE;
}
// Appends the distribution-specific search engine directories to the
// array. The directory structure is as follows:
// appdir/
// \- distribution/
// \- searchplugins/
// |- common/
// \- locale/
// |- <locale 1>/
// ...
// \- <locale N>/
// common engines are loaded for all locales. If there is no locale
// directory for the current locale, there is a pref:
// "distribution.searchplugins.defaultLocale"
// which specifies a default locale to use.
static void AppendDistroSearchDirs(nsIProperties* aDirSvc,
nsCOMArray<nsIFile>& array) {
nsCOMPtr<nsIFile> searchPlugins;
nsresult rv = aDirSvc->Get(XRE_APP_DISTRIBUTION_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(searchPlugins));
if (NS_FAILED(rv)) return;
searchPlugins->AppendNative("searchplugins"_ns);
nsCOMPtr<nsIFile> commonPlugins;
rv = searchPlugins->Clone(getter_AddRefs(commonPlugins));
if (NS_SUCCEEDED(rv)) {
commonPlugins->AppendNative("common"_ns);
array.AppendObject(commonPlugins);
}
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
nsCOMPtr<nsIFile> localePlugins;
rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
if (NS_FAILED(rv)) return;
localePlugins->AppendNative("locale"_ns);
nsAutoCString defLocale;
rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",
defLocale);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIFile> defLocalePlugins;
rv = localePlugins->Clone(getter_AddRefs(defLocalePlugins));
if (NS_SUCCEEDED(rv)) {
defLocalePlugins->AppendNative(defLocale);
array.AppendObject(defLocalePlugins);
return; // all done
}
}
// we didn't have a defaultLocale, use the user agent locale
nsAutoCString locale;
LocaleService::GetInstance()->GetAppLocaleAsBCP47(locale);
nsCOMPtr<nsIFile> curLocalePlugins;
rv = localePlugins->Clone(getter_AddRefs(curLocalePlugins));
if (NS_SUCCEEDED(rv)) {
curLocalePlugins->AppendNative(locale);
array.AppendObject(curLocalePlugins);
return; // all done
}
}
}
NS_IMETHODIMP
DirectoryProvider::GetFiles(const char* aKey, nsISimpleEnumerator** aResult) {
if (!strcmp(aKey, NS_APP_DISTRIBUTION_SEARCH_DIR_LIST)) {
nsCOMPtr<nsIProperties> dirSvc(
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
if (!dirSvc) return NS_ERROR_FAILURE;
nsCOMArray<nsIFile> distroFiles;
AppendDistroSearchDirs(dirSvc, distroFiles);
return NS_NewArrayEnumerator(aResult, distroFiles, NS_GET_IID(nsIFile));
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
DirectoryProvider::AppendingEnumerator::HasMoreElements(bool* aResult) {
*aResult = mNext ? true : false;
return NS_OK;
}
NS_IMETHODIMP
DirectoryProvider::AppendingEnumerator::GetNext(nsISupports** aResult) {
if (aResult) NS_ADDREF(*aResult = mNext);
mNext = nullptr;
// Ignore all errors
bool more;
while (NS_SUCCEEDED(mBase->HasMoreElements(&more)) && more) {
nsCOMPtr<nsISupports> nextbasesupp;
mBase->GetNext(getter_AddRefs(nextbasesupp));
nsCOMPtr<nsIFile> nextbase(do_QueryInterface(nextbasesupp));
if (!nextbase) continue;
nextbase->Clone(getter_AddRefs(mNext));
if (!mNext) continue;
char const* const* i = mAppendList;
while (*i) {
mNext->AppendNative(nsDependentCString(*i));
++i;
}
mNext = nullptr;
}
return NS_OK;
}
DirectoryProvider::AppendingEnumerator::AppendingEnumerator(
nsISimpleEnumerator* aBase, char const* const* aAppendList)
: mBase(aBase), mAppendList(aAppendList) {
// Initialize mNext to begin.
GetNext(nullptr);
}
} // namespace browser
} // namespace mozilla
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DirectoryProvider_h__
#define DirectoryProvider_h__
#include "nsIDirectoryService.h"
#include "nsComponentManagerUtils.h"
#include "nsSimpleEnumerator.h"
#include "mozilla/Attributes.h"
#define NS_BROWSERDIRECTORYPROVIDER_CONTRACTID \
"@mozilla.org/browser/directory-provider;1"
namespace mozilla {
namespace browser {
class DirectoryProvider final : public nsIDirectoryServiceProvider2 {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
private:
~DirectoryProvider() {}
class AppendingEnumerator final : public nsSimpleEnumerator {
public:
NS_DECL_NSISIMPLEENUMERATOR
AppendingEnumerator(nsISimpleEnumerator* aBase,
char const* const* aAppendList);
private:
~AppendingEnumerator() override = default;
nsCOMPtr<nsISimpleEnumerator> mBase;
char const* const* const mAppendList;
nsCOMPtr<nsIFile> mNext;
};
};
} // namespace browser
} // namespace mozilla
#endif // DirectoryProvider_h__
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files("**"):
BUG_COMPONENT = ("Firefox", "General")
EXPORTS.mozilla.browser += [
'DirectoryProvider.h',
]
SOURCES += [
'DirectoryProvider.cpp',
]
FINAL_LIBRARY = 'browsercomps'
LOCAL_INCLUDES += [
'../build'
]
{
"default": {
"searchDefault": "test",
"visibleDefaultEngines": [
"test", "test2"
]
}
}
...@@ -42,6 +42,7 @@ const ORIGINAL_NOTIFICATION_TIMEOUT = ...@@ -42,6 +42,7 @@ const ORIGINAL_NOTIFICATION_TIMEOUT =
add_task(async function startup() { add_task(async function startup() {
Services.prefs.setCharPref("browser.search.region", "US"); Services.prefs.setCharPref("browser.search.region", "US");
Services.prefs.setBoolPref("browser.search.geoSpecificDefaults", false);
Services.prefs.setIntPref("browser.search.addonLoadTimeout", 0); Services.prefs.setIntPref("browser.search.addonLoadTimeout", 0);
Services.prefs.setBoolPref( Services.prefs.setBoolPref(
"browser.search.separatePrivateDefault.ui.enabled", "browser.search.separatePrivateDefault.ui.enabled",
......
...@@ -27,10 +27,12 @@ skip-if = tsan # Times out, bug 1612707 ...@@ -27,10 +27,12 @@ skip-if = tsan # Times out, bug 1612707
support-files = support-files =
data/test/manifest.json data/test/manifest.json
data/test2/manifest.json data/test2/manifest.json
data/list.json
[test_ext_settings_overrides_search.js] [test_ext_settings_overrides_search.js]
[test_ext_settings_overrides_search_mozParam.js] [test_ext_settings_overrides_search_mozParam.js]
support-files = support-files =
data/test/manifest.json data/test/manifest.json
data/list.json
[test_ext_settings_overrides_shutdown.js] [test_ext_settings_overrides_shutdown.js]
[test_ext_settings_validate.js] [test_ext_settings_validate.js]
[test_ext_topSites.js] [test_ext_topSites.js]
......
...@@ -33,6 +33,7 @@ DIRS += [ ...@@ -33,6 +33,7 @@ DIRS += [
'attribution', 'attribution',
'contextualidentity', 'contextualidentity',
'customizableui', 'customizableui',
'dirprovider',
'doh', 'doh',
'downloads', 'downloads',
'enterprisepolicies', 'enterprisepolicies',
......
This diff is collapsed.
...@@ -15,6 +15,8 @@ support-files = ...@@ -15,6 +15,8 @@ support-files =
testEngine_dupe.xml testEngine_dupe.xml
testEngine_mozsearch.xml testEngine_mozsearch.xml
tooManyEnginesOffered.html tooManyEnginesOffered.html
mozsearch/mozsearch-engine/manifest.json
mozsearch/mozsearch-engine/favicon.ico
[browser_426329.js] [browser_426329.js]
[browser_483086.js] [browser_483086.js]
...@@ -22,6 +24,7 @@ support-files = ...@@ -22,6 +24,7 @@ support-files =
[browser_contentContextMenu.js] [browser_contentContextMenu.js]
support-files = browser_contentContextMenu.xhtml support-files = browser_contentContextMenu.xhtml
[browser_contextmenu.js] [browser_contextmenu.js]
support-files = mozsearch/mozsearch-engine-private/manifest.json
skip-if = (os == "win" && processor == "aarch64") # disabled on aarch64 due to 1531590 skip-if = (os == "win" && processor == "aarch64") # disabled on aarch64 due to 1531590
[browser_contextSearchTabPosition.js] [browser_contextSearchTabPosition.js]
skip-if = verify && debug && os == 'win' # Bug 1412519 skip-if = verify && debug && os == 'win' # Bug 1412519
......
...@@ -4,27 +4,13 @@ ...@@ -4,27 +4,13 @@
* Test searching for the selected text using the context menu * Test searching for the selected text using the context menu
*/ */
const { AddonTestUtils } = ChromeUtils.import(
"resource://testing-common/AddonTestUtils.jsm"
);
AddonTestUtils.initMochitest(this);
const ENGINE_NAME = "mozSearch"; const ENGINE_NAME = "mozSearch";
const ENGINE_ID = "mozsearch-engine@search.mozilla.org";
const PRIVATE_ENGINE_NAME = "mozPrivateSearch"; const PRIVATE_ENGINE_NAME = "mozPrivateSearch";
const ENGINE_DATA = new Map([ const PRIVATE_ENGINE_ID = "mozsearch-engine-private@search.mozilla.org";
[
ENGINE_NAME,
"https://example.com/browser/browser/components/search/test/browser/mozsearch.sjs",
],
[PRIVATE_ENGINE_NAME, "https://example.com:443/browser/"],
]);
let engine; let engine;
let privateEngine; let privateEngine;
let extensions = [];
let oldDefaultEngine;
let oldDefaultPrivateEngine;
add_task(async function setup() { add_task(async function setup() {
await SpecialPowers.pushPrefEnv({ await SpecialPowers.pushPrefEnv({
...@@ -38,38 +24,44 @@ add_task(async function setup() { ...@@ -38,38 +24,44 @@ add_task(async function setup() {
await Services.search.init(); await Services.search.init();
for (let [name, search_url] of ENGINE_DATA) { // replace the path we load search engines from with
let extension = ExtensionTestUtils.loadExtension({ // the path to our test data.
manifest: { let searchExtensions = getChromeDir(getResolvedURI(gTestPath));
chrome_settings_overrides: { searchExtensions.append("mozsearch");
search_provider: { let resProt = Services.io
name, .getProtocolHandler("resource")
search_url, .QueryInterface(Ci.nsIResProtocolHandler);
params: [ let originalSubstitution = resProt.getSubstitution("search-extensions");
{ resProt.setSubstitution(
name: "test", "search-extensions",
value: "{searchTerms}", Services.io.newURI("file://" + searchExtensions.path)
}, );
],
},
},
},
});
await extension.startup(); await Services.search.wrappedJSObject.ensureBuiltinExtension(ENGINE_ID);
await AddonTestUtils.waitForSearchProviderStartup(extension); await Services.search.wrappedJSObject.ensureBuiltinExtension(
extensions.push(extension); PRIVATE_ENGINE_ID
} );
engine = await Services.search.getEngineByName(ENGINE_NAME); engine = await Services.search.getEngineByName(ENGINE_NAME);
Assert.ok(engine, "Got a search engine"); Assert.ok(engine, "Got a search engine");
oldDefaultEngine = await Services.search.getDefault(); let defaultEngine = await Services.search.getDefault();
await Services.search.setDefault(engine); await Services.search.setDefault(engine);
privateEngine = await Services.search.getEngineByName(PRIVATE_ENGINE_NAME); privateEngine = await Services.search.getEngineByName(PRIVATE_ENGINE_NAME);
Assert.ok(privateEngine, "Got a search engine"); Assert.ok(privateEngine, "Got a search engine");
oldDefaultPrivateEngine = await Services.search.getDefaultPrivate(); let defaultPrivateEngine = await Services.search.getDefaultPrivate();
await Services.search.setDefaultPrivate(privateEngine); await Services.search.setDefaultPrivate(privateEngine);
registerCleanupFunction(async () => {
await Services.search.setDefault(defaultEngine);
await Services.search.setDefaultPrivate(defaultPrivateEngine);
await Services.search.removeEngine(engine);
await Services.search.removeEngine(privateEngine);
resProt.setSubstitution("search-extensions", originalSubstitution);
// Finial re-init to make sure we drop the added built-in engines.
await Services.search.reInit();
});
}); });
async function checkContextMenu( async function checkContextMenu(
...@@ -128,7 +120,7 @@ async function checkContextMenu( ...@@ -128,7 +120,7 @@ async function checkContextMenu(
let loaded = BrowserTestUtils.waitForNewTab( let loaded = BrowserTestUtils.waitForNewTab(
win.gBrowser, win.gBrowser,
expectedBaseUrl + "?test=test%2520search", expectedBaseUrl,
true true
); );
searchItem.click(); searchItem.click();
...@@ -221,16 +213,3 @@ add_task(async function test_privateWindow_no_separate_engine() { ...@@ -221,16 +213,3 @@ add_task(async function test_privateWindow_no_separate_engine() {
"https://example.com/browser/browser/components/search/test/browser/mozsearch.sjs" "https://example.com/browser/browser/components/search/test/browser/mozsearch.sjs"
); );
}); });
// We can't do the unload within registerCleanupFunction as that's too late for
// the test to be happy. Do it into a cleanup "test" here instead.
add_task(async function cleanup() {
await Services.search.setDefault(oldDefaultEngine);
await Services.search.setDefaultPrivate(oldDefaultPrivateEngine);
await Services.search.removeEngine(engine);
await Services.search.removeEngine(privateEngine);
for (let extension of extensions) {
await extension.unload();
}
});
{
"name": "mozPrivateSearch",
"description": "mozSearch Private Engine",
"manifest_version": 2,
"version": "1.0",
"applications": {
"gecko": {
"id": "mozsearch-engine-private@search.mozilla.org"
}
},
"hidden": true,
"chrome_settings_overrides": {
"search_provider": {
"name": "mozPrivateSearch",
"search_url": "https://example.com:443/browser/",
"params": [
{
"name": "test",
"value": "{searchTerms}"
},
{
"name": "ie",
"value": "utf-8"
},
{
"name": "channel",
"condition": "purpose",
"purpose": "contextmenu",
"value": "contextsearch"
},
{
"name": "channel",
"condition": "purpose",
"purpose": "keyword",
"value": "keywordsearch"
}
],
"search_url_post_params": "foo=bar"
}