summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2020-08-28 07:05:07 +0000
committerMoonchild <moonchild@palemoon.org>2020-08-30 11:58:40 +0000
commit5ca8fbd41c5cd92423d74e1cf6fc56cba4fe9c89 (patch)
treee0cbdc4b0e1aa7471ae95ca7ee3b21acfec75375
parent549c8b9283314fb98ee6f6068ad55f1ab38f7c5f (diff)
downloadUXP-5ca8fbd41c5cd92423d74e1cf6fc56cba4fe9c89.tar
UXP-5ca8fbd41c5cd92423d74e1cf6fc56cba4fe9c89.tar.gz
UXP-5ca8fbd41c5cd92423d74e1cf6fc56cba4fe9c89.tar.lz
UXP-5ca8fbd41c5cd92423d74e1cf6fc56cba4fe9c89.tar.xz
UXP-5ca8fbd41c5cd92423d74e1cf6fc56cba4fe9c89.zip
[DOM] Only construct JS-implemented objects if inner window is current.
-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 b244d4d2a..41ca6a629 100644
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2487,6 +2487,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);
@@ -2501,7 +2507,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);