[DOM] Only construct JS-implemented objects if inner window is current.
This commit is contained in:
parent
855a412394
commit
10961fb06d
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue