summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-23 16:13:41 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-22 20:38:21 -0500
commite51fd8ea71b361ef439728ba6985cbc30c057cd0 (patch)
treeec69f7a7f0be6a8219f042cf79371e3270750aeb /ext/fg/js
parentf725549330e851ededad3c97c4517f8a23168e4a (diff)
Add _isInjectedAndLoaded property
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/popup.js7
1 files changed, 6 insertions, 1 deletions
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}, '*');
}