From e51fd8ea71b361ef439728ba6985cbc30c057cd0 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 23 Dec 2019 16:13:41 -0500 Subject: Add _isInjectedAndLoaded property --- ext/fg/js/popup.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 7a0c6133..9b3e3944 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -28,6 +28,7 @@ class Popup { this._childrenSupported = true; this._injectPromise = null; this._isInjected = false; + this._isInjectedAndLoaded = false; this._visible = false; this._visibleOverride = null; this._options = null; @@ -114,7 +115,7 @@ class Popup { } clearAutoPlayTimer() { - if (this._isInjected) { + if (this._isInjectedAndLoaded) { this._invokeApi('clearAutoPlayTimer'); } } @@ -215,6 +216,7 @@ class Popup { return new Promise((resolve) => { const parentFrameId = (typeof this._frameId === 'number' ? this._frameId : null); this._container.addEventListener('load', () => { + this._isInjectedAndLoaded = true; this._invokeApi('initialize', { options: this._options, popupInfo: { @@ -307,6 +309,9 @@ class Popup { } _invokeApi(action, params={}) { + if (!this._isInjectedAndLoaded) { + throw new Error('Frame not loaded'); + } this._container.contentWindow.postMessage({action, params}, '*'); } -- cgit v1.2.3