Bug 1525627 - Report an error if there's no ScriptLoader for the current context. r=baku

This commit is contained in:
Jon Coppeard 2019-02-08 09:16:00 +02:00
Родитель 9743935cf6
Коммит 019d226699
1 изменённых файлов: 5 добавлений и 0 удалений

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

@ -749,6 +749,10 @@ RefPtr<GenericPromise> ScriptLoader::StartFetchingModuleAndDependencies(
}
static ScriptLoader* GetCurrentScriptLoader(JSContext* aCx) {
auto reportError = mozilla::MakeScopeExit([aCx]() {
JS_ReportErrorASCII(aCx, "No ScriptLoader found for the current context");
});
JSObject* object = JS::CurrentGlobalOrNull(aCx);
if (!object) {
return nullptr;
@ -775,6 +779,7 @@ static ScriptLoader* GetCurrentScriptLoader(JSContext* aCx) {
return nullptr;
}
reportError.release();
return loader;
}