Bug 1535071 - Use the debugger global scope for worker error reporting if necessary, r=smaug,baku.

Differential Revision: https://phabricator.services.mozilla.com/D24270

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-03-25 09:26:48 +00:00
Родитель 5e81ad2260
Коммит b851bf262e
3 изменённых файлов: 19 добавлений и 0 удалений

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

@ -483,6 +483,11 @@ void AutoJSAPI::ReportException() {
errorGlobal = xpc::PrivilegedJunkScope(); errorGlobal = xpc::PrivilegedJunkScope();
} else { } else {
errorGlobal = GetCurrentThreadWorkerGlobal(); errorGlobal = GetCurrentThreadWorkerGlobal();
if (!errorGlobal) {
// We might be reporting an error in debugger code that ran before the
// worker's global was created. Use the debugger global instead.
errorGlobal = GetCurrentThreadWorkerDebuggerGlobal();
}
} }
} }
MOZ_ASSERT(JS_IsGlobalObject(errorGlobal)); MOZ_ASSERT(JS_IsGlobalObject(errorGlobal));

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

@ -2491,5 +2491,17 @@ JSObject* GetCurrentThreadWorkerGlobal() {
return scope->GetGlobalJSObject(); return scope->GetGlobalJSObject();
} }
JSObject* GetCurrentThreadWorkerDebuggerGlobal() {
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
if (!wp) {
return nullptr;
}
WorkerDebuggerGlobalScope* scope = wp->DebuggerGlobalScope();
if (!scope) {
return nullptr;
}
return scope->GetGlobalJSObject();
}
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

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

@ -32,6 +32,8 @@ JSContext* GetCurrentWorkerThreadJSContext();
JSObject* GetCurrentThreadWorkerGlobal(); JSObject* GetCurrentThreadWorkerGlobal();
JSObject* GetCurrentThreadWorkerDebuggerGlobal();
void CancelWorkersForWindow(nsPIDOMWindowInner* aWindow); void CancelWorkersForWindow(nsPIDOMWindowInner* aWindow);
void FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow); void FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow);