Fix eslint errors

This commit is contained in:
Yuya Ochiai
2016-09-25 23:14:01 +09:00
parent 16a18e64e6
commit 16788b5a6f
21 changed files with 1282 additions and 1078 deletions

View File

@@ -6,11 +6,11 @@ const http = require('http');
const env = require('../modules/environment');
describe('application', function() {
describe('application', function desc() {
this.timeout(10000);
const serverPort = 8181;
const testURL = `http://localhost:${serverPort}`
const testURL = `http://localhost:${serverPort}`;
const config = {
version: 1,
@@ -23,8 +23,8 @@ describe('application', function() {
}]
};
before(function() {
this.server = http.createServer(function(req, res) {
before(() => {
this.server = http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/html'
});
@@ -32,66 +32,68 @@ describe('application', function() {
}).listen(serverPort, '127.0.0.1');
});
beforeEach(function() {
beforeEach(() => {
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
this.app = env.getSpectronApp();
return this.app.start();
});
afterEach(function() {
afterEach(() => {
if (this.app && this.app.isRunning()) {
return this.app.stop()
return this.app.stop();
}
return true;
});
after(function(done) {
after((done) => {
this.server.close(done);
})
});
it('should NOT be able to call Node.js API in webview', function() {
it('should NOT be able to call Node.js API in webview', () => {
env.addClientCommands(this.app.client);
return this.app.client
.getAttribute('webview', 'nodeintegration').then((nodeintegration) => {
return this.app.client.
getAttribute('webview', 'nodeintegration').then((nodeintegration) => {
// nodeintegration is an array of string
nodeintegration.forEach((n) => {
n.should.equal('false');
});
})
}).
// webview is handled as a window by chromedriver.
.windowByIndex(1).isNodeEnabled().should.eventually.be.false
.windowByIndex(2).isNodeEnabled().should.eventually.be.false;
windowByIndex(1).isNodeEnabled().should.eventually.be.false.
windowByIndex(2).isNodeEnabled().should.eventually.be.false;
});
it('should NOT be able to call Node.js API in a new window', function() {
it('should NOT be able to call Node.js API in a new window', () => {
env.addClientCommands(this.app.client);
const client = this.app.client;
return this.app.client
.windowByIndex(1) // in the first webview
.execute(function() {
return this.app.client.
windowByIndex(1). // in the first webview
execute(() => {
open_window();
})
.waitUntil(function async() {
}).
waitUntil(() => {
return client.windowHandles().then((handles) => {
return handles.value.length === 4;
});
}, 5000, 'expected a new window')
.windowByIndex(3).isNodeEnabled().should.eventually.be.false;
}, 5000, 'expected a new window').
windowByIndex(3).isNodeEnabled().should.eventually.be.false;
});
it('should NOT be able to call eval() in any window', function() {
it('should NOT be able to call eval() in any window', () => {
env.addClientCommands(this.app.client);
const tryEval = (index) => {
return this.app.client
.windowByIndex(index)
.execute(function() {
return this.app.client.
windowByIndex(index).
execute(() => {
return eval('1 + 1');
}).should.eventually.be.rejected;
};
const tryEvalInSettingsPage = () => {
return this.app.client
.windowByIndex(0)
.loadSettingsPage()
.execute(function() {
return this.app.client.
windowByIndex(0).
loadSettingsPage().
execute(() => {
return eval('1 + 1');
}).should.eventually.be.rejected;
};