diff options
Diffstat (limited to 'js/xpconnect/loader/nsImportModule.cpp')
-rw-r--r-- | js/xpconnect/loader/nsImportModule.cpp | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/js/xpconnect/loader/nsImportModule.cpp b/js/xpconnect/loader/nsImportModule.cpp index a313c44388..3720a444a6 100644 --- a/js/xpconnect/loader/nsImportModule.cpp +++ b/js/xpconnect/loader/nsImportModule.cpp @@ -39,44 +39,11 @@ static void AnnotateCrashReportWithJSException(JSContext* aCx, aURI, file.get(), line, column, NS_ConvertUTF16toUTF8(msg).get()); - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationNSCString( CrashReporter::Annotation::JSModuleLoadError, errorString); } } -nsresult ImportModule(const char* aURI, const char* aExportName, - const nsIID& aIID, void** aResult, bool aInfallible) { - AutoJSAPI jsapi; - MOZ_ALWAYS_TRUE(jsapi.Init(xpc::PrivilegedJunkScope())); - JSContext* cx = jsapi.cx(); - - JS::RootedObject global(cx); - JS::RootedObject exports(cx); - nsresult rv = mozJSModuleLoader::Get()->Import(cx, nsDependentCString(aURI), - &global, &exports); - if (NS_WARN_IF(NS_FAILED(rv))) { - if (aInfallible) { - AnnotateCrashReportWithJSException(cx, aURI); - - MOZ_CRASH_UNSAFE_PRINTF("Failed to load critical module \"%s\"", aURI); - } - return rv; - } - - if (aExportName) { - JS::RootedValue namedExport(cx); - if (!JS_GetProperty(cx, exports, aExportName, &namedExport)) { - return NS_ERROR_FAILURE; - } - if (!namedExport.isObject()) { - return NS_ERROR_XPC_BAD_CONVERT_JS; - } - exports.set(&namedExport.toObject()); - } - - return nsXPConnect::XPConnect()->WrapJS(cx, exports, aIID, aResult); -} - nsresult ImportESModule(const char* aURI, const char* aExportName, const nsIID& aIID, void** aResult, bool aInfallible) { AutoJSAPI jsapi; |