mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1636990 - Inline NS_NewBackstagePass. r=kmag
Also, make an NS_ERROR in ~mozJSComponentLoader() into an assertion. Differential Revision: https://phabricator.services.mozilla.com/D74691
This commit is contained in:
parent
3a5ced7037
commit
f9c07914d4
@ -359,12 +359,7 @@ bool XPCShellEnvironment::Init() {
|
||||
"principals");
|
||||
}
|
||||
|
||||
RefPtr<BackstagePass> backstagePass;
|
||||
rv = NS_NewBackstagePass(getter_AddRefs(backstagePass));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Failed to create backstage pass!");
|
||||
return false;
|
||||
}
|
||||
auto backstagePass = MakeRefPtr<BackstagePass>();
|
||||
|
||||
JS::RealmOptions options;
|
||||
options.creationOptions().setNewCompartmentInSystemZone();
|
||||
|
@ -294,10 +294,11 @@ static nsresult ReportOnCallerUTF8(JSCLContextHelper& helper,
|
||||
#undef ENSURE_DEP
|
||||
|
||||
mozJSComponentLoader::~mozJSComponentLoader() {
|
||||
MOZ_ASSERT(!mInitialized,
|
||||
"UnloadModules() was not explicitly called before cleaning up "
|
||||
"mozJSComponentLoader");
|
||||
|
||||
if (mInitialized) {
|
||||
NS_ERROR(
|
||||
"UnloadModules() was not explicitly called before cleaning up "
|
||||
"mozJSComponentLoader");
|
||||
UnloadModules();
|
||||
}
|
||||
|
||||
@ -565,10 +566,7 @@ size_t mozJSComponentLoader::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
|
||||
void mozJSComponentLoader::CreateLoaderGlobal(JSContext* aCx,
|
||||
const nsACString& aLocation,
|
||||
MutableHandleObject aGlobal) {
|
||||
RefPtr<BackstagePass> backstagePass;
|
||||
nsresult rv = NS_NewBackstagePass(getter_AddRefs(backstagePass));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
auto backstagePass = MakeRefPtr<BackstagePass>();
|
||||
RealmOptions options;
|
||||
|
||||
options.creationOptions().setNewCompartmentInSystemZone();
|
||||
@ -578,7 +576,7 @@ void mozJSComponentLoader::CreateLoaderGlobal(JSContext* aCx,
|
||||
// been defined so the JS debugger can tell what module the global is
|
||||
// for
|
||||
RootedObject global(aCx);
|
||||
rv = xpc::InitClassesWithNewWrappedGlobal(
|
||||
nsresult rv = xpc::InitClassesWithNewWrappedGlobal(
|
||||
aCx, static_cast<nsIGlobalObject*>(backstagePass),
|
||||
nsContentUtils::GetSystemPrincipal(), xpc::DONT_FIRE_ONNEWGLOBALHOOK,
|
||||
options, &global);
|
||||
|
@ -23,6 +23,8 @@ class BackstagePass : public nsIGlobalObject,
|
||||
public nsIClassInfo,
|
||||
public nsSupportsWeakReference {
|
||||
public:
|
||||
BackstagePass();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIXPCSCRIPTABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
@ -44,9 +46,6 @@ class BackstagePass : public nsIGlobalObject,
|
||||
|
||||
void SetGlobalObject(JSObject* global);
|
||||
|
||||
explicit BackstagePass(nsIPrincipal* prin)
|
||||
: mPrincipal(prin), mWrapper(nullptr) {}
|
||||
|
||||
private:
|
||||
virtual ~BackstagePass() = default;
|
||||
|
||||
@ -54,6 +53,4 @@ class BackstagePass : public nsIGlobalObject,
|
||||
XPCWrappedNative* mWrapper;
|
||||
};
|
||||
|
||||
nsresult NS_NewBackstagePass(BackstagePass** ret);
|
||||
|
||||
#endif // BackstagePass_h__
|
||||
|
@ -17,6 +17,9 @@ NS_IMPL_ISUPPORTS(BackstagePass, nsIXPCScriptable, nsIGlobalObject,
|
||||
nsIClassInfo, nsIScriptObjectPrincipal,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
BackstagePass::BackstagePass()
|
||||
: mPrincipal(nsContentUtils::GetSystemPrincipal()), mWrapper(nullptr) {}
|
||||
|
||||
// XXX(nika): It appears we don't have support for mayresolve hooks in
|
||||
// nsIXPCScriptable, and I don't really want to add it because I'd rather just
|
||||
// kill nsIXPCScriptable alltogether, so we don't use it here.
|
||||
@ -144,10 +147,3 @@ BackstagePass::PreCreate(nsISupports* nativeObj, JSContext* cx,
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult NS_NewBackstagePass(BackstagePass** ret) {
|
||||
RefPtr<BackstagePass> bsp =
|
||||
new BackstagePass(nsContentUtils::GetSystemPrincipal());
|
||||
bsp.forget(ret);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1260,13 +1260,7 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
|
||||
shellSecurityCallbacks = *scb;
|
||||
JS_SetSecurityCallbacks(cx, &shellSecurityCallbacks);
|
||||
|
||||
RefPtr<BackstagePass> backstagePass;
|
||||
rv = NS_NewBackstagePass(getter_AddRefs(backstagePass));
|
||||
if (NS_FAILED(rv)) {
|
||||
fprintf(gErrFile, "+++ Failed to create BackstagePass: %8x\n",
|
||||
static_cast<uint32_t>(rv));
|
||||
return 1;
|
||||
}
|
||||
auto backstagePass = MakeRefPtr<BackstagePass>();
|
||||
|
||||
// Make the default XPCShell global use a fresh zone (rather than the
|
||||
// System Zone) to improve cross-zone test coverage.
|
||||
|
Loading…
Reference in New Issue
Block a user