Backed out changeset 37aed188b674 (bug 1174386) unexpected pass in 576878.xhtml

This commit is contained in:
Carsten "Tomcat" Book 2016-07-13 09:24:09 +02:00
Родитель 03c1f7755c
Коммит 0dd9cf8167
7 изменённых файлов: 60 добавлений и 4 удалений

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

@ -987,6 +987,7 @@ class WorkerThreadPrimaryRunnable final : public Runnable
WorkerPrivate* mWorkerPrivate;
RefPtr<WorkerThread> mThread;
JSRuntime* mParentRuntime;
JS::UniqueChars mDefaultLocale;
class FinishedRunnable final : public Runnable
{
@ -1011,8 +1012,10 @@ class WorkerThreadPrimaryRunnable final : public Runnable
public:
WorkerThreadPrimaryRunnable(WorkerPrivate* aWorkerPrivate,
WorkerThread* aThread,
JSRuntime* aParentRuntime)
: mWorkerPrivate(aWorkerPrivate), mThread(aThread), mParentRuntime(aParentRuntime)
JSRuntime* aParentRuntime,
JS::UniqueChars aDefaultLocale)
: mWorkerPrivate(aWorkerPrivate), mThread(aThread)
, mParentRuntime(aParentRuntime), mDefaultLocale(Move(aDefaultLocale))
{
MOZ_ASSERT(aWorkerPrivate);
MOZ_ASSERT(aThread);
@ -1626,9 +1629,16 @@ RuntimeService::ScheduleWorker(WorkerPrivate* aWorkerPrivate)
}
JSRuntime* rt = CycleCollectedJSRuntime::Get()->Runtime();
JSRuntime* parentRuntime = JS_GetParentRuntime(rt);
JS::UniqueChars defaultLocale =
parentRuntime ? JS_GetDefaultLocale(JS_GetContext(parentRuntime)) : nullptr;
if (!parentRuntime) {
NS_WARNING("Could not obtain parent runtime's locale!");
}
nsCOMPtr<nsIRunnable> runnable =
new WorkerThreadPrimaryRunnable(aWorkerPrivate, thread,
JS_GetParentRuntime(rt));
new WorkerThreadPrimaryRunnable(aWorkerPrivate, thread, parentRuntime,
Move(defaultLocale));
if (NS_FAILED(thread->DispatchPrimaryRunnable(friendKey, runnable.forget()))) {
UnregisterWorker(aWorkerPrivate);
return false;
@ -2547,6 +2557,14 @@ WorkerThreadPrimaryRunnable::Run()
return NS_ERROR_FAILURE;
}
if (mDefaultLocale) {
if (!JS_SetDefaultLocale(cx, mDefaultLocale.get())) {
NS_WARNING("Could not set worker locale!");
}
mDefaultLocale = nullptr;
}
{
#ifdef MOZ_ENABLE_PROFILER_SPS
PseudoStack* stack = mozilla_get_pseudo_stack();

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

@ -0,0 +1,5 @@
self.onmessage = function (data) {
let myLocale = Intl.NumberFormat().resolvedOptions().locale;
self.postMessage(myLocale);
};

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

@ -0,0 +1 @@
content locale ./

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

@ -0,0 +1,12 @@
function run_test() {
do_load_manifest("data/chrome.manifest");
do_test_pending();
let mainThreadLocale = Intl.NumberFormat().resolvedOptions().locale;
let testWorker = new Worker("chrome://locale/content/bug1174386_worker.js");
testWorker.onmessage = function (e) {
let workerLocale = e.data;
equal(mainThreadLocale, workerLocale, "Worker should inherit Intl locale from main thread.");
do_test_finished();
};
testWorker.postMessage("go!");
}

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

@ -2,6 +2,9 @@
head =
tail =
skip-if = toolkit == 'gonk'
support-files =
data/bug1174386_worker.js
data/chrome.manifest
[test_bug22310.js]
skip-if = toolkit != "windows" && toolkit != "cocoa"
@ -14,6 +17,7 @@ skip-if = toolkit == "windows" || toolkit == "cocoa"
skip-if = toolkit != "cocoa"
[test_bug1086527.js]
[test_bug1174386.js]
[test_pluralForm.js]
[test_pluralForm_english.js]
[test_pluralForm_makeGetter.js]

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

@ -5819,6 +5819,16 @@ JS_SetDefaultLocale(JSContext* cx, const char* locale)
return cx->setDefaultLocale(locale);
}
JS_PUBLIC_API(UniqueChars)
JS_GetDefaultLocale(JSContext* cx)
{
AssertHeapIsIdle(cx);
if (const char* locale = cx->getDefaultLocale())
return UniqueChars(JS_strdup(cx, locale));
return nullptr;
}
JS_PUBLIC_API(void)
JS_ResetDefaultLocale(JSContext* cx)
{

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

@ -5038,6 +5038,12 @@ JS_ParseJSONWithReviver(JSContext* cx, JS::HandleString str, JS::HandleValue rev
extern JS_PUBLIC_API(bool)
JS_SetDefaultLocale(JSContext* cx, const char* locale);
/**
* Look up the default locale for the ECMAScript Internationalization API.
*/
extern JS_PUBLIC_API(JS::UniqueChars)
JS_GetDefaultLocale(JSContext* cx);
/**
* Reset the default locale to OS defaults.
*/