Bug 1315446 Avoid crashing if GetCurrentThreadJSContext() or GetCurrentThreadWorkerGlobal() are called after worker shutdown. r=baku

This commit is contained in:
Ben Kelly 2017-01-24 06:09:22 -08:00
Родитель 352d267cbb
Коммит e5bccaf01d
1 изменённых файлов: 14 добавлений и 2 удалений

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

@ -1470,13 +1470,25 @@ IsCurrentThreadRunningChromeWorker()
JSContext*
GetCurrentThreadJSContext()
{
return GetCurrentThreadWorkerPrivate()->GetJSContext();
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
if (!wp) {
return nullptr;
}
return wp->GetJSContext();
}
JSObject*
GetCurrentThreadWorkerGlobal()
{
return GetCurrentThreadWorkerPrivate()->GlobalScope()->GetGlobalJSObject();
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
if (!wp) {
return nullptr;
}
WorkerGlobalScope* scope = wp->GlobalScope();
if (!scope) {
return nullptr;
}
return scope->GetGlobalJSObject();
}
END_WORKERS_NAMESPACE