Validate contentWindow before focus

This commit is contained in:
toasted-nutbread 2019-09-14 12:02:31 -04:00
parent ec816e6767
commit 964de775df

View File

@ -239,9 +239,12 @@ class Popup {
}
focusParent() {
if (this.parent && this.parent.container) {
if (this.parent !== null) {
// Chrome doesn't like focusing iframe without contentWindow.
this.parent.container.contentWindow.focus();
const contentWindow = this.parent.container.contentWindow;
if (contentWindow !== null) {
contentWindow.focus();
}
} else {
// Firefox doesn't like focusing window without first blurring the iframe.
// this.container.contentWindow.blur() doesn't work on Firefox for some reason.