summaryrefslogtreecommitdiff
path: root/dom/bindings
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2020-08-28 07:05:07 +0000
committerMoonchild <moonchild@palemoon.org>2020-08-28 07:05:07 +0000
commit83898ee3e168216e49b010ec6d4f447963bd87f6 (patch)
tree5c35b604d369c17178e24fee77a8f91cad3d9521 /dom/bindings
parent9798bd075eb807dce8d3248f39fa6c857b1e06d5 (diff)
downloaduxp-83898ee3e168216e49b010ec6d4f447963bd87f6.tar.gz
[DOM] Only construct JS-implemented objects if inner window is current.
Diffstat (limited to 'dom/bindings')
-rw-r--r--dom/bindings/BindingUtils.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp
index ee321772e6..aeccc84bcc 100644
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2516,6 +2516,12 @@ ConstructJSImplementation(const char* aContractId,
{
AutoNoJSAPI nojsapi;
+ nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
+ if (!window->IsCurrentInnerWindow()) {
+ aRv.Throw(NS_ERROR_FAILURE);
+ return;
+ }
+
// Get the XPCOM component containing the JS implementation.
nsresult rv;
nsCOMPtr<nsISupports> implISupports = do_CreateInstance(aContractId, &rv);
@@ -2530,7 +2536,6 @@ ConstructJSImplementation(const char* aContractId,
// and our global is a window.
nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
do_QueryInterface(implISupports);
- nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
if (gpi) {
JS::Rooted<JS::Value> initReturn(RootingCx());
rv = gpi->Init(window, &initReturn);