Cleanup beforeunload handler after transaction is resolved (#7333)

* Cleanup beforeunload handler after transaction is resolved

The notification window was updated to reject transactions upon close
in #6340. A handler that rejects the transaction was added to
`window.onbeforeunload`, and it was cleared in `actions.js` if it was
confirmed or rejected.

However, the `onbeforeunload` handler remained uncleared if the
transaction was resolved in another window. This results in the
transaction being rejected when the notification window closes, even
long after the transaction is submitted and confirmed. This has been
the cause of many problems with the Firefox e2e tests.

Instead the `onbeforeunload` handler is cleared in the
`componentWillUnmount` lifecycle function, alongside where it's set in
the first place. This ensures that it's correctly unset regardless
of how the transaction was resolved, and it better matches user
expectations.

* Fix indentation and remove redundant export

The `run-all.sh` Bash script now uses consistent indentation, and is
consistent about only re-exporting the Ganache arguments when they
change.

* Ensure transactions are completed before checking balance

Various intermittent e2e test failures appear to be caused by React
re-rendering the transaction list during the test, as the transaction
goes from pending to confirmed. To avoid this race condition, the
transaction is now explicitly looked for in the confirmed transaction
list in each of the tests using this pattern.

* Enable all e2e tests on Firefox

The remaining tests that were disabled on Firefox now work correctly.
Only a few timing adjustments were needed.

* Update Firefox used in CI

Firefox v70 is now used on CI instead of v68. This necessitated
rewriting the function where the extension ID was obtained because the
Firefox extensions page was redesigned.
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent 19965985ad
commit fe28e0d134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .circleci/scripts/firefox-install
  2. 16
      test/e2e/address-book.spec.js
  3. 6
      test/e2e/from-import-ui.spec.js
  4. 2
      test/e2e/func.js
  5. 8
      test/e2e/metamask-responsive-ui.spec.js
  6. 71
      test/e2e/metamask-ui.spec.js
  7. 7
      test/e2e/run-all.sh
  8. 6
      test/e2e/send-edit.spec.js
  9. 9
      ui/app/components/app/signature-request.js
  10. 9
      ui/app/pages/confirm-transaction-base/confirm-transaction-base.component.js
  11. 7
      ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js
  12. 12
      ui/app/store/actions.js

@ -4,7 +4,7 @@ set -e
set -u set -u
set -o pipefail set -o pipefail
FIREFOX_VERSION='68.0' FIREFOX_VERSION='70.0'
FIREFOX_BINARY="firefox-${FIREFOX_VERSION}.tar.bz2" FIREFOX_BINARY="firefox-${FIREFOX_VERSION}.tar.bz2"
FIREFOX_BINARY_URL="https://ftp.mozilla.org/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/${FIREFOX_BINARY}" FIREFOX_BINARY_URL="https://ftp.mozilla.org/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/${FIREFOX_BINARY}"
FIREFOX_PATH='/opt/firefox' FIREFOX_PATH='/opt/firefox'

@ -210,13 +210,13 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 1) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000) await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000)
}
}) })
}) })
@ -251,13 +251,13 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 2) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 2
}, 10000)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-2\s*ETH/), 10000) await driver.wait(until.elementTextMatches(txValues, /-2\s*ETH/), 10000)
}
}) })
}) })
}) })

@ -226,8 +226,10 @@ describe('Using MetaMask with an existing account', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 1) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
assert.equal(txValues.length, 1) assert.equal(txValues.length, 1)

@ -91,7 +91,7 @@ async function getExtensionIdChrome (driver) {
async function getExtensionIdFirefox (driver) { async function getExtensionIdFirefox (driver) {
await driver.get('about:debugging#addons') await driver.get('about:debugging#addons')
const extensionId = await driver.findElement(By.css('dd.addon-target-info-content:nth-child(6) > span:nth-child(1)')).getText() const extensionId = await driver.wait(webdriver.until.elementLocated(By.xpath('//dl/div[contains(., \'Internal UUID\')]/dd')), 1000).getText()
return extensionId return extensionId
} }

@ -231,13 +231,13 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 1) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000) await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000)
}
}) })
}) })
}) })

@ -289,13 +289,13 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 1) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000) await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000)
}
}) })
}) })
@ -332,13 +332,13 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 2) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 2
}, 10000)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000) await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000)
}
}) })
}) })
@ -385,13 +385,13 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 3) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 3
}, 10000)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElement(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000) await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/), 10000)
}
}) })
}) })
@ -838,12 +838,10 @@ describe('MetaMask', function () {
it('renders the correct ETH balance', async () => { it('renders the correct ETH balance', async () => {
const balance = await findElement(driver, By.css('.transaction-view-balance__primary-balance')) const balance = await findElement(driver, By.css('.transaction-view-balance__primary-balance'))
await delay(regularDelayMs) await delay(regularDelayMs)
if (process.env.SELENIUM_BROWSER !== 'firefox') {
await driver.wait(until.elementTextMatches(balance, /^87.*\s*ETH.*$/), 10000) await driver.wait(until.elementTextMatches(balance, /^87.*\s*ETH.*$/), 10000)
const tokenAmount = await balance.getText() const tokenAmount = await balance.getText()
assert.ok(/^87.*\s*ETH.*$/.test(tokenAmount)) assert.ok(/^87.*\s*ETH.*$/.test(tokenAmount))
await delay(regularDelayMs) await delay(regularDelayMs)
}
}) })
}) })
@ -1002,22 +1000,15 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 1) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
assert.equal(txValues.length, 1) assert.equal(txValues.length, 1)
// test cancelled on firefox until https://github.com/mozilla/geckodriver/issues/906 is resolved,
// or possibly until we use latest version of firefox in the tests
if (process.env.SELENIUM_BROWSER !== 'firefox') {
await driver.wait(until.elementTextMatches(txValues[0], /-1\s*TST/), 10000) await driver.wait(until.elementTextMatches(txValues[0], /-1\s*TST/), 10000)
}
await driver.wait(async () => {
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
const txStatuses = await findElements(driver, By.css('.transaction-list-item__action')) const txStatuses = await findElements(driver, By.css('.transaction-list-item__action'))
await driver.wait(until.elementTextMatches(txStatuses[0], /Sent\sToken/i), 10000) await driver.wait(until.elementTextMatches(txStatuses[0], /Sent\sToken/i), 10000)
}) })
@ -1104,7 +1095,6 @@ describe('MetaMask', function () {
return confirmedTxes.length === 2 return confirmedTxes.length === 2
}, 10000) }, 10000)
await delay(regularDelayMs)
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
await driver.wait(until.elementTextMatches(txValues[0], /-1.5\s*TST/)) await driver.wait(until.elementTextMatches(txValues[0], /-1.5\s*TST/))
const txStatuses = await findElements(driver, By.css('.transaction-list-item__action')) const txStatuses = await findElements(driver, By.css('.transaction-list-item__action'))
@ -1115,14 +1105,10 @@ describe('MetaMask', function () {
const tokenListItems = await findElements(driver, By.css('.token-list-item')) const tokenListItems = await findElements(driver, By.css('.token-list-item'))
await tokenListItems[0].click() await tokenListItems[0].click()
await delay(regularDelayMs) await delay(1000)
// test cancelled on firefox until https://github.com/mozilla/geckodriver/issues/906 is resolved,
// or possibly until we use latest version of firefox in the tests
if (process.env.SELENIUM_BROWSER !== 'firefox') {
const tokenBalanceAmount = await findElements(driver, By.css('.transaction-view-balance__primary-balance')) const tokenBalanceAmount = await findElements(driver, By.css('.transaction-view-balance__primary-balance'))
await driver.wait(until.elementTextMatches(tokenBalanceAmount[0], /7.500\s*TST/), 10000) await driver.wait(until.elementTextMatches(tokenBalanceAmount[0], /7.500\s*TST/), 10000)
}
}) })
}) })
@ -1141,9 +1127,6 @@ describe('MetaMask', function () {
const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Approve Tokens')]`)) const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Approve Tokens')]`))
await transferTokens.click() await transferTokens.click()
if (process.env.SELENIUM_BROWSER !== 'firefox') {
await closeAllWindowHandlesExcept(driver, [extension, dapp])
}
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await delay(regularDelayMs) await delay(regularDelayMs)
@ -1232,10 +1215,6 @@ describe('MetaMask', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
if (process.env.SELENIUM_BROWSER === 'firefox') {
this.skip()
}
await driver.wait(async () => { await driver.wait(async () => {
const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item')) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 3 return confirmedTxes.length === 3
@ -1249,12 +1228,6 @@ describe('MetaMask', function () {
}) })
describe('Tranfers a custom token from dapp when no gas value is specified', () => { describe('Tranfers a custom token from dapp when no gas value is specified', () => {
before(function () {
if (process.env.SELENIUM_BROWSER === 'firefox') {
this.skip()
}
})
it('transfers an already created token, without specifying gas', async () => { it('transfers an already created token, without specifying gas', async () => {
const windowHandles = await driver.getAllWindowHandles() const windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0] const extension = windowHandles[0]
@ -1267,7 +1240,6 @@ describe('MetaMask', function () {
const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Transfer Tokens Without Gas')]`)) const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Transfer Tokens Without Gas')]`))
await transferTokens.click() await transferTokens.click()
await closeAllWindowHandlesExcept(driver, [extension, dapp])
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await delay(regularDelayMs) await delay(regularDelayMs)
@ -1304,12 +1276,6 @@ describe('MetaMask', function () {
}) })
describe('Approves a custom token from dapp when no gas value is specified', () => { describe('Approves a custom token from dapp when no gas value is specified', () => {
before(function () {
if (process.env.SELENIUM_BROWSER === 'firefox') {
this.skip()
}
})
it('approves an already created token', async () => { it('approves an already created token', async () => {
const windowHandles = await driver.getAllWindowHandles() const windowHandles = await driver.getAllWindowHandles()
const extension = windowHandles[0] const extension = windowHandles[0]
@ -1323,7 +1289,6 @@ describe('MetaMask', function () {
const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Approve Tokens Without Gas')]`)) const transferTokens = await findElement(driver, By.xpath(`//button[contains(text(), 'Approve Tokens Without Gas')]`))
await transferTokens.click() await transferTokens.click()
await closeAllWindowHandlesExcept(driver, extension)
await driver.switchTo().window(extension) await driver.switchTo().window(extension)
await delay(regularDelayMs) await delay(regularDelayMs)
@ -1346,7 +1311,7 @@ describe('MetaMask', function () {
}) })
it('submits the transaction', async function () { it('submits the transaction', async function () {
await delay(regularDelayMs) await delay(1000)
const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`)) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`))
await confirmButton.click() await confirmButton.click()
await delay(regularDelayMs) await delay(regularDelayMs)

@ -37,7 +37,6 @@ concurrently --kill-others \
'yarn ganache:start' \ 'yarn ganache:start' \
'sleep 5 && mocha test/e2e/from-import-ui.spec' 'sleep 5 && mocha test/e2e/from-import-ui.spec'
export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000"
concurrently --kill-others \ concurrently --kill-others \
--names 'ganache,e2e' \ --names 'ganache,e2e' \
--prefix '[{time}][{name}]' \ --prefix '[{time}][{name}]' \
@ -45,8 +44,7 @@ concurrently --kill-others \
'npm run ganache:start' \ 'npm run ganache:start' \
'sleep 5 && mocha test/e2e/send-edit.spec' 'sleep 5 && mocha test/e2e/send-edit.spec'
concurrently --kill-others \
concurrently --kill-others \
--names 'ganache,dapp,e2e' \ --names 'ganache,dapp,e2e' \
--prefix '[{time}][{name}]' \ --prefix '[{time}][{name}]' \
--success first \ --success first \
@ -73,7 +71,7 @@ concurrently --kill-others \
'sleep 5 && mocha test/e2e/address-book.spec' 'sleep 5 && mocha test/e2e/address-book.spec'
export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000"
concurrently --kill-others \ concurrently --kill-others \
--names 'ganache,dapp,e2e' \ --names 'ganache,dapp,e2e' \
--prefix '[{time}][{name}]' \ --prefix '[{time}][{name}]' \
--success first \ --success first \
@ -81,4 +79,3 @@ export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB522
'yarn ganache:start' \ 'yarn ganache:start' \
'yarn dapp' \ 'yarn dapp' \
'sleep 5 && mocha test/e2e/threebox.spec' 'sleep 5 && mocha test/e2e/threebox.spec'

@ -218,8 +218,10 @@ describe('Using MetaMask with an existing account', function () {
}) })
it('finds the transaction in the transactions list', async function () { it('finds the transaction in the transactions list', async function () {
const transactions = await findElements(driver, By.css('.transaction-list-item')) await driver.wait(async () => {
assert.equal(transactions.length, 1) const confirmedTxes = await findElements(driver, By.css('.transaction-list__completed-transactions .transaction-list-item'))
return confirmedTxes.length === 1
}, 10000)
const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary'))
assert.equal(txValues.length, 1) assert.equal(txValues.length, 1)

@ -107,7 +107,7 @@ SignatureRequest.prototype.componentDidMount = function () {
const { clearConfirmTransaction, cancel } = this.props const { clearConfirmTransaction, cancel } = this.props
const { metricsEvent } = this.context const { metricsEvent } = this.context
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) { if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) {
window.onbeforeunload = event => { this._onBeforeUnload = event => {
metricsEvent({ metricsEvent({
eventOpts: { eventOpts: {
category: 'Transactions', category: 'Transactions',
@ -118,6 +118,13 @@ SignatureRequest.prototype.componentDidMount = function () {
clearConfirmTransaction() clearConfirmTransaction()
cancel(event) cancel(event)
} }
window.addEventListener('beforeunload', this._onBeforeUnload)
}
}
SignatureRequest.prototype.componentWillUnmount = function () {
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) {
window.removeEventListener('beforeunload', this._onBeforeUnload)
} }
} }

@ -581,7 +581,7 @@ export default class ConfirmTransactionBase extends Component {
}) })
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) { if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) {
window.onbeforeunload = () => { this._onBeforeUnload = () => {
metricsEvent({ metricsEvent({
eventOpts: { eventOpts: {
category: 'Transactions', category: 'Transactions',
@ -594,11 +594,18 @@ export default class ConfirmTransactionBase extends Component {
}) })
cancelTransaction({ id }) cancelTransaction({ id })
} }
window.addEventListener('beforeunload', this._onBeforeUnload)
} }
getNextNonce() getNextNonce()
} }
componentWillUnmount () {
if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_NOTIFICATION) {
window.removeEventListener('beforeunload', this._onBeforeUnload)
}
}
render () { render () {
const { const {
isTxReprice, isTxReprice,

@ -50,7 +50,7 @@ export default class ImportWithSeedPhrase extends PureComponent {
} }
componentWillMount () { componentWillMount () {
window.onbeforeunload = () => this.context.metricsEvent({ this._onBeforeUnload = () => this.context.metricsEvent({
eventOpts: { eventOpts: {
category: 'Onboarding', category: 'Onboarding',
action: 'Import Seed Phrase', action: 'Import Seed Phrase',
@ -61,6 +61,11 @@ export default class ImportWithSeedPhrase extends PureComponent {
errorMessage: this.state.seedPhraseError, errorMessage: this.state.seedPhraseError,
}, },
}) })
window.addEventListener('beforeunload', this._onBeforeUnload)
}
componentWillUnmount () {
window.removeEventListener('beforeunload', this._onBeforeUnload)
} }
handleSeedPhraseChange (seedPhrase) { handleSeedPhraseChange (seedPhrase) {

@ -856,8 +856,6 @@ function signMsg (msgData) {
log.debug('action - signMsg') log.debug('action - signMsg')
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
log.debug(`actions calling background.signMessage`) log.debug(`actions calling background.signMessage`)
background.signMessage(msgData, (err, newState) => { background.signMessage(msgData, (err, newState) => {
@ -884,7 +882,6 @@ function signPersonalMsg (msgData) {
log.debug('action - signPersonalMsg') log.debug('action - signPersonalMsg')
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
log.debug(`actions calling background.signPersonalMessage`) log.debug(`actions calling background.signPersonalMessage`)
background.signPersonalMessage(msgData, (err, newState) => { background.signPersonalMessage(msgData, (err, newState) => {
@ -911,7 +908,6 @@ function signTypedMsg (msgData) {
log.debug('action - signTypedMsg') log.debug('action - signTypedMsg')
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
log.debug(`actions calling background.signTypedMessage`) log.debug(`actions calling background.signTypedMessage`)
background.signTypedMessage(msgData, (err, newState) => { background.signTypedMessage(msgData, (err, newState) => {
@ -1124,7 +1120,6 @@ function sendTx (txData) {
log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`) log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`)
return (dispatch, getState) => { return (dispatch, getState) => {
log.debug(`actions calling background.approveTransaction`) log.debug(`actions calling background.approveTransaction`)
window.onbeforeunload = null
background.approveTransaction(txData.id, (err) => { background.approveTransaction(txData.id, (err) => {
if (err) { if (err) {
dispatch(actions.txError(err)) dispatch(actions.txError(err))
@ -1201,7 +1196,6 @@ function updateAndApproveTx (txData) {
return (dispatch) => { return (dispatch) => {
log.debug(`actions calling background.updateAndApproveTx`) log.debug(`actions calling background.updateAndApproveTx`)
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.updateAndApproveTransaction(txData, err => { background.updateAndApproveTransaction(txData, err => {
dispatch(actions.updateTransactionParams(txData.id, txData.txParams)) dispatch(actions.updateTransactionParams(txData.id, txData.txParams))
@ -1260,7 +1254,6 @@ function txError (err) {
function cancelMsg (msgData) { function cancelMsg (msgData) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
log.debug(`background.cancelMessage`) log.debug(`background.cancelMessage`)
background.cancelMessage(msgData.id, (err, newState) => { background.cancelMessage(msgData.id, (err, newState) => {
@ -1283,7 +1276,6 @@ function cancelMsg (msgData) {
function cancelPersonalMsg (msgData) { function cancelPersonalMsg (msgData) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const id = msgData.id const id = msgData.id
background.cancelPersonalMessage(id, (err, newState) => { background.cancelPersonalMessage(id, (err, newState) => {
@ -1306,7 +1298,6 @@ function cancelPersonalMsg (msgData) {
function cancelTypedMsg (msgData) { function cancelTypedMsg (msgData) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const id = msgData.id const id = msgData.id
background.cancelTypedMessage(id, (err, newState) => { background.cancelTypedMessage(id, (err, newState) => {
@ -1330,7 +1321,6 @@ function cancelTx (txData) {
return (dispatch) => { return (dispatch) => {
log.debug(`background.cancelTransaction`) log.debug(`background.cancelTransaction`)
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
background.cancelTransaction(txData.id, err => { background.cancelTransaction(txData.id, err => {
if (err) { if (err) {
@ -1360,7 +1350,6 @@ function cancelTx (txData) {
*/ */
function cancelTxs (txDataList) { function cancelTxs (txDataList) {
return async (dispatch) => { return async (dispatch) => {
window.onbeforeunload = null
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
const txIds = txDataList.map(({id}) => id) const txIds = txDataList.map(({id}) => id)
const cancellations = txIds.map((id) => new Promise((resolve, reject) => { const cancellations = txIds.map((id) => new Promise((resolve, reject) => {
@ -1744,7 +1733,6 @@ function addTokens (tokens) {
function removeSuggestedTokens () { function removeSuggestedTokens () {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
window.onbeforeunload = null
return new Promise((resolve) => { return new Promise((resolve) => {
background.removeSuggestedTokens((err, suggestedTokens) => { background.removeSuggestedTokens((err, suggestedTokens) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())

Loading…
Cancel
Save