aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 5ee62c9b..931813de 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -229,12 +229,11 @@ class Popup {
return new Promise((resolve, reject) => {
const tokenMap = new Map();
let timer = null;
- let frameLoadedResolve = null;
- let frameLoadedReject = null;
- const frameLoaded = new Promise((resolve2, reject2) => {
- frameLoadedResolve = resolve2;
- frameLoadedReject = reject2;
- });
+ let {
+ promise: frameLoadedPromise,
+ resolve: frameLoadedResolve,
+ reject: frameLoadedReject
+ } = deferPromise();
const postMessage = (action, params) => {
const contentWindow = frame.contentWindow;
@@ -261,7 +260,7 @@ class Popup {
if (!isObject(message)) { return; }
const {action, params} = message;
if (!isObject(params)) { return; }
- await frameLoaded;
+ await frameLoadedPromise;
if (timer === null) { return; } // Done
switch (action) {
@@ -331,7 +330,7 @@ class Popup {
frame.addEventListener('load', onLoad);
// Prevent unhandled rejections
- frameLoaded.catch(() => {}); // NOP
+ frameLoadedPromise.catch(() => {}); // NOP
setupFrame(frame);
});