diff --git a/.eslintrc.yml b/.eslintrc.yml
index 18dace5e9..cf3b408ab 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -44,4 +44,4 @@ globals: # don't warn about missing declarations
_: true
window: true
location: true
-
+ document: true
diff --git a/README.md b/README.md
index e99a81efb..335323dec 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,9 @@ Please note that this repository is the Electron host for the Meteor based walle
## Help and troubleshooting
-Please check the [Mist troubleshooting guide](https://github.com/ethereum/mist/wiki) for help.
+Please check the [Mist troubleshooting guide](https://github.com/ethereum/mist/wiki).
+
+Or the [Gitter Channel](https://gitter.im/ethereum/mist), to connect with the community for instant help.
## Installation
diff --git a/gulpTasks/building.js b/gulpTasks/building.js
index f3c09c1f8..b9f9240ea 100644
--- a/gulpTasks/building.js
+++ b/gulpTasks/building.js
@@ -35,6 +35,7 @@ gulp.task('copy-app-source-files', () => {
'!./tests/wallet/*',
`./icons/${type}/*`,
'./sounds/*',
+ './errorPages/*',
'customProtocols.js'
], {
base: './'
@@ -214,7 +215,8 @@ gulp.task('release-dist', (done) => {
break;
case 'mac':
cp(
- `${applicationName}-${version}.dmg`, `${appNameHypen}-macosx-${versionDashed}.dmg`);
+ path.join('mac', `${applicationName}-${version}.dmg`),
+ `${appNameHypen}-macosx-${versionDashed}.dmg`);
break;
case 'linux':
cp(
diff --git a/gulpTasks/publishing.js b/gulpTasks/publishing.js
index 6e3fa5737..6207c6d6b 100644
--- a/gulpTasks/publishing.js
+++ b/gulpTasks/publishing.js
@@ -57,6 +57,8 @@ gulp.task('upload-binaries', (cb) => {
// personal access token (public_repo) must be set using travis' ENVs
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
+ console.info('Checking Github releases...');
+
// query github releases
got(`https://api.github.com/repos/ethereum/mist/releases?access_token=${GITHUB_TOKEN}`, { json: true })
// filter draft with current version's tag
diff --git a/interface/client/lib/helpers/helperFunctions.js b/interface/client/lib/helpers/helperFunctions.js
index 472cf2fde..59af00f0d 100644
--- a/interface/client/lib/helpers/helperFunctions.js
+++ b/interface/client/lib/helpers/helperFunctions.js
@@ -79,11 +79,19 @@ Format Urls, e.g add a default protocol if on is missing.
@param {String} url
**/
Helpers.formatUrl = function (url) {
+ if (!url) return;
+
// add http:// if no protocol is present
- if (url && url.length === 64 && !!url.match(/^[0-9a-f]+$/)) {
+ if (url.length === 64 && !!url.match(/^[0-9a-f]+$/)) {
// if the url looks like a hash, add bzz
url = 'bzz://' + url;
- } else if (url && url.indexOf('://') === -1) {
+ } else if (!!url.match(/^([a-z]*:\/\/)?[^/]*\.eth(\/.*)?$/i)) {
+ // if uses .eth as a TLD
+ url = 'bzz://' + url.replace(/^([a-z]*:\/\/)?/i, '');
+ } else if (!!url.match(/^[^\.\/]*$/i)) {
+ // doesn't have a protocol nor a TLD
+ url = 'bzz://' + url + '.eth';
+ } else if (url.indexOf('://') === -1) {
// if it doesn't have a protocol
url = 'http://' + url;
}
diff --git a/interface/client/mistAPIBackend.js b/interface/client/mistAPIBackend.js
index 7a0f057e7..3fa29b03c 100644
--- a/interface/client/mistAPIBackend.js
+++ b/interface/client/mistAPIBackend.js
@@ -67,10 +67,9 @@ mistAPIBackend = function (event) {
appBar: (_.contains(allowedBrowserBarStyles, appBarClass) ? appBarClass : null)
}});
}
-
if (event.channel === 'mistAPI_sound') {
sound.pause();
- sound.src = Blaze._escape(arg);
+ sound.src = Blaze._escape('file://'+ dirname +'/sounds/' + arg + '.mp3');
sound.play();
}
diff --git a/interface/client/templates/views/webview.js b/interface/client/templates/views/webview.js
index a830594bd..6cf6bfbfc 100644
--- a/interface/client/templates/views/webview.js
+++ b/interface/client/templates/views/webview.js
@@ -64,6 +64,21 @@ Template['views_webview'].onRendered(function () {
webview.addEventListener('did-fail-load', showError.bind(webview, tabId));
webview.addEventListener('crashed', showError.bind(webview, tabId));
+ // Forward SWARM status code errors to showError
+ webview.addEventListener('did-get-response-details', function (e) {
+ if (e && e.resourceType === 'mainFrame' && /^bzz:\//i.test(e.newURL)) {
+ switch (e.httpResponseCode) {
+ case 500:
+ showError.call(webview, tabId, {
+ isMainFrame: true,
+ errorCode: 404
+ });
+ break;
+ }
+ }
+ });
+
+
// navigate page, and redirect to browser tab if necessary
webview.addEventListener('will-navigate', webviewLoadStart.bind(webview, tabId));
webview.addEventListener('did-get-redirect-request', webviewLoadStart.bind(webview, tabId));
diff --git a/interface/client/templates/webviewEvents.js b/interface/client/templates/webviewEvents.js
index a742e83dc..dc4e03347 100644
--- a/interface/client/templates/webviewEvents.js
+++ b/interface/client/templates/webviewEvents.js
@@ -12,6 +12,9 @@ showError = function (tabId, e) {
case -105:
url = path + '404.html';
break;
+ case 404:
+ url = path + '404.html';
+ break;
case 500:
url = path + '500.html';
break;
@@ -41,7 +44,7 @@ webviewChangeUrl = function (tabId, e) {
}
// make sure to not store error pages in history
- if (!url || url.indexOf('mist/errorPages/') !== -1) {
+ if (!url || url.indexOf('mist/errorPages/') !== -1 || url.indexOf('app.asar/errorPages/') !== -1) {
return;
}
diff --git a/interface/i18n/mist.en.i18n.json b/interface/i18n/mist.en.i18n.json
index 006147c42..c49d42be6 100644
--- a/interface/i18n/mist.en.i18n.json
+++ b/interface/i18n/mist.en.i18n.json
@@ -81,8 +81,9 @@
},
"help": {
"label": "Help",
- "reportBug": "Report an issue on Github",
- "mistWiki": "Troubleshooting and Help"
+ "mistWiki": "Troubleshooting and Help",
+ "gitter": "Mist channel on Gitter",
+ "reportBug": "Report an issue on Github"
}
},
"errors": {
diff --git a/main.js b/main.js
index 85bbc4ad4..d6cffe608 100644
--- a/main.js
+++ b/main.js
@@ -381,6 +381,10 @@ onReady = () => {
return ethereumNode.init();
})
.then(() => {
+ // Wallet shouldn't start Swarm
+ if (Settings.uiMode === 'wallet') {
+ return Promise.resolve();
+ }
return swarmNode.init();
})
.then(function sanityCheck() {
diff --git a/modules/ipc/ipcProviderBackend.js b/modules/ipc/ipcProviderBackend.js
index 04540c8d2..0b76b8748 100644
--- a/modules/ipc/ipcProviderBackend.js
+++ b/modules/ipc/ipcProviderBackend.js
@@ -16,13 +16,12 @@ const log = require('../utils/logger').create('ipcProviderBackend');
const Sockets = require('../socketManager');
const Settings = require('../settings');
const ethereumNode = require('../ethereumNode');
-const Windows = require('../windows');
const ERRORS = {
- INVALID_PAYLOAD: { code: -32600, message: 'Payload, or some of its content properties are invalid. Please check if they are valid HEX with 0x prefix.' },
- METHOD_DENIED: { code: -32601, message: "Method \'__method__\' not allowed." },
- METHOD_TIMEOUT: { code: -32603, message: "Request timed out for method \'__method__\'." },
+ INVALID_PAYLOAD: { code: -32600, message: "Payload, or some of its content properties are invalid. Please check if they are valid HEX with '0x' prefix." },
+ METHOD_DENIED: { code: -32601, message: 'Method __method__ not allowed.' },
+ METHOD_TIMEOUT: { code: -32603, message: 'Request timed out for method __method__.' },
TX_DENIED: { code: -32603, message: 'Transaction denied' },
BATCH_TX_DENIED: { code: -32603, message: 'Transactions denied, sendTransaction is not allowed in batch requests.' },
BATCH_COMPILE_DENIED: { code: -32603, message: 'Compilation denied, compileSolidity is not allowed in batch requests.' },
diff --git a/modules/ipc/methods/base.js b/modules/ipc/methods/base.js
index 5057fb02b..8275a708a 100644
--- a/modules/ipc/methods/base.js
+++ b/modules/ipc/methods/base.js
@@ -97,11 +97,11 @@ module.exports = class BaseProcessor {
}
// prevent dapps from acccesing admin endpoints
- if (!/^eth_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
+ if (!/^eth_|^bzz_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
delete payload.result;
-
- payload.error = this.ERRORS.METHOD_DENIED;
+ const err = _.clone(this.ERRORS.METHOD_DENIED);
+ err.message = err.message.replace('__method__', `"${payload.method}"`);
+ payload.error = err;
}
}
};
-
diff --git a/modules/menuItems.js b/modules/menuItems.js
index 5b873a8e0..54a99e9fe 100644
--- a/modules/menuItems.js
+++ b/modules/menuItems.js
@@ -230,12 +230,13 @@ let menuTempl = function (webviews) {
}});
LocalStore.set('selectedTab', 'browser');
`);
+ console.log('Hash uploaded:', hash);
}).catch(e => console.log(e));
}
}
}]
});
-
+
// EDIT
menu.push({
label: i18n.t('mist.applicationMenu.edit.label'),
@@ -624,14 +625,19 @@ let menuTempl = function (webviews) {
);
}
helpMenu.push({
- label: i18n.t('mist.applicationMenu.help.reportBug'),
+ label: i18n.t('mist.applicationMenu.help.mistWiki'),
click() {
- shell.openExternal('https://github.com/ethereum/mist/issues');
+ shell.openExternal('https://github.com/ethereum/mist/wiki');
},
}, {
- label: i18n.t('mist.applicationMenu.help.mistWiki'),
+ label: i18n.t('mist.applicationMenu.help.gitter'),
click() {
- shell.openExternal('https://github.com/ethereum/mist/wiki');
+ shell.openExternal('https://gitter.com/ethereum/mist');
+ },
+ }, {
+ label: i18n.t('mist.applicationMenu.help.reportBug'),
+ click() {
+ shell.openExternal('https://github.com/ethereum/mist/issues');
},
});
diff --git a/modules/preloader/browser.js b/modules/preloader/browser.js
index 39f02cb36..7776efac6 100644
--- a/modules/preloader/browser.js
+++ b/modules/preloader/browser.js
@@ -135,10 +135,10 @@ const postMessage = function (payload) {
// load ethereumProvider
-const bignumber = fs.readFileSync(path.resolve('./modules/preloader/injected/BigNumber.js')).toString();
-const eventEmitter3 = fs.readFileSync(path.resolve('./modules/preloader/injected/EventEmitter3.js')).toString();
-let mistAPI = fs.readFileSync(path.resolve('./modules/preloader/injected/mistAPI.js')).toString();
-const ethereumProvider = fs.readFileSync(path.resolve('./modules/preloader/injected/EthereumProvider.js')).toString();
+const bignumber = fs.readFileSync(path.join(__dirname, '/injected/BigNumber.js')).toString();
+const eventEmitter3 = fs.readFileSync(path.join(__dirname, '/injected/EventEmitter3.js')).toString();
+let mistAPI = fs.readFileSync(path.join(__dirname, '/injected/mistAPI.js')).toString();
+const ethereumProvider = fs.readFileSync(path.join(__dirname, '/injected/EthereumProvider.js')).toString();
mistAPI = mistAPI.replace('__version__', packageJson.version)
.replace('__license__', packageJson.license)
diff --git a/modules/preloader/injected/mistAPI.js b/modules/preloader/injected/mistAPI.js
index 2b960f005..d480c6621 100644
--- a/modules/preloader/injected/mistAPI.js
+++ b/modules/preloader/injected/mistAPI.js
@@ -71,19 +71,19 @@
bip: function playSound() {
postMessage({
type: 'mistAPI_sound',
- message: 'file://'+ __dirname +'/../../../sounds/bip.mp3'
+ message: 'bip'
});
},
bloop: function playSound() {
postMessage({
type: 'mistAPI_sound',
- message: 'file://'+ __dirname +'/../../../sounds/bloop.mp3'
+ message: 'bloop'
});
},
invite: function playSound() {
postMessage({
type: 'mistAPI_sound',
- message: 'file://'+ __dirname +'/../../../sounds/invite.mp3'
+ message: 'invite'
});
},
},
diff --git a/modules/preloader/walletMain.js b/modules/preloader/walletMain.js
index a1b571c27..354e5a496 100644
--- a/modules/preloader/walletMain.js
+++ b/modules/preloader/walletMain.js
@@ -5,7 +5,7 @@
require('./dapps.js');
require('./include/openExternal.js');
require('./include/setBasePath')('interface/wallet');
-
+const {webFrame} = require('electron');
const web3Admin = require('../web3Admin.js');
// make variables globally accessable
@@ -13,6 +13,7 @@ const web3Admin = require('../web3Admin.js');
webFrame.executeJavaScript("window.mistMode = 'wallet';");
+
// add admin later
setTimeout(() => {
web3Admin.extend(window.web3);
diff --git a/package.json b/package.json
index f5b3cbb70..1082eb03d 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,6 @@
},
"devDependencies": {
"chai": "^3.5.0",
- "chai-as-promised": "^6.0.0",
"co-mocha": "^1.2.0",
"del": "^2.2.2",
"ecstatic": "^2.1.0",
@@ -52,22 +51,20 @@
"eslint": "^3.14.1",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-import": "^2.2.0",
+ "express": "^4.15.3",
"genomatic": "^1.0.0",
"geth-private": "^1.3.0",
"gh-release-assets": "^1.1.0",
"gulp": "^3.9.0",
"gulp-spawn-mocha": "^3.3.0",
- "istanbul": "^0.4.5",
"json-structure-diff": "^0.0.2",
- "merge-stream": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.2.0",
- "optimist": "^0.6.1",
"require-dir": "^0.3.2",
"run-sequence": "^1.2.1",
"semver-compare": "^1.0.0",
"shelljs": "^0.7.7",
- "spectron": "3.6.0",
+ "spectron": "3.4.1",
"xml2js": "^0.4.17"
}
}
diff --git a/tests/.eslintrc.yml b/tests/.eslintrc.yml
index 49047f6f2..0be095d8c 100644
--- a/tests/.eslintrc.yml
+++ b/tests/.eslintrc.yml
@@ -3,3 +3,7 @@ globals: # don't warn about missing declarations
it: true
expect: true
chai: true
+ $: true
+ LastVisitedPages: true
+ History: true
+ localStorage: true
diff --git a/tests/_base.js b/tests/_base.js
index 1a0cc67b9..315591f48 100644
--- a/tests/_base.js
+++ b/tests/_base.js
@@ -6,14 +6,13 @@ const fs = require('fs');
const Web3 = require('web3');
const shell = require('shelljs');
const path = require('path');
-const packageJson = require('../package.json');
const gethPrivate = require('geth-private');
const Application = require('spectron').Application;
const chai = require('chai');
const http = require('http');
const ecstatic = require('ecstatic');
+const express = require('express');
const ClientBinaryManager = require('ethereum-client-binaries').Manager;
-const Settings = require('../modules/settings');
chai.should();
@@ -28,12 +27,10 @@ const startGeth = function* () {
const manager = new ClientBinaryManager(config);
yield manager.init();
- if (manager.clients.Geth.state.available) {
+ if (!manager.clients.Geth.state.available) {
gethPath = manager.clients.Geth.activeCli.fullPath;
- }
- else {
console.info('Downloading geth...');
- let downloadedGeth = yield manager.download('Geth');
+ const downloadedGeth = yield manager.download('Geth');
gethPath = downloadedGeth.client.activeCli.fullPath;
console.info('Geth downloaded at:', gethPath);
}
@@ -57,6 +54,18 @@ const startGeth = function* () {
return geth;
};
+const startFixtureServer = function (serverPort) {
+ const app = express();
+ app.use(express.static(path.join(__dirname, 'fixtures')));
+
+ app.get('/redirect', (req, res) => {
+ // Redirects to param ?url=XX
+ res.redirect(302, req.query.to);
+ });
+ app.listen(serverPort);
+ return app;
+};
+
exports.mocha = (_module, options) => {
const tests = {};
@@ -82,11 +91,10 @@ exports.mocha = (_module, options) => {
this.geth = yield startGeth();
const appFileName = (options.app === 'wallet') ? 'Ethereum Wallet' : 'Mist';
- const appVers = packageJson.version.replace(/\./ig, '-');
const platformArch = `${process.platform}-${process.arch}`;
let appPath;
- let ipcProviderPath = path.join(this.geth.dataDir, 'geth.ipc');
+ const ipcProviderPath = path.join(this.geth.dataDir, 'geth.ipc');
switch (platformArch) {
case 'darwin-x64':
@@ -122,18 +130,23 @@ exports.mocha = (_module, options) => {
webdriverLogPath: webdriverLogFile,
chromeDriverLogPath: chromeLogFile,
});
+
yield this.app.start();
+ this.client = this.app.client;
/*
Starting HTTP server for HTML fixtures
*/
const serverPort = 8080;
- this.httpServer = http.createServer(
- ecstatic({root: path.join(__dirname, 'fixtures')})
- ).listen(serverPort);
+ this.httpServer = startFixtureServer(serverPort);
this.fixtureBaseUrl = `http://localhost:${serverPort}/`;
- this.client = this.app.client;
+ // this.httpServer = http.createServer(
+ // ecstatic({root: path.join(__dirname, 'fixtures')})
+ // ).listen(serverPort);
+ // this.fixtureBaseUrl = `http://localhost:${serverPort}/`;
+ //
+ // this.client = this.app.client;
/*
Utility methods
@@ -143,8 +156,8 @@ exports.mocha = (_module, options) => {
}
// Loop over windows trying to select Main Window
- let app = this;
- let selectMainWindow = function* (mainWindowSearch) {
+ const app = this;
+ const selectMainWindow = function* (mainWindowSearch) {
let windowHandles = (yield app.client.windowHandles()).value;
for (let handle in windowHandles) {
@@ -157,7 +170,7 @@ exports.mocha = (_module, options) => {
// not main window. try again after 1 second.
yield Q.delay(1000);
yield selectMainWindow(mainWindowSearch);
- }
+ };
const mainWindowSearch = (options.app === 'wallet') ? /^file:\/\/\/$/ : /interface\/index\.html$/;
yield selectMainWindow(mainWindowSearch);
@@ -165,7 +178,7 @@ exports.mocha = (_module, options) => {
this.mainWindowHandle = (yield this.client.windowHandle()).value;
},
- * beforeEach () {
+ * beforeEach() {
yield this.app.client.window(this.mainWindowHandle);
yield this.client.execute(() => { // Code executed in context of browser
@@ -192,10 +205,9 @@ exports.mocha = (_module, options) => {
// yield this.client.reload();
},
- * afterEach () {
- },
+ // * afterEach() { },
- * after () {
+ * after() {
if (this.app && this.app.isRunning()) {
console.log('Stopping app...');
yield this.app.stop();
@@ -339,14 +351,18 @@ const Utils = {
},
* selectTab(tabId) {
- const tab = yield this.getUiElement(`.sidebar [data-tab-id=${tabId}]`);
+ yield this.getUiElement(`.sidebar [data-tab-id=${tabId}]`);
yield this.client.click(`.sidebar [data-tab-id=${tabId}] button.main`);
// TODO: returns webview reference
},
- * getActiveWebview() {
- const webview = '';
- return webview;
+
+ * getSelectedWebviewParam(param) {
+ const selectedTabId = (yield this.client.execute(() => {
+ return localStorage.getItem('selectedTab');
+ })).value;
+ return yield this.client.getAttribute(`webview[data-id=${selectedTabId}]`, param);
},
+
* loadFixture(uri = '') {
const client = this.client;
yield client.setValue('#url-input', `${this.fixtureBaseUrl}${uri}`);
@@ -357,10 +373,12 @@ const Utils = {
});
}, 3000, 'expected to properly load fixture');
},
+
* getBrowserBarText() {
return yield this.client.getText('.url-breadcrumb');
},
- *pinCurrentTab() {
+
+ * pinCurrentTab() {
const client = this.client;
yield this.openAndFocusNewWindow(() => {
@@ -374,7 +392,7 @@ const Utils = {
const pinnedWebview = (yield client.windowHandles()).value.pop();
return pinnedWebview;
},
- *navigateTo(url) {
+ * navigateTo(url) {
const client = this.client;
yield client.setValue('#url-input', url);
yield client.submitForm('form.url');
@@ -386,19 +404,15 @@ const Utils = {
@param search: function that tells how to search by window
@param tries: amount of tries left until give up searching for
*/
- *getWindowByUrl(search, tries = 5) {
+ * getWindowByUrl(search, tries = 5) {
if (tries < 0) throw new Error('Couldn\'t select window using given parameters.');
-
- let windowHandles = (yield this.client.windowHandles()).value;
-
+ const windowHandles = (yield this.client.windowHandles()).value;
for (let handle in windowHandles) {
yield this.client.window(windowHandles[handle]);
-
const found = !!search(yield this.client.getUrl());
if (found) return true;
}
yield Q.delay(500);
- yield this.getWindowByUrl(search, --tries);
+ yield this.getWindowByUrl(search, --tries); //eslint-disable-line
}
-
};
diff --git a/tests/mist/basic.test.js b/tests/mist/basic.test.js
index cb3edcc89..71725b7ef 100644
--- a/tests/mist/basic.test.js
+++ b/tests/mist/basic.test.js
@@ -1,6 +1,4 @@
-const _ = require('underscore');
const Q = require('bluebird');
-const fs = require('fs');
const path = require('path');
const should = require('chai').should();
@@ -18,21 +16,17 @@ test['Sanity Check: main window is focused'] = function* () {
};
test['Browser bar should render urls with separators'] = function* () {
- const client = this.client;
-
yield this.navigateTo('http://localhost:8080/page1/page2?param=value#hash');
+ yield Q.delay(500);
yield this.waitForText('.url-breadcrumb', 'http://localhost:8080 ▸ page1 ▸ page2 ▸ param=value ▸ hash');
};
test['Browser bar should not render script tags on breadcrumb view'] = function* () { // ETH-01-001
- const client = this.client;
-
yield this.navigateTo('');
- yield client.waitUntil(() => {
- return client.getText('.url-breadcrumb').then((e) => {
- return /404\.html$/.test(e);
- });
- }, 8000, 'expected breadcrumb to render as HTML encoded');
+ yield Q.delay(1500);
+
+ const webviewErrorURL = yield this.getSelectedWebviewParam('src');
+ webviewErrorURL.should.match(/errorPages\/404\.html$/);
should.exist(yield this.getUiElement('form.url'));
should.not.exist(yield this.getUiElement('form.url script'));
@@ -43,8 +37,11 @@ test['Browser bar should not render script tags in disguise on breadcrumb view']
yield client.setValue('#url-input', '<script>alert()</script>');
const isUrlBlocked = (yield client.execute(() => { // Code executed in context of browser
- try { $('form.url').submit(); }
- catch(e) { return /Invalid URL/.test(e); }
+ try {
+ $('form.url').submit();
+ } catch (e) {
+ return /Invalid URL/.test(e);
+ }
return false;
})).value;
@@ -53,20 +50,18 @@ test['Browser bar should not render script tags in disguise on breadcrumb view']
};
test['Browser bar should not render script tags in disguise (2) on breadcrumb view'] = function* () { // ETH-01-001
- const client = this.client;
-
yield this.navigateTo('');
- yield client.waitUntil(() => {
- return client.getText('.url-breadcrumb').then((e) => {
- return /404\.html$/.test(e);
- });
- }, 5000, 'expected breadcrumb to render as HTML encoded');
+ yield Q.delay(1500);
should.exist(yield this.getUiElement('form.url'));
should.not.exist(yield this.getUiElement('form.url svg'));
should.not.exist(yield this.getUiElement('form.url script'));
+
+ const webviewErrorURL = yield this.getSelectedWebviewParam('src');
+ webviewErrorURL.should.match(/errorPages\/404\.html$/);
};
+
test['Browser bar should not render arbitrary code as HTML'] = function* () { // ETH-01-001
const client = this.client;
@@ -81,20 +76,18 @@ test['Browser bar should not execute JS'] = function* () { // ETH-01-001
const client = this.client;
yield this.navigateTo('');
- const mist = yield client.execute(() => { return window.mist }); // checking if `execute` works
- const pwned = yield client.execute(() => { return window.pwned });
+ const mist = yield client.execute(() => { return window.mist; }); // checking if `execute` works
+ const pwned = yield client.execute(() => { return window.pwned; });
should.exist(mist.value);
should.not.exist(pwned.value);
};
test['Should select Wallet and Browse tabs properly'] = function* () {
- const client = this.client;
- const walletTab = yield this.selectTab('wallet');
+ yield this.selectTab('wallet');
};
test['Load fixture page'] = function* () {
- const client = this.client;
yield this.loadFixture();
};
@@ -104,8 +97,11 @@ test['"http" protocol should be allowed on browser bar'] = function* () { // ETH
yield client.setValue('#url-input', `${this.fixtureBaseUrl}index.html`);
const isProtocolBlocked = (yield client.execute(() => { // Code executed in context of browser
- try { $('form.url').submit(); }
- catch(e) { return /Invalid URL/.test(e); }
+ try {
+ $('form.url').submit();
+ } catch (e) {
+ return /Invalid URL/.test(e);
+ }
return false;
})).value;
isProtocolBlocked.should.be.false;
@@ -119,11 +115,15 @@ test['"http" protocol should be allowed on browser bar'] = function* () { // ETH
test['"javascript" protocol should be disallowed on browser bar'] = function* () { // ETH-01-002
const client = this.client;
yield this.loadFixture();
- yield client.setValue('#url-input', 'javascript:window.close()');
+ yield client.setValue('#url-input', 'javascript:window.close()'); // eslint-disable-line no-script-url
const isProtocolBlocked = (yield client.execute(() => { // Code executed in context of browser
- try { $('form.url').submit(); }
- catch(e) { return /Invalid URL/.test(e); }
+ try {
+ $('form.url').submit();
+ }
+ catch (e) {
+ return /Invalid URL/.test(e);
+ }
return false;
})).value;
isProtocolBlocked.should.be.true;
@@ -139,8 +139,11 @@ test['"data" protocol should be disallowed on browser bar'] = function* () { //
yield client.setValue('#url-input', 'data:text/plain;charset=utf-8;base64,dGhpcyB0ZXN0IGlzIG9uIGZpcmU=');
const isProtocolBlocked = (yield client.execute(() => { // Code executed in context of browser
- try { $('form.url').submit(); }
- catch(e) { return /Invalid URL/.test(e); }
+ try {
+ $('form.url').submit();
+ } catch (e) {
+ return /Invalid URL/.test(e);
+ }
return false;
})).value;
isProtocolBlocked.should.be.true;
@@ -151,15 +154,16 @@ test['"data" protocol should be disallowed on browser bar'] = function* () { //
};
test['"file" protocol should be disallowed on browser bar'] = function* () { // ETH-01-012
- const client = this.client;
- const filePath = 'file://' + path.join(__dirname, '..', 'fixtures', 'index.html');
+ const filePath = `file://${path.join(__dirname, '..', 'fixtures', 'index.html')}`;
yield this.navigateTo(filePath);
- yield Q.delay(2500);
- const browserBarText = yield this.getBrowserBarText();
- browserBarText.should.match(/errorPages ▸ 400.html$/);
+ yield Q.delay(1000);
+
+ const webviewErrorURL = yield this.getSelectedWebviewParam('src');
+ webviewErrorURL.should.match(/errorPages\/400\.html$/);
};
+
test['Pin tab test'] = function* () {
const client = this.client;
const sidebarItems = (yield client.elements('.sidebar nav > ul > li')).value;
@@ -188,7 +192,6 @@ test['Browse tab should be changed to pinned tab if URLs are the same'] = functi
test['Wallet tab shouldn\'t have the page replaced if URLs does not match'] = function* () { // ETH-01-007
const client = this.client;
- const app = this;
yield this.selectTab('wallet');
yield this.navigateTo(`${this.fixtureBaseUrl}index.html?https://wallet.ethereum.org`);
@@ -201,12 +204,11 @@ test['Wallet tab shouldn\'t have the page replaced if URLs does not match'] = fu
test['Wallet tab shouldn\'t have the page replaced if URLs does not match - 2'] = function* () { // ETH-01-007
const client = this.client;
- const app = this;
yield this.selectTab('wallet');
// Now changing address via JS
yield client.setValue('#url-input', `${this.fixtureBaseUrl}index.html?https://wallet.ethereum.org`);
- const isProtocolBlocked = yield client.execute(() => { // Code executed in context of browser
+ yield client.execute(() => { // Code executed in context of browser
$('form.url').submit();
});
@@ -239,7 +241,7 @@ test['Links with target _popup should open inside Mist'] = function* () {
yield client.waitUntil(() => {
return client.getUrl((url) => {
return /index.html$/.test(url);
- })
+ });
});
};
@@ -260,13 +262,11 @@ test['Mist main webview should not redirect to arbitrary addresses'] = function*
// ETH-01-008
test['Mist main webview should not redirect to local files'] = function* () {
const client = this.client;
- const initialURL = yield client.getUrl();
+ const url = `${this.fixtureBaseUrl}redirect?to=file:///Users/ev/Desktop/keystore.txt`;
- yield this.navigateTo('https://cure53.de/exchange/8743653459838/ETH-01-008.php');
+ yield this.navigateTo(url);
+ yield Q.delay(1000);
- yield client.waitUntil(() => {
- return client.getText('.url-breadcrumb').then((e) => {
- return /400\.html$/.test(e);
- });
- }, 5000, 'expected a URL not allowed as a result');
+ const webviewErrorURL = yield this.getSelectedWebviewParam('src');
+ webviewErrorURL.should.match(/errorPages\/400\.html$/);
};