Remove unneeded returns

This commit is contained in:
Kevin Sawicki 2016-02-16 17:39:11 -08:00
parent e63c3c727a
commit 12adaa0570
14 changed files with 773 additions and 826 deletions

View file

@ -15,28 +15,27 @@ describe('chromium feature', function() {
if (listener != null) {
window.removeEventListener('message', listener);
}
return listener = null;
listener = null;
});
xdescribe('heap snapshot', function() {
return it('does not crash', function() {
return process.atomBinding('v8_util').takeHeapSnapshot();
it('does not crash', function() {
process.atomBinding('v8_util').takeHeapSnapshot();
});
});
describe('sending request of http protocol urls', function() {
return it('does not crash', function(done) {
var server;
it('does not crash', function(done) {
this.timeout(5000);
server = http.createServer(function(req, res) {
var server = http.createServer(function(req, res) {
res.end();
server.close();
return done();
done();
});
return server.listen(0, '127.0.0.1', function() {
var port;
port = server.address().port;
return $.get("http://127.0.0.1:" + port);
server.listen(0, '127.0.0.1', function() {
var port = server.address().port;
$.get("http://127.0.0.1:" + port);
});
});
});
@ -46,7 +45,7 @@ describe('chromium feature', function() {
var w = null;
afterEach(function() {
return w != null ? w.destroy() : void 0;
w != null ? w.destroy() : void 0;
});
it('is set correctly when window is not shown', function(done) {
@ -55,41 +54,42 @@ describe('chromium feature', function() {
});
w.webContents.on('ipc-message', function(event, args) {
assert.deepEqual(args, ['hidden', true]);
return done();
done();
});
return w.loadURL(url);
w.loadURL(url);
});
return it('is set correctly when window is inactive', function(done) {
it('is set correctly when window is inactive', function(done) {
w = new BrowserWindow({
show: false
});
w.webContents.on('ipc-message', function(event, args) {
assert.deepEqual(args, ['hidden', false]);
return done();
done();
});
w.showInactive();
return w.loadURL(url);
w.loadURL(url);
});
});
xdescribe('navigator.webkitGetUserMedia', function() {
return it('calls its callbacks', function(done) {
it('calls its callbacks', function(done) {
this.timeout(5000);
return navigator.webkitGetUserMedia({
navigator.webkitGetUserMedia({
audio: true,
video: false
}, function() {
return done();
done();
}, function() {
return done();
done();
});
});
});
describe('navigator.language', function() {
return it('should not be empty', function() {
return assert.notEqual(navigator.language, '');
it('should not be empty', function() {
assert.notEqual(navigator.language, '');
});
});
@ -98,28 +98,28 @@ describe('chromium feature', function() {
var w = null;
afterEach(function() {
return w != null ? w.destroy() : void 0;
w != null ? w.destroy() : void 0;
});
return it('should register for file scheme', function(done) {
it('should register for file scheme', function(done) {
w = new BrowserWindow({
show: false
});
w.webContents.on('ipc-message', function(event, args) {
if (args[0] === 'reload') {
return w.webContents.reload();
w.webContents.reload();
} else if (args[0] === 'error') {
return done('unexpected error : ' + args[1]);
done('unexpected error : ' + args[1]);
} else if (args[0] === 'response') {
assert.equal(args[1], 'Hello from serviceWorker!');
return session.defaultSession.clearStorageData({
session.defaultSession.clearStorageData({
storages: ['serviceworkers']
}, function() {
return done();
done();
});
}
});
return w.loadURL(url);
sw.loadURL(url);
});
});
@ -127,11 +127,10 @@ describe('chromium feature', function() {
this.timeout(20000);
it('returns a BrowserWindowProxy object', function() {
var b;
b = window.open('about:blank', '', 'show=no');
var b = window.open('about:blank', '', 'show=no');
assert.equal(b.closed, false);
assert.equal(b.constructor.name, 'BrowserWindowProxy');
return b.close();
b.close();
});
it('accepts "node-integration" as feature', function(done) {
@ -139,10 +138,10 @@ describe('chromium feature', function() {
listener = function(event) {
assert.equal(event.data, 'undefined');
b.close();
return done();
done();
};
window.addEventListener('message', listener);
return b = window.open("file://" + fixtures + "/pages/window-opener-node.html", '', 'nodeIntegration=no,show=no');
b = window.open("file://" + fixtures + "/pages/window-opener-node.html", '', 'nodeIntegration=no,show=no');
});
it('inherit options of parent window', function(done) {
@ -152,13 +151,13 @@ describe('chromium feature', function() {
ref1 = remote.getCurrentWindow().getSize(), width = ref1[0], height = ref1[1];
assert.equal(event.data, "size: " + width + " " + height);
b.close();
return done();
done();
};
window.addEventListener('message', listener);
return b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', 'show=no');
b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', 'show=no');
});
return it('does not override child options', function(done) {
it('does not override child options', function(done) {
var b, size;
size = {
width: 350,
@ -167,45 +166,48 @@ describe('chromium feature', function() {
listener = function(event) {
assert.equal(event.data, "size: " + size.width + " " + size.height);
b.close();
return done();
done();
};
window.addEventListener('message', listener);
return b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', "show=no,width=" + size.width + ",height=" + size.height);
b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', "show=no,width=" + size.width + ",height=" + size.height);
});
});
describe('window.opener', function() {
var url, w;
this.timeout(10000);
url = "file://" + fixtures + "/pages/window-opener.html";
w = null;
var url = "file://" + fixtures + "/pages/window-opener.html";
var w = null;
afterEach(function() {
return w != null ? w.destroy() : void 0;
w != null ? w.destroy() : void 0;
});
it('is null for main window', function(done) {
w = new BrowserWindow({
show: false
});
w.webContents.on('ipc-message', function(event, args) {
assert.deepEqual(args, ['opener', null]);
return done();
done();
});
return w.loadURL(url);
w.loadURL(url);
});
return it('is not null for window opened by window.open', function(done) {
it('is not null for window opened by window.open', function(done) {
var b;
listener = function(event) {
assert.equal(event.data, 'object');
b.close();
return done();
done();
};
window.addEventListener('message', listener);
return b = window.open(url, '', 'show=no');
b = window.open(url, '', 'show=no');
});
});
describe('window.postMessage', function() {
return it('sets the source and origin correctly', function(done) {
it('sets the source and origin correctly', function(done) {
var b, sourceId;
sourceId = remote.getCurrentWindow().id;
listener = function(event) {
@ -218,47 +220,47 @@ describe('chromium feature', function() {
assert.equal(message.sourceEqualsOpener, true);
assert.equal(message.sourceId, sourceId);
assert.equal(event.origin, 'file://');
return done();
done();
};
window.addEventListener('message', listener);
b = window.open("file://" + fixtures + "/pages/window-open-postMessage.html", '', 'show=no');
return BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() {
return b.postMessage('testing', '*');
BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() {
b.postMessage('testing', '*');
});
});
});
describe('window.opener.postMessage', function() {
return it('sets source and origin correctly', function(done) {
it('sets source and origin correctly', function(done) {
var b;
listener = function(event) {
window.removeEventListener('message', listener);
b.close();
assert.equal(event.source, b);
assert.equal(event.origin, 'file://');
return done();
done();
};
window.addEventListener('message', listener);
return b = window.open("file://" + fixtures + "/pages/window-opener-postMessage.html", '', 'show=no');
b = window.open("file://" + fixtures + "/pages/window-opener-postMessage.html", '', 'show=no');
});
});
describe('creating a Uint8Array under browser side', function() {
return it('does not crash', function() {
it('does not crash', function() {
var RUint8Array;
RUint8Array = remote.getGlobal('Uint8Array');
return new RUint8Array;
new RUint8Array;
});
});
describe('webgl', function() {
return it('can be get as context in canvas', function() {
it('can be get as context in canvas', function() {
var webgl;
if (process.platform === 'linux') {
return;
}
webgl = document.createElement('canvas').getContext('webgl');
return assert.notEqual(webgl, null);
assert.notEqual(webgl, null);
});
});
@ -270,20 +272,20 @@ describe('chromium feature', function() {
worker.onmessage = function(event) {
assert.equal(event.data, message);
worker.terminate();
return done();
done();
};
return worker.postMessage(message);
worker.postMessage(message);
});
return it('SharedWorker can work', function(done) {
it('SharedWorker can work', function(done) {
var message, worker;
worker = new SharedWorker('../fixtures/workers/shared_worker.js');
message = 'ping';
worker.port.onmessage = function(event) {
assert.equal(event.data, message);
return done();
done();
};
return worker.port.postMessage(message);
worker.port.postMessage(message);
});
});
@ -291,28 +293,28 @@ describe('chromium feature', function() {
var iframe = null;
beforeEach(function() {
return iframe = document.createElement('iframe');
iframe = document.createElement('iframe');
});
afterEach(function() {
return document.body.removeChild(iframe);
document.body.removeChild(iframe);
});
return it('does not have node integration', function(done) {
it('does not have node integration', function(done) {
iframe.src = "file://" + fixtures + "/pages/set-global.html";
document.body.appendChild(iframe);
return iframe.onload = function() {
iframe.onload = function() {
assert.equal(iframe.contentWindow.test, 'undefined undefined undefined');
return done();
done();
};
});
});
describe('storage', function() {
return it('requesting persitent quota works', function(done) {
return navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function(grantedBytes) {
it('requesting persitent quota works', function(done) {
navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function(grantedBytes) {
assert.equal(grantedBytes, 1048576);
return done();
done();
});
});
});
@ -324,12 +326,12 @@ describe('chromium feature', function() {
afterEach(function() {
wss.close();
return server.close();
server.close();
});
return it('has user agent', function(done) {
it('has user agent', function(done) {
server = http.createServer();
return server.listen(0, '127.0.0.1', function() {
server.listen(0, '127.0.0.1', function() {
var port = server.address().port;
wss = new WebSocketServer({
server: server
@ -337,9 +339,9 @@ describe('chromium feature', function() {
wss.on('error', done);
wss.on('connection', function(ws) {
if (ws.upgradeReq.headers['user-agent']) {
return done();
done();
} else {
return done('user agent is empty');
done('user agent is empty');
}
});
new WebSocket("ws://127.0.0.1:" + port);
@ -347,7 +349,7 @@ describe('chromium feature', function() {
});
});
return describe('Promise', function() {
describe('Promise', function() {
it('resolves correctly in Node.js calls', function(done) {
document.registerElement('x-element', {
prototype: Object.create(HTMLElement.prototype, {
@ -356,18 +358,17 @@ describe('chromium feature', function() {
}
})
});
return setImmediate(function() {
var called;
called = false;
setImmediate(function() {
var called = false;
Promise.resolve().then(function() {
return done(called ? void 0 : new Error('wrong sequence'));
done(called ? void 0 : new Error('wrong sequence'));
});
document.createElement('x-element');
return called = true;
called = true;
});
});
return it('resolves correctly in Electron calls', function(done) {
it('resolves correctly in Electron calls', function(done) {
document.registerElement('y-element', {
prototype: Object.create(HTMLElement.prototype, {
createdCallback: {
@ -375,14 +376,14 @@ describe('chromium feature', function() {
}
})
});
return remote.getGlobal('setImmediate')(function() {
remote.getGlobal('setImmediate')(function() {
var called;
called = false;
Promise.resolve().then(function() {
return done(called ? void 0 : new Error('wrong sequence'));
done(called ? void 0 : new Error('wrong sequence'));
});
document.createElement('y-element');
return called = true;
called = true;
});
});
});