aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mascara/src/ui.js41
-rw-r--r--mascara/test/test-ui.js1
-rw-r--r--test/integration/lib/first-time.js4
3 files changed, 28 insertions, 18 deletions
diff --git a/mascara/src/ui.js b/mascara/src/ui.js
index 7506532d2..05521d095 100644
--- a/mascara/src/ui.js
+++ b/mascara/src/ui.js
@@ -30,30 +30,41 @@ const connectApp = function (readSw) {
serviceWorker: background.controller,
context: name,
})
- startPopup({ container, connectionStream }, (err, store) => {
- if (err) return displayCriticalError(err)
- store.subscribe(() => {
- const state = store.getState()
- if (state.appState.shouldClose) window.close()
+ return new Promise((resolve, reject) => {
+ startPopup({ container, connectionStream }, (err, store) => {
+ console.log('hello from MetaMascara ui!')
+ if (err) reject(err)
+ store.subscribe(() => {
+ const state = store.getState()
+ if (state.appState.shouldClose) window.close()
+ })
+ resolve()
})
})
}
-background.on('ready', (sw) => {
- background.removeListener('updatefound', connectApp)
- connectApp(sw)
+background.on('ready', async (sw) => {
+ try {
+ background.removeListener('updatefound', connectApp)
+ await timeout(1000)
+ await connectApp(sw)
+ console.log('hello from cb ready event!')
+ } catch (e) {
+ console.error(e)
+ }
})
background.on('updatefound', windowReload)
background.startWorker()
-.then(() => {
- setTimeout(() => {
- const container = document.getElementById(`app-content`)
- if (!container.children.length) windowReload()
- }, 2000)
-})
-console.log('hello from MetaMascara ui!')
function windowReload() {
if (window.METAMASK_SKIP_RELOAD) return
window.location.reload()
}
+
+function timeout (time) {
+ return new Promise(function (resolve, reject) {
+ setTimeout(function () {
+ resolve()
+ }, time || 1500)
+ })
+} \ No newline at end of file
diff --git a/mascara/test/test-ui.js b/mascara/test/test-ui.js
index 201eec601..bf27338d9 100644
--- a/mascara/test/test-ui.js
+++ b/mascara/test/test-ui.js
@@ -1,6 +1,5 @@
const Helper = require('./util/mascara-test-helper.js')
-window.METAMASK_SKIP_RELOAD = true
window.addEventListener('load', () => {
// inject app container
const body = document.body
diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js
index e023351bc..4140dfd78 100644
--- a/test/integration/lib/first-time.js
+++ b/test/integration/lib/first-time.js
@@ -12,7 +12,7 @@ QUnit.test('render init screen', (assert) => {
async function runFirstTimeUsageTest(assert, done) {
- await timeout()
+ await timeout(10000)
const app = $('#app-content')
@@ -123,7 +123,7 @@ async function runFirstTimeUsageTest(assert, done) {
assert.ok(children2, 'All network options present')
}
-function timeout(time) {
+function timeout (time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve()