Skip to content

Commit

Permalink
Bug 1658214: Only construct JS-implemented objects if inner window is…
Browse files Browse the repository at this point in the history
… current. r=bholley, a=RyanVM

Differential Revision: https://phabricator.services.mozilla.com/D86614
  • Loading branch information
kmaglione committed Aug 14, 2020
1 parent 971b17e commit acddbd4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dom/bindings/BindingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,12 @@ void ConstructJSImplementation(const char* aContractId,
{
AutoNoJSAPI nojsapi;

nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
if (!window->IsCurrentInnerWindow()) {
aRv.ThrowInvalidStateError("Window no longer active");
return;
}

// Get the XPCOM component containing the JS implementation.
nsresult rv;
nsCOMPtr<nsISupports> implISupports = do_CreateInstance(aContractId, &rv);
Expand All @@ -2604,7 +2610,6 @@ void 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);
Expand Down

0 comments on commit acddbd4

Please sign in to comment.