From 226fea3868129374d6047c7f8fc2a5c02c97dee1 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 28 Aug 2020 07:05:07 +0000 Subject: [DOM] Only construct JS-implemented objects if inner window is current. --- dom/bindings/BindingUtils.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'dom') diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index ee321772e..aeccc84bc 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -2516,6 +2516,12 @@ ConstructJSImplementation(const char* aContractId, { AutoNoJSAPI nojsapi; + nsCOMPtr window = do_QueryInterface(aGlobal); + if (!window->IsCurrentInnerWindow()) { + aRv.Throw(NS_ERROR_FAILURE); + return; + } + // Get the XPCOM component containing the JS implementation. nsresult rv; nsCOMPtr implISupports = do_CreateInstance(aContractId, &rv); @@ -2530,7 +2536,6 @@ ConstructJSImplementation(const char* aContractId, // and our global is a window. nsCOMPtr gpi = do_QueryInterface(implISupports); - nsCOMPtr window = do_QueryInterface(aGlobal); if (gpi) { JS::Rooted initReturn(RootingCx()); rv = gpi->Init(window, &initReturn); -- cgit v1.2.3