bug 930456: Enforce failure if search service is initialized from a child process. r=gavin

--HG--
extra : transplant_source : %1F%E46%1F%C7%F2%04%9B%EB%BF%FE%EB_%08%B3XN%F9%8B%29
This commit is contained in:
chrishood@eagles.ewu.edu 2014-12-30 09:32:04 -08:00
Родитель 7344c78734
Коммит 1a6a9cae0d
5 изменённых файлов: 42 добавлений и 13 удалений

Просмотреть файл

@ -22,6 +22,8 @@ const MODE_CREATE = FileUtils.MODE_CREATE;
const MODE_TRUNCATE = FileUtils.MODE_TRUNCATE;
// nsSearchService.js uses Services.appinfo.name to build a salt for a hash.
var XULRuntime = Components.classesByID["{95d89e3e-a169-41a3-8e56-719978e15b12}"]
.getService(Ci.nsIXULRuntime);
var XULAppInfo = {
vendor: "Mozilla",
name: "XPCShell",
@ -34,6 +36,8 @@ var XULAppInfo = {
logConsoleErrors: true,
OS: "XPCShell",
XPCOMABI: "noarch-spidermonkey",
// mirror processType from the base implementation
processType: XULRuntime.processType,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, Ci.nsIXULRuntime,
Ci.nsISupports])
@ -47,13 +51,18 @@ var XULAppInfoFactory = {
}
};
var isChild = XULRuntime.processType == XULRuntime.PROCESS_TYPE_CONTENT;
Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
.registerFactory(Components.ID("{ecff8849-cee8-40a7-bd4a-3f4fdfeddb5c}"),
"XULAppInfo", "@mozilla.org/xre/app-info;1",
XULAppInfoFactory);
// Need to create and register a profile folder.
var gProfD = do_get_profile();
var gProfD;
if (!isChild) {
// Need to create and register a profile folder.
gProfD = do_get_profile();
}
function dumpn(text)
{
@ -202,15 +211,19 @@ function isSubObjectOf(expectedObj, actualObj) {
}
}
// Expand the amount of information available in error logs
Services.prefs.setBoolPref("browser.search.log", true);
// Can't set prefs if we're running in a child process, but the search service
// doesn't run in child processes anyways.
if (!isChild) {
// Expand the amount of information available in error logs
Services.prefs.setBoolPref("browser.search.log", true);
// The geo-specific search tests assume certain prefs are already setup, which
// might not be true when run in comm-central etc. So create them here.
Services.prefs.setBoolPref("browser.search.geoSpecificDefaults", true);
Services.prefs.setIntPref("browser.search.geoip.timeout", 2000);
// But still disable geoip lookups - tests that need it will re-configure this.
Services.prefs.setCharPref("browser.search.geoip.url", "");
// The geo-specific search tests assume certain prefs are already setup, which
// might not be true when run in comm-central etc. So create them here.
Services.prefs.setBoolPref("browser.search.geoSpecificDefaults", true);
Services.prefs.setIntPref("browser.search.geoip.timeout", 2000);
// But still disable geoip lookups - tests that need it will re-configure this.
Services.prefs.setCharPref("browser.search.geoip.url", "");
}
/**
* After useHttpServer() is called, this string contains the URL of the "data"

Просмотреть файл

@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function run_test()
{
if (isChild) {
do_check_false("@mozilla.org/browser/search-service;1" in Cc);
} else {
do_check_true("@mozilla.org/browser/search-service;1" in Cc);
}
}

Просмотреть файл

@ -0,0 +1,3 @@
function run_test() {
run_test_in_child("test_bug930456.js");
}

Просмотреть файл

@ -23,6 +23,8 @@ support-files =
[test_nocache.js]
[test_645970.js]
[test_bug930456.js]
[test_bug930456_child.js]
[test_identifiers.js]
[test_invalid_engine_from_dir.js]
[test_init_async_multiple.js]

Просмотреть файл

@ -1,6 +1,6 @@
component {7319788a-fe93-4db3-9f39-818cf08f4256} nsSearchService.js
contract @mozilla.org/browser/search-service;1 {7319788a-fe93-4db3-9f39-818cf08f4256}
component {7319788a-fe93-4db3-9f39-818cf08f4256} nsSearchService.js process=main
contract @mozilla.org/browser/search-service;1 {7319788a-fe93-4db3-9f39-818cf08f4256} process=main
# 21600 == 6 hours
category update-timer nsSearchService @mozilla.org/browser/search-service;1,getService,search-engine-update-timer,browser.search.update.interval,21600
component {aa892eb4-ffbf-477d-9f9a-06c995ae9f27} nsSearchSuggestions.js
contract @mozilla.org/autocomplete/search;1?name=search-autocomplete {aa892eb4-ffbf-477d-9f9a-06c995ae9f27}
contract @mozilla.org/autocomplete/search;1?name=search-autocomplete {aa892eb4-ffbf-477d-9f9a-06c995ae9f27}