aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-06-28 14:39:43 -0400
committerGitHub <noreply@github.com>2020-06-28 14:39:43 -0400
commitf2345b7d1c035422dad553a4541ee486d952afa9 (patch)
treea13d87b874b28b1be9cfe8e343cb37c780107883 /ext/bg
parent7b5dd5c310f7ec4d7f6e329367d34258cce10e8e (diff)
Use deferPromise (#630)
* Use deferPromise * Move definition * Implement promiseTimeout using deferPromise
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/backend.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 59a3de45..5ca84cab 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -78,10 +78,10 @@ class Backend {
this._isPrepared = false;
this._prepareError = false;
this._preparePromise = null;
- this._prepareCompletePromise = new Promise((resolve, reject) => {
- this._prepareCompleteResolve = resolve;
- this._prepareCompleteReject = reject;
- });
+ const {promise, resolve, reject} = deferPromise();
+ this._prepareCompletePromise = promise;
+ this._prepareCompleteResolve = resolve;
+ this._prepareCompleteReject = reject;
this._defaultBrowserActionTitle = null;
this._badgePrepareDelayTimer = null;
@@ -1269,8 +1269,7 @@ class Backend {
static async _findTab(timeout, checkUrl) {
// This function works around the need to have the "tabs" permission to access tab.url.
const tabs = await new Promise((resolve) => chrome.tabs.query({}, resolve));
- let matchPromiseResolve = null;
- const matchPromise = new Promise((resolve) => { matchPromiseResolve = resolve; });
+ const {promise: matchPromise, resolve: matchPromiseResolve} = deferPromise();
const checkTabUrl = ({tab, url}) => {
if (checkUrl(url, tab)) {