From 964de775df5b573b8ae96e4096815e1649401eb9 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 14 Sep 2019 12:02:31 -0400 Subject: Validate contentWindow before focus --- ext/fg/js/popup.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 1b15977b..08c4bfcb 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -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. -- cgit v1.2.3