Bug 1078163 - WorkerNavigator strings should honor general.*.override prefs in e10s mode, r=khuey
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -366,16 +366,18 @@ Navigator::GetAppName(nsAString& aAppNam
*
* An empty array will be returned if there is no valid languages.
*/
/* static */ void
Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages)
{
MOZ_ASSERT(NS_IsMainThread());
+ aLanguages.Clear();
+
// E.g. "de-de, en-us,en".
const nsAdoptingString& acceptLang =
Preferences::GetLocalizedString("intl.accept_languages");
// Split values on commas.
nsCharSeparatedTokenizer langTokenizer(acceptLang, ',');
while (langTokenizer.hasMoreTokens()) {
nsDependentSubstring lang = langTokenizer.nextToken();
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -170,19 +170,16 @@ const uint32_t kNoIndex = uint32_t(-1);
const JS::ContextOptions kRequiredContextOptions =
JS::ContextOptions().setDontReportUncaught(true);
uint32_t gMaxWorkersPerDomain = MAX_WORKERS_PER_DOMAIN;
// Does not hold an owning reference.
RuntimeService* gRuntimeService = nullptr;
-// Only non-null during the call to Init.
-RuntimeService* gRuntimeServiceDuringInit = nullptr;
-
#ifdef ENABLE_TESTS
bool gTestPBackground = false;
#endif // ENABLE_TESTS
enum {
ID_Worker = 0,
ID_ChromeWorker,
ID_Event,
@@ -322,17 +319,17 @@ GenerateSharedWorkerKey(const nsACString
}
void
LoadRuntimeOptions(const char* aPrefName, void* /* aClosure */)
{
AssertIsOnMainThread();
RuntimeService* rts = RuntimeService::GetService();
- if (!rts && !gRuntimeServiceDuringInit) {
+ if (!rts) {
// May be shutting down, just bail.
return;
}
const nsDependentCString prefName(aPrefName);
// Several other pref branches will get included here so bail out if there is
// another callback that will handle this change.
@@ -383,17 +380,17 @@ LoadRuntimeOptions(const char* aPrefName
#ifdef JS_GC_ZEAL
void
LoadGCZealOptions(const char* /* aPrefName */, void* /* aClosure */)
{
AssertIsOnMainThread();
RuntimeService* rts = RuntimeService::GetService();
- if (!rts && !gRuntimeServiceDuringInit) {
+ if (!rts) {
// May be shutting down, just bail.
return;
}
int32_t gczeal = GetWorkerPref<int32_t>(NS_LITERAL_CSTRING(PREF_GCZEAL), -1);
if (gczeal < 0) {
gczeal = 0;
}
@@ -446,17 +443,17 @@ UpdatOtherJSGCMemoryOption(RuntimeServic
void
LoadJSGCMemoryOptions(const char* aPrefName, void* /* aClosure */)
{
AssertIsOnMainThread();
RuntimeService* rts = RuntimeService::GetService();
- if (!rts && !gRuntimeServiceDuringInit) {
+ if (!rts) {
// May be shutting down, just bail.
return;
}
NS_NAMED_LITERAL_CSTRING(jsPrefix, PREF_JS_OPTIONS_PREFIX);
NS_NAMED_LITERAL_CSTRING(workersPrefix, PREF_WORKERS_OPTIONS_PREFIX);
const nsDependentCString fullPrefName(aPrefName);
@@ -1393,29 +1390,28 @@ RuntimeService::~RuntimeService()
// static
RuntimeService*
RuntimeService::GetOrCreateService()
{
AssertIsOnMainThread();
if (!gRuntimeService) {
- nsRefPtr<RuntimeService> service = new RuntimeService();
- if (NS_FAILED(service->Init())) {
+ // The observer service now owns us until shutdown.
+ gRuntimeService = new RuntimeService();
+ if (NS_FAILED(gRuntimeService->Init())) {
NS_WARNING("Failed to initialize!");
- service->Cleanup();
+ gRuntimeService->Cleanup();
+ gRuntimeService = nullptr;
return nullptr;
}
#ifdef ENABLE_TESTS
gTestPBackground = mozilla::Preferences::GetBool("pbackground.testing", false);
#endif // ENABLE_TESTS
-
- // The observer service now owns us until shutdown.
- gRuntimeService = service;
}
return gRuntimeService;
}
// static
RuntimeService*
RuntimeService::GetService()
@@ -1820,19 +1816,16 @@ RuntimeService::Init()
false))) {
NS_WARNING("Failed to register for memory pressure notifications!");
}
if (NS_FAILED(obs->AddObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, false))) {
NS_WARNING("Failed to register for offline notification event!");
}
- NS_ASSERTION(!gRuntimeServiceDuringInit, "This should be null!");
- gRuntimeServiceDuringInit = this;
-
if (NS_FAILED(Preferences::RegisterCallback(
LoadJSGCMemoryOptions,
PREF_JS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
nullptr)) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
LoadJSGCMemoryOptions,
PREF_WORKERS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX,
nullptr)) ||
@@ -1880,19 +1873,16 @@ RuntimeService::Init()
nullptr)) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
JSVersionChanged,
PREF_WORKERS_LATEST_JS_VERSION,
nullptr))) {
NS_WARNING("Failed to register pref callbacks!");
}
- NS_ASSERTION(gRuntimeServiceDuringInit == this, "Should be 'this'!");
- gRuntimeServiceDuringInit = nullptr;
-
// We assume atomic 32bit reads/writes. If this assumption doesn't hold on
// some wacky platform then the worst that could happen is that the close
// handler will run for a slightly different amount of time.
if (NS_FAILED(Preferences::AddIntVarCache(
&sDefaultJSSettings.content.maxScriptRuntime,
PREF_MAX_SCRIPT_RUN_TIME_CONTENT,
MAX_SCRIPT_RUN_TIME_SEC)) ||
NS_FAILED(Preferences::AddIntVarCache(