Bug 1658214: Only construct JS-implemented objects if inner window is current. r=bholley

Differential Revision: https://phabricator.services.mozilla.com/D86614
This commit is contained in:
Kris Maglione 2020-08-14 16:02:25 +00:00
Родитель 0920dd26fe
Коммит 9bbcae0e83
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -2547,6 +2547,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);
@ -2561,7 +2567,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);