diff --git a/content/base/src/nsDOMDataChannel.cpp b/content/base/src/nsDOMDataChannel.cpp index 43735d06155e..7f043fd99d7a 100644 --- a/content/base/src/nsDOMDataChannel.cpp +++ b/content/base/src/nsDOMDataChannel.cpp @@ -142,8 +142,6 @@ nsDOMDataChannel::Init(nsPIDOMWindow* aDOMWindow) nsresult rv; nsAutoString urlParam; - nsDOMEventTargetHelper::Init(); - MOZ_ASSERT(mDataChannel); mDataChannel->SetListener(this, nullptr); diff --git a/content/base/src/nsDOMFileReader.cpp b/content/base/src/nsDOMFileReader.cpp index 165dd86bac31..6492dc6c36db 100644 --- a/content/base/src/nsDOMFileReader.cpp +++ b/content/base/src/nsDOMFileReader.cpp @@ -118,20 +118,25 @@ nsDOMFileReader::~nsDOMFileReader() nsLayoutStatics::Release(); } + +/** + * This Init method is called from the factory constructor. + */ nsresult nsDOMFileReader::Init() { - nsDOMEventTargetHelper::Init(); - - nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager(); - nsCOMPtr subjectPrincipal; + nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager(); + nsCOMPtr principal; if (secMan) { - nsresult rv = secMan->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal)); - NS_ENSURE_SUCCESS(rv, rv); + secMan->GetSystemPrincipal(getter_AddRefs(principal)); } - NS_ENSURE_STATE(subjectPrincipal); - mPrincipal.swap(subjectPrincipal); + NS_ENSURE_STATE(principal); + mPrincipal.swap(principal); + // Instead of grabbing some random global from the context stack, + // let's use the default one (junk drawer) for now. + // We should move away from this Init... + BindToOwner(xpc::GetNativeForGlobal(xpc::GetJunkScope())); return NS_OK; } diff --git a/content/events/src/nsDOMEventTargetHelper.cpp b/content/events/src/nsDOMEventTargetHelper.cpp index cd6c34e6cc06..c4739ed6c58c 100644 --- a/content/events/src/nsDOMEventTargetHelper.cpp +++ b/content/events/src/nsDOMEventTargetHelper.cpp @@ -363,27 +363,3 @@ nsDOMEventTargetHelper::GetContextForEventHandlers(nsresult* aRv) : nullptr; } -void -nsDOMEventTargetHelper::Init(JSContext* aCx) -{ - JSContext* cx = aCx; - if (!cx) { - nsIJSContextStack* stack = nsContentUtils::ThreadJSContextStack(); - - if (!stack) - return; - - if (NS_FAILED(stack->Peek(&cx)) || !cx) - return; - } - - NS_ASSERTION(cx, "Should have returned earlier ..."); - nsIScriptContext* context = GetScriptContextFromJSContext(cx); - if (context) { - nsCOMPtr window = - do_QueryInterface(context->GetGlobalObject()); - if (window) { - BindToOwner(window->GetCurrentInnerWindow()); - } - } -} diff --git a/content/events/src/nsDOMEventTargetHelper.h b/content/events/src/nsDOMEventTargetHelper.h index c35e9a2fa645..f49037ce49b2 100644 --- a/content/events/src/nsDOMEventTargetHelper.h +++ b/content/events/src/nsDOMEventTargetHelper.h @@ -68,8 +68,6 @@ public: return static_cast(target); } - void Init(JSContext* aCx = nullptr); - bool HasListenersFor(nsIAtom* aTypeWithOn) { return mListenerManager && mListenerManager->HasListenersFor(aTypeWithOn);