diff --git a/CHANGELOG.md b/CHANGELOG.md index b96fab508..93dc1b0b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Current Develop Branch +## 7.0.1 Thu Aug 08 2019 +- [#6975](https://github.com/MetaMask/metamask-extension/pull/6975): Ensure seed phrase backup notification only shows up for new users + ## 7.0.0 Fri Aug 02 2019 - [#6828](https://github.com/MetaMask/metamask-extension/pull/6828): Capitalized speed up label to match rest of UI - [#6874](https://github.com/MetaMask/metamask-extension/pull/6928): Allows skipping of seed phrase challenge during onboarding, and completing it at a later time diff --git a/app/manifest.json b/app/manifest.json index 1ca2215eb..f8c150281 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_appName__", "short_name": "__MSG_appName__", - "version": "7.0.0", + "version": "7.0.1", "manifest_version": 2, "author": "https://metamask.io", "description": "__MSG_appDescription__", diff --git a/app/scripts/controllers/onboarding.js b/app/scripts/controllers/onboarding.js index 18fec4993..a29c8407a 100644 --- a/app/scripts/controllers/onboarding.js +++ b/app/scripts/controllers/onboarding.js @@ -23,7 +23,7 @@ class OnboardingController { */ constructor (opts = {}) { const initState = extend({ - seedPhraseBackedUp: null, + seedPhraseBackedUp: true, }, opts.initState) this.store = new ObservableStore(initState) } diff --git a/app/scripts/lib/enums.js b/app/scripts/lib/enums.js index c6d57a1bc..32c0947a3 100644 --- a/app/scripts/lib/enums.js +++ b/app/scripts/lib/enums.js @@ -1,6 +1,7 @@ const ENVIRONMENT_TYPE_POPUP = 'popup' const ENVIRONMENT_TYPE_NOTIFICATION = 'notification' const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen' +const ENVIRONMENT_TYPE_BACKGROUND = 'background' const PLATFORM_BRAVE = 'Brave' const PLATFORM_CHROME = 'Chrome' @@ -12,6 +13,7 @@ module.exports = { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_FULLSCREEN, + ENVIRONMENT_TYPE_BACKGROUND, PLATFORM_BRAVE, PLATFORM_CHROME, PLATFORM_EDGE, diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js index ea13b26be..2eb71c0a0 100644 --- a/app/scripts/lib/util.js +++ b/app/scripts/lib/util.js @@ -5,6 +5,7 @@ const { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_FULLSCREEN, + ENVIRONMENT_TYPE_BACKGROUND, PLATFORM_FIREFOX, PLATFORM_OPERA, PLATFORM_CHROME, @@ -28,17 +29,21 @@ function getStack () { * - 'popup' refers to the extension opened through the browser app icon (in top right corner in chrome and firefox) * - 'responsive' refers to the main browser window * - 'notification' refers to the popup that appears in its own window when taking action outside of metamask + * - 'background' refers to the background page * * @returns {string} A single word label that represents the type of window through which the app is being viewed * */ const getEnvironmentType = (url = window.location.href) => { - if (url.match(/popup.html(?:#.*)*$/)) { + const parsedUrl = new URL(url) + if (parsedUrl.pathname === '/popup.html') { return ENVIRONMENT_TYPE_POPUP - } else if (url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) { + } else if (parsedUrl.pathname === '/home.html') { return ENVIRONMENT_TYPE_FULLSCREEN - } else { + } else if (parsedUrl.pathname === '/notification.html') { return ENVIRONMENT_TYPE_NOTIFICATION + } else { + return ENVIRONMENT_TYPE_BACKGROUND } } diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js index 43820515d..d54a8a7b3 100644 --- a/app/scripts/platforms/extension.js +++ b/app/scripts/platforms/extension.js @@ -1,6 +1,9 @@ const extension = require('extensionizer') const {createExplorerLink: explorerLink} = require('etherscan-link') +const {getEnvironmentType} = require('../lib/util') +const {ENVIRONMENT_TYPE_BACKGROUND} = require('../lib/enums') + class ExtensionPlatform { // @@ -35,6 +38,9 @@ class ExtensionPlatform { extensionURL += `#${route}` } this.openWindow({ url: extensionURL }) + if (getEnvironmentType() !== ENVIRONMENT_TYPE_BACKGROUND) { + window.close() + } } getPlatformInfo (cb) { diff --git a/app/vendor/trezor/usb-permissions.js b/app/vendor/trezor/usb-permissions.js index 9de47e0a1..18f70f94f 100644 --- a/app/vendor/trezor/usb-permissions.js +++ b/app/vendor/trezor/usb-permissions.js @@ -25,6 +25,7 @@ const switchToPopupTab = (event) => { return; } + // TODO: remove this query, or add `tabs` permission. This does not work. // triggered from 'beforeunload' event // find tab by popup pattern and switch to it chrome.tabs.query({ @@ -47,4 +48,4 @@ window.addEventListener('message', event => { } }); -window.addEventListener('beforeunload', switchToPopupTab); \ No newline at end of file +window.addEventListener('beforeunload', switchToPopupTab); diff --git a/test/e2e/run-all.sh b/test/e2e/run-all.sh index 0e3fdfcc4..cb161f0b8 100755 --- a/test/e2e/run-all.sh +++ b/test/e2e/run-all.sh @@ -5,8 +5,13 @@ set -e set -u set -o pipefail +# Set the environment variable 'GANACHE_ARGS' to change any optional ganache flags +# By default, the flag `--quiet` is used. Setting 'GANACHE_ARGS' will override the default. +OPTIONAL_GANACHE_ARGS="${GANACHE_ARGS---quiet}" +BASE_GANACHE_ARGS="${OPTIONAL_GANACHE_ARGS} --blockTime 2" + export PATH="$PATH:./node_modules/.bin" -export GANACHE_ARGS='--blockTime 2 --quiet' +export GANACHE_ARGS="${BASE_GANACHE_ARGS}" concurrently --kill-others \ --names 'ganache,dapp,e2e' \ @@ -24,7 +29,7 @@ concurrently --kill-others \ 'yarn dapp' \ 'sleep 5 && mocha test/e2e/metamask-responsive-ui.spec' -export GANACHE_ARGS="$GANACHE_ARGS --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" +export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" concurrently --kill-others \ --names 'ganache,e2e' \ --prefix '[{time}][{name}]' \ @@ -32,7 +37,7 @@ concurrently --kill-others \ 'yarn ganache:start' \ 'sleep 5 && mocha test/e2e/from-import-ui.spec' -export GANACHE_ARGS="$GANACHE_ARGS --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" +export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" concurrently --kill-others \ --names 'ganache,e2e' \ --prefix '[{time}][{name}]' \ @@ -41,7 +46,7 @@ concurrently --kill-others \ 'sleep 5 && mocha test/e2e/send-edit.spec' -export GANACHE_ARGS="$GANACHE_ARGS --deterministic --account=0x250F458997A364988956409A164BA4E16F0F99F916ACDD73ADCD3A1DE30CF8D1,0 --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" +export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x250F458997A364988956409A164BA4E16F0F99F916ACDD73ADCD3A1DE30CF8D1,0 --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" concurrently --kill-others \ --names 'ganache,sendwithprivatedapp,e2e' \ --prefix '[{time}][{name}]' \ @@ -50,7 +55,7 @@ concurrently --kill-others \ 'npm run sendwithprivatedapp' \ 'sleep 5 && mocha test/e2e/incremental-security.spec' -export GANACHE_ARGS="$GANACHE_ARGS --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" +export GANACHE_ARGS="${BASE_GANACHE_ARGS} --deterministic --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000" concurrently --kill-others \ --names 'ganache,dapp,e2e' \ --prefix '[{time}][{name}]' \ diff --git a/test/unit/app/util-test.js b/test/unit/app/util-test.js index 656b22d92..259bd708b 100644 --- a/test/unit/app/util-test.js +++ b/test/unit/app/util-test.js @@ -1,6 +1,48 @@ const assert = require('assert') -const { sufficientBalance } = require('../../../app/scripts/lib/util') +const { getEnvironmentType, sufficientBalance } = require('../../../app/scripts/lib/util') +const { + ENVIRONMENT_TYPE_POPUP, + ENVIRONMENT_TYPE_NOTIFICATION, + ENVIRONMENT_TYPE_FULLSCREEN, + ENVIRONMENT_TYPE_BACKGROUND, +} = require('../../../app/scripts/lib/enums') +describe('getEnvironmentType', function () { + it('should return popup type', function () { + const environmentType = getEnvironmentType('http://extension-id/popup.html') + assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP) + }) + + it('should return notification type', function () { + const environmentType = getEnvironmentType('http://extension-id/notification.html') + assert.equal(environmentType, ENVIRONMENT_TYPE_NOTIFICATION) + }) + + it('should return fullscreen type', function () { + const environmentType = getEnvironmentType('http://extension-id/home.html') + assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN) + }) + + it('should return background type', function () { + const environmentType = getEnvironmentType('http://extension-id/_generated_background_page.html') + assert.equal(environmentType, ENVIRONMENT_TYPE_BACKGROUND) + }) + + it('should return the correct type for a URL with a hash fragment', function () { + const environmentType = getEnvironmentType('http://extension-id/popup.html#hash') + assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP) + }) + + it('should return the correct type for a URL with query parameters', function () { + const environmentType = getEnvironmentType('http://extension-id/popup.html?param=foo') + assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP) + }) + + it('should return the correct type for a URL with query parameters and a hash fragment', function () { + const environmentType = getEnvironmentType('http://extension-id/popup.html?param=foo#hash') + assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP) + }) +}) describe('SufficientBalance', function () { it('returns true if max tx cost is equal to balance.', function () {