Merge pull request #4172 from atom/enable-eslint-rules

Enable more eslint rules
This commit is contained in:
Kevin Sawicki 2016-01-21 09:56:07 -07:00
commit fda480d1aa
40 changed files with 806 additions and 912 deletions

View file

@ -60,9 +60,8 @@ var fn = function(name) {
return webContents.emit.apply(webContents, [name, event].concat(slice.call(args))); return webContents.emit.apply(webContents, [name, event].concat(slice.call(args)));
}); });
}; };
var i, len, name; var i, len;
for (i = 0, len = ref1.length; i < len; i++) { for (i = 0, len = ref1.length; i < len; i++) {
name = ref1[i];
fn(ref1[i]); fn(ref1[i]);
} }

View file

@ -13,7 +13,7 @@ const exeName = path.basename(process.execPath);
// Spawn a command and invoke the callback when it completes with an error // Spawn a command and invoke the callback when it completes with an error
// and the output from standard out. // and the output from standard out.
var spawnUpdate = function(args, detached, callback) { var spawnUpdate = function(args, detached, callback) {
var error, error1, errorEmitted, spawnedProcess, stderr, stdout; var error, errorEmitted, spawnedProcess, stderr, stdout;
try { try {
spawnedProcess = spawn(updateExe, args, { spawnedProcess = spawn(updateExe, args, {
detached: detached detached: detached
@ -58,23 +58,22 @@ var spawnUpdate = function(args, detached, callback) {
}; };
// Start an instance of the installed app. // Start an instance of the installed app.
exports.processStart = function(callback) { exports.processStart = function() {
return spawnUpdate(['--processStart', exeName], true, function() {}); return spawnUpdate(['--processStart', exeName], true, function() {});
}; };
// Download the releases specified by the URL and write new results to stdout. // Download the releases specified by the URL and write new results to stdout.
exports.download = function(updateURL, callback) { exports.download = function(updateURL, callback) {
return spawnUpdate(['--download', updateURL], false, function(error, stdout) { return spawnUpdate(['--download', updateURL], false, function(error, stdout) {
var error1, json, ref, ref1, update; var json, ref, ref1, update;
if (error != null) { if (error != null) {
return callback(error); return callback(error);
} }
try { try {
// Last line of output is the JSON details about the releases // Last line of output is the JSON details about the releases
json = stdout.trim().split('\n').pop(); json = stdout.trim().split('\n').pop();
update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === "function" ? ref1.pop() : void 0 : void 0 : void 0; update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === "function" ? ref1.pop() : void 0 : void 0 : void 0;
} catch (error1) { } catch (jsonError) {
return callback("Invalid result:\n" + stdout); return callback("Invalid result:\n" + stdout);
} }
return callback(null, update); return callback(null, update);
@ -90,11 +89,10 @@ exports.update = function(updateURL, callback) {
// Is the Update.exe installed with the current application? // Is the Update.exe installed with the current application?
exports.supported = function() { exports.supported = function() {
var error1;
try { try {
fs.accessSync(updateExe, fs.R_OK); fs.accessSync(updateExe, fs.R_OK);
return true; return true;
} catch (error1) { } catch (error) {
return false; return false;
} }
}; };

View file

@ -56,7 +56,7 @@ BrowserWindow.prototype._init = function() {
// Change window title to page title. // Change window title to page title.
this.webContents.on('page-title-updated', (function(_this) { this.webContents.on('page-title-updated', (function(_this) {
return function(event, title, explicitSet) { return function(event, title) {
_this.emit('page-title-updated', event, title); _this.emit('page-title-updated', event, title);
if (!event.defaultPrevented) { if (!event.defaultPrevented) {
return _this.setTitle(title); return _this.setTitle(title);

View file

@ -5,7 +5,6 @@ const v8Util = process.atomBinding('v8_util');
var slice = [].slice; var slice = [].slice;
var includes = [].includes; var includes = [].includes;
var indexOf = [].indexOf;
var fileDialogProperties = { var fileDialogProperties = {
openFile: 1 << 0, openFile: 1 << 0,

View file

@ -1,6 +1,4 @@
var MenuItem, methodInBrowserWindow, nextCommandId, rolesMap, v8Util; var MenuItem, methodInBrowserWindow, nextCommandId, rolesMap;
v8Util = process.atomBinding('v8_util');
nextCommandId = 0; nextCommandId = 0;

View file

@ -210,7 +210,7 @@ Menu.prototype.insert = function(pos, item) {
return v8Util.getHiddenValue(item, 'checked'); return v8Util.getHiddenValue(item, 'checked');
}, },
set: (function(_this) { set: (function(_this) {
return function(val) { return function() {
var j, len, otherItem, ref1; var j, len, otherItem, ref1;
ref1 = _this.groupsMap[item.groupId]; ref1 = _this.groupsMap[item.groupId];
for (j = 0, len = ref1.length; j < len; j++) { for (j = 0, len = ref1.length; j < len; j++) {

View file

@ -3,7 +3,6 @@
const EventEmitter = require('events').EventEmitter; const EventEmitter = require('events').EventEmitter;
const deprecate = require('electron').deprecate; const deprecate = require('electron').deprecate;
const ipcMain = require('electron').ipcMain; const ipcMain = require('electron').ipcMain;
const session = require('electron').session;
const NavigationController = require('electron').NavigationController; const NavigationController = require('electron').NavigationController;
const Menu = require('electron').Menu; const Menu = require('electron').Menu;
@ -62,7 +61,7 @@ const webFrameMethods = [
'insertText', 'insertText',
'setZoomFactor', 'setZoomFactor',
'setZoomLevel', 'setZoomLevel',
'setZoomLevelLimits', 'setZoomLevelLimits'
]; ];
let wrapWebContents = function(webContents) { let wrapWebContents = function(webContents) {

View file

@ -144,23 +144,29 @@ app.once('ready', function() {
submenu: [ submenu: [
{ {
label: 'Learn More', label: 'Learn More',
click: function() { shell.openExternal('http://electron.atom.io') } click: function() {
shell.openExternal('http://electron.atom.io');
}
}, },
{ {
label: 'Documentation', label: 'Documentation',
click: function() { click: function() {
shell.openExternal( shell.openExternal(
`https://github.com/atom/electron/tree/v${process.versions.electron}/docs#readme` `https://github.com/atom/electron/tree/v${process.versions.electron}/docs#readme`
) );
} }
}, },
{ {
label: 'Community Discussions', label: 'Community Discussions',
click: function() { shell.openExternal('https://discuss.atom.io/c/electron') } click: function() {
shell.openExternal('https://discuss.atom.io/c/electron');
}
}, },
{ {
label: 'Search Issues', label: 'Search Issues',
click: function() { shell.openExternal('https://github.com/atom/electron/issues') } click: function() {
shell.openExternal('https://github.com/atom/electron/issues');
}
} }
] ]
}, },

View file

@ -50,25 +50,24 @@ var loadedExtensions = null;
var loadedExtensionsPath = null; var loadedExtensionsPath = null;
app.on('will-quit', function() { app.on('will-quit', function() {
var e, error1, error2;
try { try {
loadedExtensions = Object.keys(extensionInfoMap).map(function(key) { loadedExtensions = Object.keys(extensionInfoMap).map(function(key) {
return extensionInfoMap[key].srcDirectory; return extensionInfoMap[key].srcDirectory;
}); });
try { try {
fs.mkdirSync(path.dirname(loadedExtensionsPath)); fs.mkdirSync(path.dirname(loadedExtensionsPath));
} catch (error1) { } catch (error) {
e = error1; // Ignore error
} }
return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions)); return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
} catch (error2) { } catch (error) {
e = error2; // Ignore error
} }
}); });
// We can not use protocol or BrowserWindow until app is ready. // We can not use protocol or BrowserWindow until app is ready.
app.once('ready', function() { app.once('ready', function() {
var BrowserWindow, chromeExtensionHandler, e, error1, i, init, len, protocol, srcDirectory; var BrowserWindow, chromeExtensionHandler, i, init, len, protocol, srcDirectory;
protocol = electron.protocol, BrowserWindow = electron.BrowserWindow; protocol = electron.protocol, BrowserWindow = electron.BrowserWindow;
// Load persistented extensions. // Load persistented extensions.
@ -84,8 +83,8 @@ app.once('ready', function() {
srcDirectory = loadedExtensions[i]; srcDirectory = loadedExtensions[i];
getExtensionInfoFromPath(srcDirectory); getExtensionInfoFromPath(srcDirectory);
} }
} catch (error1) { } catch (error) {
e = error1; // Ignore error
} }
// The chrome-extension: can map a extension URL request to real file path. // The chrome-extension: can map a extension URL request to real file path.

View file

@ -19,7 +19,7 @@ var moveLastToFirst = function(list) {
}; };
// Generate guestInstanceId. // Generate guestInstanceId.
var getNextInstanceId = function(webContents) { var getNextInstanceId = function() {
return ++nextInstanceId; return ++nextInstanceId;
}; };
@ -109,8 +109,7 @@ var createGuest = function(embedder, params) {
// Dispatch events to embedder. // Dispatch events to embedder.
fn = function(event) { fn = function(event) {
return guest.on(event, function() { return guest.on(event, function() {
var _, args; var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
_ = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + guest.viewInstanceId, event].concat(slice.call(args))); return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + guest.viewInstanceId, event].concat(slice.call(args)));
}); });
}; };
@ -128,8 +127,7 @@ var createGuest = function(embedder, params) {
// Autosize. // Autosize.
guest.on('size-changed', function() { guest.on('size-changed', function() {
var _, args; var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
_ = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + guest.viewInstanceId].concat(slice.call(args))); return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + guest.viewInstanceId].concat(slice.call(args)));
}); });
return id; return id;

View file

@ -1,8 +1,6 @@
const ipcMain = require('electron').ipcMain; const ipcMain = require('electron').ipcMain;
const BrowserWindow = require('electron').BrowserWindow; const BrowserWindow = require('electron').BrowserWindow;
const v8Util = process.atomBinding('v8_util');
var hasProp = {}.hasOwnProperty; var hasProp = {}.hasOwnProperty;
var slice = [].slice; var slice = [].slice;
var frameToGuest = {}; var frameToGuest = {};
@ -102,8 +100,8 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function(event, guest
}); });
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function() { ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function() {
var args, event, guestId, method, ref1; var args, guestId, method, ref1;
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : []; guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0; return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0;
}); });
@ -120,7 +118,7 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function(event,
}); });
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function() { ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function() {
var args, event, guestId, method, ref1, ref2; var args, guestId, method, ref1, ref2;
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : []; guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0; return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0;
}); });

View file

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const path = require('path');
const electron = require('electron'); const electron = require('electron');
const ipcMain = electron.ipcMain; const ipcMain = electron.ipcMain;
const objectsRegistry = require('./objects-registry'); const objectsRegistry = require('./objects-registry');
@ -183,7 +182,7 @@ var unwrapArgs = function(sender, args) {
// Call a function and send reply asynchronously if it's a an asynchronous // Call a function and send reply asynchronously if it's a an asynchronous
// style function and the caller didn't pass a callback. // style function and the caller didn't pass a callback.
var callFunction = function(event, func, caller, args) { var callFunction = function(event, func, caller, args) {
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret; var funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous'); funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
funcPassedCallback = typeof args[args.length - 1] === 'function'; funcPassedCallback = typeof args[args.length - 1] === 'function';
try { try {
@ -196,14 +195,12 @@ var callFunction = function(event, func, caller, args) {
ret = func.apply(caller, args); ret = func.apply(caller, args);
return event.returnValue = valueToMeta(event.sender, ret, true); return event.returnValue = valueToMeta(event.sender, ret, true);
} }
} catch (error1) { } catch (error) {
e = error1;
// Catch functions thrown further down in function invocation and wrap // Catch functions thrown further down in function invocation and wrap
// them with the function name so it's easier to trace things like // them with the function name so it's easier to trace things like
// `Error processing argument -1.` // `Error processing argument -1.`
funcName = (ref = func.name) != null ? ref : "anonymous"; funcName = (ref = func.name) != null ? ref : "anonymous";
throw new Error("Could not call remote function `" + funcName + "`. Check that the function signature is correct. Underlying error: " + e.message); throw new Error("Could not call remote function `" + funcName + "`. Check that the function signature is correct. Underlying error: " + error.message);
} }
}; };
@ -213,42 +210,34 @@ process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
}); });
ipcMain.on('ATOM_BROWSER_REQUIRE', function(event, module) { ipcMain.on('ATOM_BROWSER_REQUIRE', function(event, module) {
var e, error1;
try { try {
return event.returnValue = valueToMeta(event.sender, process.mainModule.require(module)); return event.returnValue = valueToMeta(event.sender, process.mainModule.require(module));
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_GET_BUILTIN', function(event, module) { ipcMain.on('ATOM_BROWSER_GET_BUILTIN', function(event, module) {
var e, error1;
try { try {
return event.returnValue = valueToMeta(event.sender, electron[module]); return event.returnValue = valueToMeta(event.sender, electron[module]);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_GLOBAL', function(event, name) { ipcMain.on('ATOM_BROWSER_GLOBAL', function(event, name) {
var e, error1;
try { try {
return event.returnValue = valueToMeta(event.sender, global[name]); return event.returnValue = valueToMeta(event.sender, global[name]);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_CURRENT_WINDOW', function(event) { ipcMain.on('ATOM_BROWSER_CURRENT_WINDOW', function(event) {
var e, error1;
try { try {
return event.returnValue = valueToMeta(event.sender, event.sender.getOwnerBrowserWindow()); return event.returnValue = valueToMeta(event.sender, event.sender.getOwnerBrowserWindow());
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
@ -257,7 +246,7 @@ ipcMain.on('ATOM_BROWSER_CURRENT_WEB_CONTENTS', function(event) {
}); });
ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) { ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) {
var constructor, e, error1, obj; var constructor, obj;
try { try {
args = unwrapArgs(event.sender, args); args = unwrapArgs(event.sender, args);
constructor = objectsRegistry.get(id); constructor = objectsRegistry.get(id);
@ -266,26 +255,24 @@ ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) {
// http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible // http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args))); obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
return event.returnValue = valueToMeta(event.sender, obj); return event.returnValue = valueToMeta(event.sender, obj);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_FUNCTION_CALL', function(event, id, args) { ipcMain.on('ATOM_BROWSER_FUNCTION_CALL', function(event, id, args) {
var e, error1, func; var func;
try { try {
args = unwrapArgs(event.sender, args); args = unwrapArgs(event.sender, args);
func = objectsRegistry.get(id); func = objectsRegistry.get(id);
return callFunction(event, func, global, args); return callFunction(event, func, global, args);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function(event, id, method, args) { ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function(event, id, method, args) {
var constructor, e, error1, obj; var constructor, obj;
try { try {
args = unwrapArgs(event.sender, args); args = unwrapArgs(event.sender, args);
constructor = objectsRegistry.get(id)[method]; constructor = objectsRegistry.get(id)[method];
@ -293,44 +280,40 @@ ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function(event, id, method, args)
// Call new with array of arguments. // Call new with array of arguments.
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args))); obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
return event.returnValue = valueToMeta(event.sender, obj); return event.returnValue = valueToMeta(event.sender, obj);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_MEMBER_CALL', function(event, id, method, args) { ipcMain.on('ATOM_BROWSER_MEMBER_CALL', function(event, id, method, args) {
var e, error1, obj; var obj;
try { try {
args = unwrapArgs(event.sender, args); args = unwrapArgs(event.sender, args);
obj = objectsRegistry.get(id); obj = objectsRegistry.get(id);
return callFunction(event, obj[method], obj, args); return callFunction(event, obj[method], obj, args);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_MEMBER_SET', function(event, id, name, value) { ipcMain.on('ATOM_BROWSER_MEMBER_SET', function(event, id, name, value) {
var e, error1, obj; var obj;
try { try {
obj = objectsRegistry.get(id); obj = objectsRegistry.get(id);
obj[name] = value; obj[name] = value;
return event.returnValue = null; return event.returnValue = null;
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_MEMBER_GET', function(event, id, name) { ipcMain.on('ATOM_BROWSER_MEMBER_GET', function(event, id, name) {
var e, error1, obj; var obj;
try { try {
obj = objectsRegistry.get(id); obj = objectsRegistry.get(id);
return event.returnValue = valueToMeta(event.sender, obj[name]); return event.returnValue = valueToMeta(event.sender, obj[name]);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
@ -339,25 +322,23 @@ ipcMain.on('ATOM_BROWSER_DEREFERENCE', function(event, id) {
}); });
ipcMain.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function(event, guestInstanceId) { ipcMain.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function(event, guestInstanceId) {
var e, error1, guestViewManager; var guestViewManager;
try { try {
guestViewManager = require('./guest-view-manager'); guestViewManager = require('./guest-view-manager');
return event.returnValue = valueToMeta(event.sender, guestViewManager.getGuest(guestInstanceId)); return event.returnValue = valueToMeta(event.sender, guestViewManager.getGuest(guestInstanceId));
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });
ipcMain.on('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function() { ipcMain.on('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function() {
var args, e, error1, event, guest, guestInstanceId, guestViewManager, method; var args, event, guest, guestInstanceId, guestViewManager, method;
event = arguments[0], guestInstanceId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : []; event = arguments[0], guestInstanceId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
try { try {
guestViewManager = require('./guest-view-manager'); guestViewManager = require('./guest-view-manager');
guest = guestViewManager.getGuest(guestInstanceId); guest = guestViewManager.getGuest(guestInstanceId);
return guest[method].apply(guest, args); return guest[method].apply(guest, args);
} catch (error1) { } catch (error) {
e = error1; return event.returnValue = exceptionToMeta(error);
return event.returnValue = exceptionToMeta(e);
} }
}); });

View file

@ -12,7 +12,7 @@ class CallbacksRegistry {
add(callback) { add(callback) {
// The callback is already added. // The callback is already added.
var filenameAndLine, id, location, match, ref, regexp, stackString, x; var filenameAndLine, id, location, match, ref, regexp, stackString;
id = v8Util.getHiddenValue(callback, 'callbackId'); id = v8Util.getHiddenValue(callback, 'callbackId');
if (id != null) { if (id != null) {
return id; return id;
@ -24,14 +24,15 @@ class CallbacksRegistry {
regexp = /at (.*)/gi; regexp = /at (.*)/gi;
stackString = (new Error).stack; stackString = (new Error).stack;
while ((match = regexp.exec(stackString)) !== null) { while ((match = regexp.exec(stackString)) !== null) {
x = match[0], location = match[1]; location = match[1];
if (location.indexOf('(native)') !== -1) { if (location.indexOf('(native)') !== -1) {
continue; continue;
} }
if (location.indexOf('atom.asar') !== -1) { if (location.indexOf('atom.asar') !== -1) {
continue; continue;
} }
ref = /([^\/^\)]*)\)?$/gi.exec(location), x = ref[0], filenameAndLine = ref[1]; ref = /([^\/^\)]*)\)?$/gi.exec(location);
filenameAndLine = ref[1];
break; break;
} }
this.callbacks[id] = callback; this.callbacks[id] = callback;
@ -62,4 +63,4 @@ class CallbacksRegistry {
} }
} }
module.exports = CallbacksRegistry module.exports = CallbacksRegistry;

View file

@ -1,4 +1,3 @@
const fs = require('fs');
const os = require('os'); const os = require('os');
const path = require('path'); const path = require('path');
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn;

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,14 @@
(function () { (function () {
return function(process, require, asarSource) { return function(process, require, asarSource) {
var createArchive, source; // Make asar.coffee accessible via "require".
createArchive = process.binding('atom_common_asar').createArchive; process.binding('natives').ATOM_SHELL_ASAR = asarSource;
// Make asar.coffee accessible via "require". // Monkey-patch the fs module.
process.binding('natives').ATOM_SHELL_ASAR = asarSource; require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs'));
// Monkey-patch the fs module. // Make graceful-fs work with asar.
require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs')); var source = process.binding('natives');
source['original-fs'] = source.fs;
// Make graceful-fs work with asar. return source['fs'] = "var src = '(function (exports, require, module, __filename, __dirname) { ' +\n process.binding('natives')['original-fs'] +\n ' });';\nvar vm = require('vm');\nvar fn = vm.runInThisContext(src, { filename: 'fs.js' });\nfn(exports, require, module);\nvar asar = require('ATOM_SHELL_ASAR');\nasar.wrapFsWithAsar(exports);";
source = process.binding('natives'); };
source['original-fs'] = source.fs; })();
return source['fs'] = "var src = '(function (exports, require, module, __filename, __dirname) { ' +\n process.binding('natives')['original-fs'] +\n ' });';\nvar vm = require('vm');\nvar fn = vm.runInThisContext(src, { filename: 'fs.js' });\nfn(exports, require, module);\nvar asar = require('ATOM_SHELL_ASAR');\nasar.wrapFsWithAsar(exports);";
};
})()

View file

@ -1,15 +1,12 @@
const fs = require('fs');
const path = require('path'); const path = require('path');
const timers = require('timers'); const timers = require('timers');
const Module = require('module'); const Module = require('module');
process.atomBinding = function(name) { process.atomBinding = function(name) {
var e, error;
try { try {
return process.binding("atom_" + process.type + "_" + name); return process.binding("atom_" + process.type + "_" + name);
} catch (error) { } catch (error) {
e = error; if (/No such module/.test(error.message)) {
if (/No such module/.test(e.message)) {
return process.binding("atom_common_" + name); return process.binding("atom_common_" + name);
} }
} }

View file

@ -1,4 +1,3 @@
const EventEmitter = require('events').EventEmitter;
const binding = process.atomBinding('ipc'); const binding = process.atomBinding('ipc');
const v8Util = process.atomBinding('v8_util'); const v8Util = process.atomBinding('v8_util');

View file

@ -11,8 +11,8 @@ deprecate.warn('ipc module', 'require("electron").ipcRenderer');
var ipc = new EventEmitter; var ipc = new EventEmitter;
ipcRenderer.emit = function() { ipcRenderer.emit = function() {
var args, channel, event; var channel = arguments[0];
channel = arguments[0], event = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : []; var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
ipc.emit.apply(ipc, [channel].concat(slice.call(args))); ipc.emit.apply(ipc, [channel].concat(slice.call(args)));
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments); return EventEmitter.prototype.emit.apply(ipcRenderer, arguments);
}; };

View file

@ -87,7 +87,7 @@ var wrapArgs = function(args, visited) {
// Convert meta data from browser into real value. // Convert meta data from browser into real value.
var metaToValue = function(meta) { var metaToValue = function(meta) {
var RemoteFunction, el, i, j, len, len1, member, ref1, ref2, results, ret; var el, i, j, len, len1, member, ref1, ref2, results, ret;
switch (meta.type) { switch (meta.type) {
case 'value': case 'value':
return meta.value; return meta.value;
@ -111,11 +111,10 @@ var metaToValue = function(meta) {
return new Date(meta.value); return new Date(meta.value);
case 'exception': case 'exception':
throw new Error(meta.message + "\n" + meta.stack); throw new Error(meta.message + "\n" + meta.stack);
break;
default: default:
if (meta.type === 'function') { if (meta.type === 'function') {
// A shadow class to represent the remote function object. // A shadow class to represent the remote function object.
ret = RemoteFunction = (function() { ret = (function() {
function RemoteFunction() { function RemoteFunction() {
var obj; var obj;
if (this.constructor === RemoteFunction) { if (this.constructor === RemoteFunction) {
@ -190,8 +189,7 @@ var metaToPlainObject = function(meta) {
// This function's content should not be inlined into metaToValue, otherwise V8 // This function's content should not be inlined into metaToValue, otherwise V8
// may consider it circular reference. // may consider it circular reference.
var createRemoteMemberFunction = function(metaId, name) { var createRemoteMemberFunction = function(metaId, name) {
var RemoteMemberFunction; return (function() {
return RemoteMemberFunction = (function() {
function RemoteMemberFunction() { function RemoteMemberFunction() {
var ret; var ret;
if (this.constructor === RemoteMemberFunction) { if (this.constructor === RemoteMemberFunction) {

View file

@ -2,19 +2,15 @@
const events = require('events'); const events = require('events');
const path = require('path'); const path = require('path');
const url = require('url');
const Module = require('module'); const Module = require('module');
// We modified the original process.argv to let node.js load the // We modified the original process.argv to let node.js load the
// atom-renderer.js, we need to restore it here. // atom-renderer.js, we need to restore it here.
process.argv.splice(1, 1); process.argv.splice(1, 1);
// Clear search paths. // Clear search paths.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths')); require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
// Import common settings. // Import common settings.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')); require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));

View file

@ -43,7 +43,7 @@ var convertToMenuTemplate = function(items) {
return template; return template;
}; };
var createMenu = function(x, y, items, document) { var createMenu = function(x, y, items) {
const remote = require('electron').remote; const remote = require('electron').remote;
const Menu = remote.Menu; const Menu = remote.Menu;
const menu = Menu.buildFromTemplate(convertToMenuTemplate(items)); const menu = Menu.buildFromTemplate(convertToMenuTemplate(items));

View file

@ -62,21 +62,21 @@ var dispatchEvent = function() {
module.exports = { module.exports = {
registerEvents: function(webView, viewInstanceId) { registerEvents: function(webView, viewInstanceId) {
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function() { ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function() {
var args, event, eventName; var eventName = arguments[1];
event = arguments[0], eventName = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : []; var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
return dispatchEvent.apply(null, [webView, eventName, eventName].concat(slice.call(args))); return dispatchEvent.apply(null, [webView, eventName, eventName].concat(slice.call(args)));
}); });
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function() { ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function() {
var args, channel, domEvent, event; var channel = arguments[1];
event = arguments[0], channel = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : []; var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
domEvent = new Event('ipc-message'); var domEvent = new Event('ipc-message');
domEvent.channel = channel; domEvent.channel = channel;
domEvent.args = slice.call(args); domEvent.args = slice.call(args);
return webView.dispatchEvent(domEvent); return webView.dispatchEvent(domEvent);
}); });
return ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId, function() { return ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId, function() {
var args, domEvent, event, f, i, j, len, ref1; var args, domEvent, f, i, j, len, ref1;
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
domEvent = new Event('size-changed'); domEvent = new Event('size-changed');
ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight']; ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight'];
for (i = j = 0, len = ref1.length; j < len; i = ++j) { for (i = j = 0, len = ref1.length; j < len; i = ++j) {

View file

@ -87,7 +87,7 @@ class AllowTransparencyAttribute extends BooleanAttribute {
super(webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY, webViewImpl); super(webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY, webViewImpl);
} }
handleMutation(oldValue, newValue) { handleMutation() {
if (!this.webViewImpl.guestInstanceId) { if (!this.webViewImpl.guestInstanceId) {
return; return;
} }
@ -105,7 +105,7 @@ class AutosizeDimensionAttribute extends WebViewAttribute {
return parseInt(this.webViewImpl.webviewNode.getAttribute(this.name)) || 0; return parseInt(this.webViewImpl.webviewNode.getAttribute(this.name)) || 0;
} }
handleMutation(oldValue, newValue) { handleMutation() {
if (!this.webViewImpl.guestInstanceId) { if (!this.webViewImpl.guestInstanceId) {
return; return;
} }

View file

@ -41,7 +41,7 @@ var WebViewImpl = (function() {
// Subscribe to host's zoom level changes. // Subscribe to host's zoom level changes.
this.onZoomLevelChanged = (zoomLevel) => { this.onZoomLevelChanged = (zoomLevel) => {
this.webviewNode.setZoomLevel(zoomLevel); this.webviewNode.setZoomLevel(zoomLevel);
} };
webFrame.on('zoom-level-changed', this.onZoomLevelChanged); webFrame.on('zoom-level-changed', this.onZoomLevelChanged);
} }
@ -93,15 +93,13 @@ var WebViewImpl = (function() {
this.webviewNode.setAttribute('tabIndex', -1); this.webviewNode.setAttribute('tabIndex', -1);
} }
this.webviewNode.addEventListener('focus', (function(_this) { this.webviewNode.addEventListener('focus', (function(_this) {
return function(e) { return function() {
// Focus the BrowserPlugin when the <webview> takes focus. // Focus the BrowserPlugin when the <webview> takes focus.
return _this.browserPluginNode.focus(); return _this.browserPluginNode.focus();
}; };
})(this)); })(this));
return this.webviewNode.addEventListener('blur', (function(_this) { return this.webviewNode.addEventListener('blur', (function(_this) {
return function(e) { return function() {
// Blur the BrowserPlugin when the <webview> loses focus. // Blur the BrowserPlugin when the <webview> loses focus.
return _this.browserPluginNode.blur(); return _this.browserPluginNode.blur();
}; };
@ -138,12 +136,11 @@ var WebViewImpl = (function() {
}; };
WebViewImpl.prototype.onSizeChanged = function(webViewEvent) { WebViewImpl.prototype.onSizeChanged = function(webViewEvent) {
var height, maxHeight, maxWidth, minHeight, minWidth, newHeight, newWidth, node, width; var maxHeight, maxWidth, minHeight, minWidth, newHeight, newWidth, node, width;
newWidth = webViewEvent.newWidth; newWidth = webViewEvent.newWidth;
newHeight = webViewEvent.newHeight; newHeight = webViewEvent.newHeight;
node = this.webviewNode; node = this.webviewNode;
width = node.offsetWidth; width = node.offsetWidth;
height = node.offsetHeight;
// Check the current bounds to make sure we do not resize <webview> // Check the current bounds to make sure we do not resize <webview>
// outside of current constraints. // outside of current constraints.
@ -296,8 +293,7 @@ var registerBrowserPluginElement = function() {
}; };
proto.attachedCallback = function() { proto.attachedCallback = function() {
// Load the plugin immediately. // Load the plugin immediately.
var unused; return this.nonExistentAttribute;
return unused = this.nonExistentAttribute;
}; };
WebViewImpl.BrowserPlugin = webFrame.registerEmbedderCustomElement('browserplugin', { WebViewImpl.BrowserPlugin = webFrame.registerEmbedderCustomElement('browserplugin', {
"extends": 'object', "extends": 'object',

View file

@ -11,6 +11,7 @@
}, },
"private": true, "private": true,
"scripts": { "scripts": {
"lint": "python ./script/eslint.py && python ./script/cpplint.py",
"preinstall": "node -e 'process.exit(0)'", "preinstall": "node -e 'process.exit(0)'",
"start": "python ./script/start.py", "start": "python ./script/start.py",
"test": "python ./script/test.py" "test": "python ./script/test.py"

View file

@ -1,7 +1,7 @@
{ {
"rules": { "rules": {
"indent": [ "indent": [
0, 2,
2, 2,
{ {
"SwitchCase": 1 "SwitchCase": 1
@ -12,20 +12,25 @@
"single" "single"
], ],
"semi": [ "semi": [
0, 2,
"always" "always"
], ],
"comma-dangle": 0, "comma-dangle": 0,
"linebreak-style": 0, "linebreak-style": 0,
"no-console": 0, "no-console": 0,
"no-undef": 0, "no-undef": 2,
"no-unreachable": 0, "no-unused-vars": 2
"no-unused-vars": 0
}, },
"env": { "env": {
"es6": true, "es6": true,
"node": true, "node": true,
"browser": true "browser": true
}, },
"extends": "eslint:recommended" "extends": "eslint:recommended",
"globals": {
"DevToolsAPI": false,
"InspectorFrontendHost": false,
"WebInspector": false,
"WebView": false
}
} }

View file

@ -1,7 +1,4 @@
{ {
"rules": {
"no-empty": 0
},
"env": { "env": {
"jquery": true, "jquery": true,
"mocha": true "mocha": true

View file

@ -1,22 +1,15 @@
var BrowserWindow, assert, fs, http, ipcMain, isCI, os, path, ref, ref1, remote, screen, url; const assert = require('assert');
const fs = require('fs');
const path = require('path');
const os = require('os');
assert = require('assert'); const remote = require('electron').remote;
const screen = require('electron').screen;
fs = require('fs'); const ipcMain = remote.require('electron').ipcMain;
const BrowserWindow = remote.require('electron').BrowserWindow;
path = require('path'); const isCI = remote.getGlobal('isCi');
http = require('http');
url = require('url');
os = require('os');
ref = require('electron'), remote = ref.remote, screen = ref.screen;
ref1 = remote.require('electron'), ipcMain = ref1.ipcMain, BrowserWindow = ref1.BrowserWindow;
isCI = remote.getGlobal('isCi');
describe('browser-window module', function() { describe('browser-window module', function() {
var fixtures, w; var fixtures, w;
@ -470,6 +463,7 @@ describe('browser-window module', function() {
fs.rmdirSync(path.join(savePageDir, 'save_page_files')); fs.rmdirSync(path.join(savePageDir, 'save_page_files'));
fs.rmdirSync(savePageDir); fs.rmdirSync(savePageDir);
} catch (e) { } catch (e) {
// Ignore error
} }
}); });

View file

@ -41,7 +41,7 @@ describe('crash-reporter module', function() {
var form; var form;
server.close(); server.close();
form = new multiparty.Form(); form = new multiparty.Form();
return form.parse(req, function(error, fields, files) { return form.parse(req, function(error, fields) {
if (called) { if (called) {
return; return;
} }

View file

@ -19,9 +19,9 @@ describe('desktopCapturer', function() {
assert.equal(error, null); assert.equal(error, null);
assert.notEqual(sources.length, 0); assert.notEqual(sources.length, 0);
if (callCount === 2) done(); if (callCount === 2) done();
} };
desktopCapturer.getSources({types: ['window', 'screen']}, callback); desktopCapturer.getSources({types: ['window', 'screen']}, callback);
desktopCapturer.getSources({types: ['window', 'screen']}, callback); desktopCapturer.getSources({types: ['window', 'screen']}, callback);
}) });
}); });

View file

@ -84,12 +84,10 @@ describe('ipc module', function() {
return it('can be used as promise in each side', function(done) { return it('can be used as promise in each side', function(done) {
var promise; var promise;
promise = remote.require(path.join(fixtures, 'module', 'promise.js')); promise = remote.require(path.join(fixtures, 'module', 'promise.js'));
return promise.twicePromise(Promise.resolve(1234)).then((function(_this) { return promise.twicePromise(Promise.resolve(1234)).then(function(value) {
return function(value) { assert.equal(value, 2468);
assert.equal(value, 2468); return done();
return done(); });
};
})(this));
}); });
}); });
describe('ipc.sender.send', function() { describe('ipc.sender.send', function() {

View file

@ -1,16 +1,9 @@
var assert, http, path, protocol, qs, remote; const assert = require('assert');
const http = require('http');
assert = require('assert'); const path = require('path');
const qs = require('querystring');
http = require('http'); const remote = require('electron').remote;
const protocol = remote.require('electron').protocol;
path = require('path');
qs = require('querystring');
remote = require('electron').remote;
protocol = remote.require('electron').protocol;
describe('protocol module', function() { describe('protocol module', function() {
var postData, protocolName, text; var postData, protocolName, text;
@ -44,12 +37,11 @@ describe('protocol module', function() {
it('does not crash when handler is called twice', function(done) { it('does not crash when handler is called twice', function(done) {
var doubleHandler; var doubleHandler;
doubleHandler = function(request, callback) { doubleHandler = function(request, callback) {
var error1;
try { try {
callback(text); callback(text);
return callback(); return callback();
} catch (error1) { } catch (error) {
// Ignore error
} }
}; };
return protocol.registerStringProtocol(protocolName, doubleHandler, function(error) { return protocol.registerStringProtocol(protocolName, doubleHandler, function(error) {
@ -75,10 +67,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -175,7 +167,7 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data, statux, request) { success: function(data) {
assert.equal(data, text); assert.equal(data, text);
return done(); return done();
}, },
@ -196,10 +188,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -267,7 +259,7 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data, statux, request) { success: function(data) {
assert.equal(data, text); assert.equal(data, text);
return done(); return done();
}, },
@ -288,10 +280,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -361,7 +353,7 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data, statux, request) { success: function(data) {
assert.equal(data, String(fileContent)); assert.equal(data, String(fileContent));
return done(); return done();
}, },
@ -404,10 +396,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -425,10 +417,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -483,10 +475,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -504,10 +496,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: protocolName + "://fake-host", url: protocolName + "://fake-host",
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }
@ -584,12 +576,11 @@ describe('protocol module', function() {
it('does not crash when handler is called twice', function(done) { it('does not crash when handler is called twice', function(done) {
var doubleHandler; var doubleHandler;
doubleHandler = function(request, callback) { doubleHandler = function(request, callback) {
var error1;
try { try {
callback(text); callback(text);
return callback(); return callback();
} catch (error1) { } catch (error) {
// Ignore error
} }
}; };
return protocol.interceptStringProtocol('http', doubleHandler, function(error) { return protocol.interceptStringProtocol('http', doubleHandler, function(error) {
@ -618,10 +609,10 @@ describe('protocol module', function() {
} }
return $.ajax({ return $.ajax({
url: 'http://fake-host', url: 'http://fake-host',
success: function(data) { success: function() {
return done('request succeeded but it should not'); return done('request succeeded but it should not');
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
assert.equal(errorType, 'error'); assert.equal(errorType, 'error');
return done(); return done();
} }

View file

@ -1,16 +1,14 @@
var BrowserWindow, app, assert, fs, http, ipcMain, ipcRenderer, path, ref, remote, session; const assert = require('assert');
const http = require('http');
const path = require('path');
const fs = require('fs');
assert = require('assert'); const ipcRenderer = require('electron').ipcRenderer;
const remote = require('electron').remote;
http = require('http'); const ipcMain = remote.ipcMain;
const session = remote.session;
path = require('path'); const BrowserWindow = remote.BrowserWindow;
fs = require('fs');
ref = require('electron'), ipcRenderer = ref.ipcRenderer, remote = ref.remote;
app = remote.app, ipcMain = remote.ipcMain, session = remote.session, BrowserWindow = remote.BrowserWindow;
describe('session module', function() { describe('session module', function() {
var fixtures, url, w; var fixtures, url, w;

View file

@ -1,12 +1,7 @@
var assert, http, remote, session; const assert = require('assert');
const http = require('http');
assert = require('assert'); const remote = require('electron').remote;
const session = remote.session;
http = require('http');
remote = require('electron').remote;
session = remote.session;
describe('webRequest module', function() { describe('webRequest module', function() {
var defaultURL, server, ses; var defaultURL, server, ses;
@ -44,10 +39,10 @@ describe('webRequest module', function() {
}); });
return $.ajax({ return $.ajax({
url: defaultURL, url: defaultURL,
success: function(data) { success: function() {
return done('unexpected success'); return done('unexpected success');
}, },
error: function(xhr, errorType, error) { error: function() {
return done(); return done();
} }
}); });
@ -68,15 +63,15 @@ describe('webRequest module', function() {
assert.equal(data, '/nofilter/test'); assert.equal(data, '/nofilter/test');
return $.ajax({ return $.ajax({
url: defaultURL + "filter/test", url: defaultURL + "filter/test",
success: function(data) { success: function() {
return done('unexpected success'); return done('unexpected success');
}, },
error: function(xhr, errorType, error) { error: function() {
return done(); return done();
} }
}); });
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -96,7 +91,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -117,7 +112,7 @@ describe('webRequest module', function() {
assert.equal(data, '/redirect'); assert.equal(data, '/redirect');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -138,7 +133,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -154,11 +149,11 @@ describe('webRequest module', function() {
}); });
return $.ajax({ return $.ajax({
url: defaultURL, url: defaultURL,
success: function(data, textStatus, request) { success: function(data) {
assert.equal(data, '/header/received'); assert.equal(data, '/header/received');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -179,7 +174,7 @@ describe('webRequest module', function() {
}); });
return $.ajax({ return $.ajax({
url: defaultURL, url: defaultURL,
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -199,7 +194,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -222,7 +217,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -243,7 +238,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -259,7 +254,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -283,7 +278,7 @@ describe('webRequest module', function() {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -314,11 +309,11 @@ describe('webRequest module', function() {
}); });
return $.ajax({ return $.ajax({
url: defaultURL, url: defaultURL,
success: function(data, status, xhr) { success: function(data) {
assert.equal(data, '/redirect'); assert.equal(data, '/redirect');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -336,11 +331,11 @@ describe('webRequest module', function() {
}); });
return $.ajax({ return $.ajax({
url: defaultURL, url: defaultURL,
success: function(data, status, xhr) { success: function(data) {
assert.equal(data, '/'); assert.equal(data, '/');
return done(); return done();
}, },
error: function(xhr, errorType, error) { error: function(xhr, errorType) {
return done(errorType); return done(errorType);
} }
}); });
@ -363,7 +358,7 @@ describe('webRequest module', function() {
}); });
return $.ajax({ return $.ajax({
url: defaultURL, url: defaultURL,
success: function(data) { success: function() {
return done('unexpected success'); return done('unexpected success');
} }
}); });

View file

@ -1,16 +1,13 @@
var BrowserWindow, assert, child_process, fs, ipcMain, nativeImage, path, ref, ref1, remote; const assert = require('assert');
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
assert = require('assert'); const nativeImage = require('electron').nativeImage;
const remote = require('electron').remote;
child_process = require('child_process'); const ipcMain = remote.require('electron').ipcMain;
const BrowserWindow = remote.require('electron').BrowserWindow;
fs = require('fs');
path = require('path');
ref = require('electron'), nativeImage = ref.nativeImage, remote = ref.remote;
ref1 = remote.require('electron'), ipcMain = ref1.ipcMain, BrowserWindow = ref1.BrowserWindow;
describe('asar package', function() { describe('asar package', function() {
var fixtures; var fixtures;
@ -18,12 +15,11 @@ describe('asar package', function() {
describe('node api', function() { describe('node api', function() {
describe('fs.readFileSync', function() { describe('fs.readFileSync', function() {
it('does not leak fd', function() { it('does not leak fd', function() {
var i, j, results; var readCalls = 1;
results = []; while(readCalls <= 10000) {
for (i = j = 1; j <= 10000; i = ++j) { fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'lib', 'ipc.js'));
results.push(fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'lib', 'ipc.js'))); readCalls++;
} }
return results;
}); });
it('reads a normal file', function() { it('reads a normal file', function() {
var file1, file2, file3; var file1, file2, file3;
@ -117,7 +113,7 @@ describe('asar package', function() {
return it('throws ENOENT error when can not find file', function(done) { return it('throws ENOENT error when can not find file', function(done) {
var p; var p;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist'); p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return fs.readFile(p, function(err, content) { return fs.readFile(p, function(err) {
assert.equal(err.code, 'ENOENT'); assert.equal(err.code, 'ENOENT');
return done(); return done();
}); });
@ -221,9 +217,8 @@ describe('asar package', function() {
return fs.lstat(p + '/', done); return fs.lstat(p + '/', done);
}); });
it('returns information of root', function(done) { it('returns information of root', function(done) {
var p, stats; var p = path.join(fixtures, 'asar', 'a.asar');
p = path.join(fixtures, 'asar', 'a.asar'); fs.lstat(p, function(err, stats) {
return stats = fs.lstat(p, function(err, stats) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(stats.isFile(), false); assert.equal(stats.isFile(), false);
assert.equal(stats.isDirectory(), true); assert.equal(stats.isDirectory(), true);
@ -233,9 +228,8 @@ describe('asar package', function() {
}); });
}); });
it('returns information of a normal file', function(done) { it('returns information of a normal file', function(done) {
var p, stats; var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1');
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1'); fs.lstat(p, function(err, stats) {
return stats = fs.lstat(p, function(err, stats) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(stats.isFile(), true); assert.equal(stats.isFile(), true);
assert.equal(stats.isDirectory(), false); assert.equal(stats.isDirectory(), false);
@ -245,9 +239,8 @@ describe('asar package', function() {
}); });
}); });
it('returns information of a normal directory', function(done) { it('returns information of a normal directory', function(done) {
var p, stats; var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
p = path.join(fixtures, 'asar', 'a.asar', 'dir1'); fs.lstat(p, function(err, stats) {
return stats = fs.lstat(p, function(err, stats) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(stats.isFile(), false); assert.equal(stats.isFile(), false);
assert.equal(stats.isDirectory(), true); assert.equal(stats.isDirectory(), true);
@ -257,9 +250,8 @@ describe('asar package', function() {
}); });
}); });
it('returns information of a linked file', function(done) { it('returns information of a linked file', function(done) {
var p, stats; var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1');
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1'); fs.lstat(p, function(err, stats) {
return stats = fs.lstat(p, function(err, stats) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(stats.isFile(), false); assert.equal(stats.isFile(), false);
assert.equal(stats.isDirectory(), false); assert.equal(stats.isDirectory(), false);
@ -269,9 +261,8 @@ describe('asar package', function() {
}); });
}); });
it('returns information of a linked directory', function(done) { it('returns information of a linked directory', function(done) {
var p, stats; var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2'); fs.lstat(p, function(err, stats) {
return stats = fs.lstat(p, function(err, stats) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(stats.isFile(), false); assert.equal(stats.isFile(), false);
assert.equal(stats.isDirectory(), false); assert.equal(stats.isDirectory(), false);
@ -281,9 +272,8 @@ describe('asar package', function() {
}); });
}); });
return it('throws ENOENT error when can not find file', function(done) { return it('throws ENOENT error when can not find file', function(done) {
var p, stats; var p = path.join(fixtures, 'asar', 'a.asar', 'file4');
p = path.join(fixtures, 'asar', 'a.asar', 'file4'); fs.lstat(p, function(err) {
return stats = fs.lstat(p, function(err, stats) {
assert.equal(err.code, 'ENOENT'); assert.equal(err.code, 'ENOENT');
return done(); return done();
}); });
@ -390,7 +380,7 @@ describe('asar package', function() {
var p, parent; var p, parent;
parent = fs.realpathSync(path.join(fixtures, 'asar')); parent = fs.realpathSync(path.join(fixtures, 'asar'));
p = path.join('a.asar', 'not-exist'); p = path.join('a.asar', 'not-exist');
return fs.realpath(path.join(parent, p), function(err, stats) { return fs.realpath(path.join(parent, p), function(err) {
assert.equal(err.code, 'ENOENT'); assert.equal(err.code, 'ENOENT');
return done(); return done();
}); });
@ -426,27 +416,24 @@ describe('asar package', function() {
}); });
describe('fs.readdir', function() { describe('fs.readdir', function() {
it('reads dirs from root', function(done) { it('reads dirs from root', function(done) {
var dirs, p; var p = path.join(fixtures, 'asar', 'a.asar');
p = path.join(fixtures, 'asar', 'a.asar'); fs.readdir(p, function(err, dirs) {
return dirs = fs.readdir(p, function(err, dirs) {
assert.equal(err, null); assert.equal(err, null);
assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js']); assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js']);
return done(); return done();
}); });
}); });
it('reads dirs from a normal dir', function(done) { it('reads dirs from a normal dir', function(done) {
var dirs, p; var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
p = path.join(fixtures, 'asar', 'a.asar', 'dir1'); fs.readdir(p, function(err, dirs) {
return dirs = fs.readdir(p, function(err, dirs) {
assert.equal(err, null); assert.equal(err, null);
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']); assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
return done(); return done();
}); });
}); });
it('reads dirs from a linked dir', function(done) { it('reads dirs from a linked dir', function(done) {
var dirs, p; var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2'); fs.readdir(p, function(err, dirs) {
return dirs = fs.readdir(p, function(err, dirs) {
assert.equal(err, null); assert.equal(err, null);
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']); assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
return done(); return done();
@ -455,7 +442,7 @@ describe('asar package', function() {
return it('throws ENOENT error when can not find file', function(done) { return it('throws ENOENT error when can not find file', function(done) {
var p; var p;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist'); p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return fs.readdir(p, function(err, stats) { return fs.readdir(p, function(err) {
assert.equal(err.code, 'ENOENT'); assert.equal(err.code, 'ENOENT');
return done(); return done();
}); });
@ -504,7 +491,7 @@ describe('asar package', function() {
return it('throws ENOENT error when can not find file', function(done) { return it('throws ENOENT error when can not find file', function(done) {
var p; var p;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist'); p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return fs.open(p, 'r', function(err, stats) { return fs.open(p, 'r', function(err) {
assert.equal(err.code, 'ENOENT'); assert.equal(err.code, 'ENOENT');
return done(); return done();
}); });
@ -559,8 +546,7 @@ describe('asar package', function() {
ref2 = require('child_process'), execFile = ref2.execFile, execFileSync = ref2.execFileSync; ref2 = require('child_process'), execFile = ref2.execFile, execFileSync = ref2.execFileSync;
echo = path.join(fixtures, 'asar', 'echo.asar', 'echo'); echo = path.join(fixtures, 'asar', 'echo.asar', 'echo');
it('executes binaries', function(done) { it('executes binaries', function(done) {
var child; execFile(echo, ['test'], function(error, stdout) {
return child = execFile(echo, ['test'], function(error, stdout) {
assert.equal(error, null); assert.equal(error, null);
assert.equal(stdout, 'test\n'); assert.equal(stdout, 'test\n');
return done(); return done();

View file

@ -1,18 +1,11 @@
var BrowserWindow, assert, http, https, path, ref, remote, session, ws; const assert = require('assert');
const http = require('http');
const path = require('path');
const ws = require('ws');
const remote = require('electron').remote;
assert = require('assert'); const BrowserWindow = remote.require('electron').BrowserWindow;
const session = remote.require('electron').session;
http = require('http');
https = require('https');
path = require('path');
ws = require('ws');
remote = require('electron').remote;
ref = remote.require('electron'), BrowserWindow = ref.BrowserWindow, session = ref.session;
describe('chromium feature', function() { describe('chromium feature', function() {
var fixtures, listener; var fixtures, listener;
@ -310,8 +303,7 @@ describe('chromium feature', function() {
return it('has user agent', function(done) { return it('has user agent', function(done) {
server = http.createServer(); server = http.createServer();
return server.listen(0, '127.0.0.1', function() { return server.listen(0, '127.0.0.1', function() {
var port, websocket; var port = server.address().port;
port = server.address().port;
wss = new WebSocketServer({ wss = new WebSocketServer({
server: server server: server
}); });
@ -323,7 +315,7 @@ describe('chromium feature', function() {
return done('user agent is empty'); return done('user agent is empty');
} }
}); });
return websocket = new WebSocket("ws://127.0.0.1:" + port); new WebSocket("ws://127.0.0.1:" + port);
}); });
}); });
}); });

View file

@ -1,12 +1,6 @@
var assert, fs, path, temp; const assert = require('assert');
const path = require('path');
assert = require('assert'); const temp = require('temp');
fs = require('fs');
path = require('path');
temp = require('temp');
describe('third-party module', function() { describe('third-party module', function() {
var fixtures; var fixtures;

View file

@ -1,16 +1,9 @@
var assert, child_process, fs, os, path, remote; const assert = require('assert');
const child_process = require('child_process');
assert = require('assert'); const fs = require('fs');
const path = require('path');
child_process = require('child_process'); const os = require('os');
const remote = require('electron').remote;
fs = require('fs');
path = require('path');
os = require('os');
remote = require('electron').remote;
describe('node feature', function() { describe('node feature', function() {
var fixtures; var fixtures;
@ -103,7 +96,7 @@ describe('node feature', function() {
error = new Error('boo!'); error = new Error('boo!');
lsts = process.listeners('uncaughtException'); lsts = process.listeners('uncaughtException');
process.removeAllListeners('uncaughtException'); process.removeAllListeners('uncaughtException');
process.on('uncaughtException', function(err) { process.on('uncaughtException', function() {
var i, len, lst; var i, len, lst;
process.removeAllListeners('uncaughtException'); process.removeAllListeners('uncaughtException');
for (i = 0, len = lsts.length; i < len; i++) { for (i = 0, len = lsts.length; i < len; i++) {

View file

@ -31,8 +31,7 @@ describe('<webview> tag', function() {
return document.body.appendChild(webview); return document.body.appendChild(webview);
}); });
return it('navigates to new page when changed', function(done) { return it('navigates to new page when changed', function(done) {
var listener; var listener = function() {
listener = function(e) {
webview.src = "file://" + fixtures + "/pages/b.html"; webview.src = "file://" + fixtures + "/pages/b.html";
webview.addEventListener('console-message', function(e) { webview.addEventListener('console-message', function(e) {
assert.equal(e.message, 'b'); assert.equal(e.message, 'b');
@ -74,11 +73,9 @@ describe('<webview> tag', function() {
}); });
if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) { if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) {
return it('loads native modules when navigation happens', function(done) { return it('loads native modules when navigation happens', function(done) {
var listener; var listener = function() {
listener = function(e) {
var listener2;
webview.removeEventListener('did-finish-load', listener); webview.removeEventListener('did-finish-load', listener);
listener2 = function(e) { var listener2 = function(e) {
assert.equal(e.message, 'function'); assert.equal(e.message, 'function');
return done(); return done();
}; };
@ -123,7 +120,7 @@ describe('<webview> tag', function() {
webview.removeEventListener('ipc-message', listener); webview.removeEventListener('ipc-message', listener);
return done(); return done();
}; };
listener2 = function(e) { listener2 = function() {
webview.send('ping', message); webview.send('ping', message);
return webview.removeEventListener('did-finish-load', listener2); return webview.removeEventListener('did-finish-load', listener2);
}; };
@ -459,7 +456,7 @@ describe('<webview> tag', function() {
webview.removeEventListener('ipc-message', listener); webview.removeEventListener('ipc-message', listener);
return done(); return done();
}; };
listener2 = function(e) { listener2 = function() {
webview.reload(); webview.reload();
return webview.removeEventListener('did-finish-load', listener2); return webview.removeEventListener('did-finish-load', listener2);
}; };
@ -520,7 +517,7 @@ describe('<webview> tag', function() {
describe('dom-ready event', function() { describe('dom-ready event', function() {
return it('emits when document is loaded', function(done) { return it('emits when document is loaded', function(done) {
var server; var server;
server = http.createServer(function(req) {}); server = http.createServer(function() {});
return server.listen(0, '127.0.0.1', function() { return server.listen(0, '127.0.0.1', function() {
var port; var port;
port = server.address().port; port = server.address().port;
@ -538,11 +535,11 @@ describe('<webview> tag', function() {
} }
return it('should support user gesture', function(done) { return it('should support user gesture', function(done) {
var listener, listener2; var listener, listener2;
listener = function(e) { listener = function() {
webview.removeEventListener('enter-html-full-screen', listener); webview.removeEventListener('enter-html-full-screen', listener);
return done(); return done();
}; };
listener2 = function(e) { listener2 = function() {
var jsScript; var jsScript;
jsScript = 'document.getElementsByTagName("video")[0].webkitRequestFullScreen()'; jsScript = 'document.getElementsByTagName("video")[0].webkitRequestFullScreen()';
webview.executeJavaScript(jsScript, true); webview.executeJavaScript(jsScript, true);
@ -618,7 +615,7 @@ describe('<webview> tag', function() {
return done(); return done();
} }
}; };
listener2 = function(e) { listener2 = function() {
return requestId = webview.findInPage("virtual"); return requestId = webview.findInPage("virtual");
}; };
webview.addEventListener('found-in-page', listener); webview.addEventListener('found-in-page', listener);
@ -629,7 +626,7 @@ describe('<webview> tag', function() {
}); });
return xdescribe('did-change-theme-color event', function() { return xdescribe('did-change-theme-color event', function() {
return it('emits when theme color changes', function(done) { return it('emits when theme color changes', function(done) {
webview.addEventListener('did-change-theme-color', function(e) { webview.addEventListener('did-change-theme-color', function() {
return done(); return done();
}); });
webview.src = "file://" + fixtures + "/pages/theme-color.html"; webview.src = "file://" + fixtures + "/pages/theme-color.html";