Bug 1696452: Handle attempts to construct JS-implemented interfaces in non-Window globals. r=peterv

We don't want to support this, but we also shouldn't crash if someone attempts
it.

Differential Revision: https://phabricator.services.mozilla.com/D108093
This commit is contained in:
Kris Maglione 2021-03-22 20:15:28 +00:00
parent 243e3e5bb8
commit a045dbb379

View File

@ -2559,6 +2559,10 @@ void ConstructJSImplementation(const char* aContractId,
AutoNoJSAPI nojsapi;
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
if (!window) {
aRv.ThrowInvalidStateError("Global is not a Window");
return;
}
if (!window->IsCurrentInnerWindow()) {
aRv.ThrowInvalidStateError("Window no longer active");
return;