Merge pull request #4172 from atom/enable-eslint-rules
Enable more eslint rules
This commit is contained in:
commit
fda480d1aa
40 changed files with 806 additions and 912 deletions
|
@ -60,9 +60,8 @@ var fn = function(name) {
|
|||
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++) {
|
||||
name = ref1[i];
|
||||
fn(ref1[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ const exeName = path.basename(process.execPath);
|
|||
// Spawn a command and invoke the callback when it completes with an error
|
||||
// and the output from standard out.
|
||||
var spawnUpdate = function(args, detached, callback) {
|
||||
var error, error1, errorEmitted, spawnedProcess, stderr, stdout;
|
||||
var error, errorEmitted, spawnedProcess, stderr, stdout;
|
||||
try {
|
||||
spawnedProcess = spawn(updateExe, args, {
|
||||
detached: detached
|
||||
|
@ -58,23 +58,22 @@ var spawnUpdate = function(args, detached, callback) {
|
|||
};
|
||||
|
||||
// Start an instance of the installed app.
|
||||
exports.processStart = function(callback) {
|
||||
exports.processStart = function() {
|
||||
return spawnUpdate(['--processStart', exeName], true, function() {});
|
||||
};
|
||||
|
||||
// Download the releases specified by the URL and write new results to stdout.
|
||||
exports.download = function(updateURL, callback) {
|
||||
return spawnUpdate(['--download', updateURL], false, function(error, stdout) {
|
||||
var error1, json, ref, ref1, update;
|
||||
var json, ref, ref1, update;
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
try {
|
||||
|
||||
// Last line of output is the JSON details about the releases
|
||||
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;
|
||||
} catch (error1) {
|
||||
} catch (jsonError) {
|
||||
return callback("Invalid result:\n" + stdout);
|
||||
}
|
||||
return callback(null, update);
|
||||
|
@ -90,11 +89,10 @@ exports.update = function(updateURL, callback) {
|
|||
|
||||
// Is the Update.exe installed with the current application?
|
||||
exports.supported = function() {
|
||||
var error1;
|
||||
try {
|
||||
fs.accessSync(updateExe, fs.R_OK);
|
||||
return true;
|
||||
} catch (error1) {
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -56,7 +56,7 @@ BrowserWindow.prototype._init = function() {
|
|||
|
||||
// Change window title to page title.
|
||||
this.webContents.on('page-title-updated', (function(_this) {
|
||||
return function(event, title, explicitSet) {
|
||||
return function(event, title) {
|
||||
_this.emit('page-title-updated', event, title);
|
||||
if (!event.defaultPrevented) {
|
||||
return _this.setTitle(title);
|
||||
|
|
|
@ -5,7 +5,6 @@ const v8Util = process.atomBinding('v8_util');
|
|||
|
||||
var slice = [].slice;
|
||||
var includes = [].includes;
|
||||
var indexOf = [].indexOf;
|
||||
|
||||
var fileDialogProperties = {
|
||||
openFile: 1 << 0,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
var MenuItem, methodInBrowserWindow, nextCommandId, rolesMap, v8Util;
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
var MenuItem, methodInBrowserWindow, nextCommandId, rolesMap;
|
||||
|
||||
nextCommandId = 0;
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ Menu.prototype.insert = function(pos, item) {
|
|||
return v8Util.getHiddenValue(item, 'checked');
|
||||
},
|
||||
set: (function(_this) {
|
||||
return function(val) {
|
||||
return function() {
|
||||
var j, len, otherItem, ref1;
|
||||
ref1 = _this.groupsMap[item.groupId];
|
||||
for (j = 0, len = ref1.length; j < len; j++) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
const EventEmitter = require('events').EventEmitter;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const session = require('electron').session;
|
||||
const NavigationController = require('electron').NavigationController;
|
||||
const Menu = require('electron').Menu;
|
||||
|
||||
|
@ -62,7 +61,7 @@ const webFrameMethods = [
|
|||
'insertText',
|
||||
'setZoomFactor',
|
||||
'setZoomLevel',
|
||||
'setZoomLevelLimits',
|
||||
'setZoomLevelLimits'
|
||||
];
|
||||
|
||||
let wrapWebContents = function(webContents) {
|
||||
|
|
|
@ -144,23 +144,29 @@ app.once('ready', function() {
|
|||
submenu: [
|
||||
{
|
||||
label: 'Learn More',
|
||||
click: function() { shell.openExternal('http://electron.atom.io') }
|
||||
click: function() {
|
||||
shell.openExternal('http://electron.atom.io');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Documentation',
|
||||
click: function() {
|
||||
shell.openExternal(
|
||||
`https://github.com/atom/electron/tree/v${process.versions.electron}/docs#readme`
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
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',
|
||||
click: function() { shell.openExternal('https://github.com/atom/electron/issues') }
|
||||
click: function() {
|
||||
shell.openExternal('https://github.com/atom/electron/issues');
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -50,25 +50,24 @@ var loadedExtensions = null;
|
|||
var loadedExtensionsPath = null;
|
||||
|
||||
app.on('will-quit', function() {
|
||||
var e, error1, error2;
|
||||
try {
|
||||
loadedExtensions = Object.keys(extensionInfoMap).map(function(key) {
|
||||
return extensionInfoMap[key].srcDirectory;
|
||||
});
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(loadedExtensionsPath));
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
|
||||
} catch (error2) {
|
||||
e = error2;
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
});
|
||||
|
||||
// We can not use protocol or BrowserWindow until app is ready.
|
||||
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;
|
||||
|
||||
// Load persistented extensions.
|
||||
|
@ -84,8 +83,8 @@ app.once('ready', function() {
|
|||
srcDirectory = loadedExtensions[i];
|
||||
getExtensionInfoFromPath(srcDirectory);
|
||||
}
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
|
||||
// The chrome-extension: can map a extension URL request to real file path.
|
||||
|
|
|
@ -19,7 +19,7 @@ var moveLastToFirst = function(list) {
|
|||
};
|
||||
|
||||
// Generate guestInstanceId.
|
||||
var getNextInstanceId = function(webContents) {
|
||||
var getNextInstanceId = function() {
|
||||
return ++nextInstanceId;
|
||||
};
|
||||
|
||||
|
@ -109,8 +109,7 @@ var createGuest = function(embedder, params) {
|
|||
// Dispatch events to embedder.
|
||||
fn = function(event) {
|
||||
return guest.on(event, function() {
|
||||
var _, args;
|
||||
_ = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
var 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)));
|
||||
});
|
||||
};
|
||||
|
@ -128,8 +127,7 @@ var createGuest = function(embedder, params) {
|
|||
|
||||
// Autosize.
|
||||
guest.on('size-changed', function() {
|
||||
var _, args;
|
||||
_ = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
var 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 id;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
const ipcMain = require('electron').ipcMain;
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
var slice = [].slice;
|
||||
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() {
|
||||
var args, event, guestId, method, ref1;
|
||||
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
||||
var args, guestId, method, ref1;
|
||||
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;
|
||||
});
|
||||
|
||||
|
@ -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() {
|
||||
var args, event, guestId, method, ref1, ref2;
|
||||
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
||||
var args, guestId, method, ref1, ref2;
|
||||
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;
|
||||
});
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const electron = require('electron');
|
||||
const ipcMain = electron.ipcMain;
|
||||
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
|
||||
// style function and the caller didn't pass a callback.
|
||||
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');
|
||||
funcPassedCallback = typeof args[args.length - 1] === 'function';
|
||||
try {
|
||||
|
@ -196,14 +195,12 @@ var callFunction = function(event, func, caller, args) {
|
|||
ret = func.apply(caller, args);
|
||||
return event.returnValue = valueToMeta(event.sender, ret, true);
|
||||
}
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
|
||||
} catch (error) {
|
||||
// Catch functions thrown further down in function invocation and wrap
|
||||
// them with the function name so it's easier to trace things like
|
||||
// `Error processing argument -1.`
|
||||
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) {
|
||||
var e, error1;
|
||||
try {
|
||||
return event.returnValue = valueToMeta(event.sender, process.mainModule.require(module));
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_GET_BUILTIN', function(event, module) {
|
||||
var e, error1;
|
||||
try {
|
||||
return event.returnValue = valueToMeta(event.sender, electron[module]);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_GLOBAL', function(event, name) {
|
||||
var e, error1;
|
||||
try {
|
||||
return event.returnValue = valueToMeta(event.sender, global[name]);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_CURRENT_WINDOW', function(event) {
|
||||
var e, error1;
|
||||
try {
|
||||
return event.returnValue = valueToMeta(event.sender, event.sender.getOwnerBrowserWindow());
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -257,7 +246,7 @@ ipcMain.on('ATOM_BROWSER_CURRENT_WEB_CONTENTS', function(event) {
|
|||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) {
|
||||
var constructor, e, error1, obj;
|
||||
var constructor, obj;
|
||||
try {
|
||||
args = unwrapArgs(event.sender, args);
|
||||
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
|
||||
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
|
||||
return event.returnValue = valueToMeta(event.sender, obj);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_FUNCTION_CALL', function(event, id, args) {
|
||||
var e, error1, func;
|
||||
var func;
|
||||
try {
|
||||
args = unwrapArgs(event.sender, args);
|
||||
func = objectsRegistry.get(id);
|
||||
return callFunction(event, func, global, args);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function(event, id, method, args) {
|
||||
var constructor, e, error1, obj;
|
||||
var constructor, obj;
|
||||
try {
|
||||
args = unwrapArgs(event.sender, args);
|
||||
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.
|
||||
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
|
||||
return event.returnValue = valueToMeta(event.sender, obj);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_MEMBER_CALL', function(event, id, method, args) {
|
||||
var e, error1, obj;
|
||||
var obj;
|
||||
try {
|
||||
args = unwrapArgs(event.sender, args);
|
||||
obj = objectsRegistry.get(id);
|
||||
return callFunction(event, obj[method], obj, args);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_MEMBER_SET', function(event, id, name, value) {
|
||||
var e, error1, obj;
|
||||
var obj;
|
||||
try {
|
||||
obj = objectsRegistry.get(id);
|
||||
obj[name] = value;
|
||||
return event.returnValue = null;
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_MEMBER_GET', function(event, id, name) {
|
||||
var e, error1, obj;
|
||||
var obj;
|
||||
try {
|
||||
obj = objectsRegistry.get(id);
|
||||
return event.returnValue = valueToMeta(event.sender, obj[name]);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -339,25 +322,23 @@ ipcMain.on('ATOM_BROWSER_DEREFERENCE', function(event, id) {
|
|||
});
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function(event, guestInstanceId) {
|
||||
var e, error1, guestViewManager;
|
||||
var guestViewManager;
|
||||
try {
|
||||
guestViewManager = require('./guest-view-manager');
|
||||
return event.returnValue = valueToMeta(event.sender, guestViewManager.getGuest(guestInstanceId));
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
||||
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) : [];
|
||||
try {
|
||||
guestViewManager = require('./guest-view-manager');
|
||||
guest = guestViewManager.getGuest(guestInstanceId);
|
||||
return guest[method].apply(guest, args);
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
return event.returnValue = exceptionToMeta(e);
|
||||
} catch (error) {
|
||||
return event.returnValue = exceptionToMeta(error);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ class CallbacksRegistry {
|
|||
|
||||
add(callback) {
|
||||
// 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');
|
||||
if (id != null) {
|
||||
return id;
|
||||
|
@ -24,14 +24,15 @@ class CallbacksRegistry {
|
|||
regexp = /at (.*)/gi;
|
||||
stackString = (new Error).stack;
|
||||
while ((match = regexp.exec(stackString)) !== null) {
|
||||
x = match[0], location = match[1];
|
||||
location = match[1];
|
||||
if (location.indexOf('(native)') !== -1) {
|
||||
continue;
|
||||
}
|
||||
if (location.indexOf('atom.asar') !== -1) {
|
||||
continue;
|
||||
}
|
||||
ref = /([^\/^\)]*)\)?$/gi.exec(location), x = ref[0], filenameAndLine = ref[1];
|
||||
ref = /([^\/^\)]*)\)?$/gi.exec(location);
|
||||
filenameAndLine = ref[1];
|
||||
break;
|
||||
}
|
||||
this.callbacks[id] = callback;
|
||||
|
@ -62,4 +63,4 @@ class CallbacksRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = CallbacksRegistry
|
||||
module.exports = CallbacksRegistry;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,17 +1,14 @@
|
|||
(function () {
|
||||
return function(process, require, asarSource) {
|
||||
var createArchive, source;
|
||||
createArchive = process.binding('atom_common_asar').createArchive;
|
||||
return function(process, require, asarSource) {
|
||||
// Make asar.coffee accessible via "require".
|
||||
process.binding('natives').ATOM_SHELL_ASAR = asarSource;
|
||||
|
||||
// Make asar.coffee accessible via "require".
|
||||
process.binding('natives').ATOM_SHELL_ASAR = asarSource;
|
||||
// Monkey-patch the fs module.
|
||||
require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs'));
|
||||
|
||||
// Monkey-patch the fs module.
|
||||
require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs'));
|
||||
|
||||
// Make graceful-fs work with asar.
|
||||
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);";
|
||||
};
|
||||
})()
|
||||
// Make graceful-fs work with asar.
|
||||
var 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);";
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const timers = require('timers');
|
||||
const Module = require('module');
|
||||
|
||||
process.atomBinding = function(name) {
|
||||
var e, error;
|
||||
try {
|
||||
return process.binding("atom_" + process.type + "_" + name);
|
||||
} catch (error) {
|
||||
e = error;
|
||||
if (/No such module/.test(e.message)) {
|
||||
if (/No such module/.test(error.message)) {
|
||||
return process.binding("atom_common_" + name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const EventEmitter = require('events').EventEmitter;
|
||||
const binding = process.atomBinding('ipc');
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ deprecate.warn('ipc module', 'require("electron").ipcRenderer');
|
|||
var ipc = new EventEmitter;
|
||||
|
||||
ipcRenderer.emit = function() {
|
||||
var args, channel, event;
|
||||
channel = arguments[0], event = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
var channel = arguments[0];
|
||||
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
ipc.emit.apply(ipc, [channel].concat(slice.call(args)));
|
||||
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments);
|
||||
};
|
||||
|
|
|
@ -87,7 +87,7 @@ var wrapArgs = function(args, visited) {
|
|||
|
||||
// Convert meta data from browser into real value.
|
||||
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) {
|
||||
case 'value':
|
||||
return meta.value;
|
||||
|
@ -111,11 +111,10 @@ var metaToValue = function(meta) {
|
|||
return new Date(meta.value);
|
||||
case 'exception':
|
||||
throw new Error(meta.message + "\n" + meta.stack);
|
||||
break;
|
||||
default:
|
||||
if (meta.type === 'function') {
|
||||
// A shadow class to represent the remote function object.
|
||||
ret = RemoteFunction = (function() {
|
||||
ret = (function() {
|
||||
function RemoteFunction() {
|
||||
var obj;
|
||||
if (this.constructor === RemoteFunction) {
|
||||
|
@ -190,8 +189,7 @@ var metaToPlainObject = function(meta) {
|
|||
// This function's content should not be inlined into metaToValue, otherwise V8
|
||||
// may consider it circular reference.
|
||||
var createRemoteMemberFunction = function(metaId, name) {
|
||||
var RemoteMemberFunction;
|
||||
return RemoteMemberFunction = (function() {
|
||||
return (function() {
|
||||
function RemoteMemberFunction() {
|
||||
var ret;
|
||||
if (this.constructor === RemoteMemberFunction) {
|
||||
|
|
|
@ -2,19 +2,15 @@
|
|||
|
||||
const events = require('events');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const Module = require('module');
|
||||
|
||||
|
||||
// We modified the original process.argv to let node.js load the
|
||||
// atom-renderer.js, we need to restore it here.
|
||||
process.argv.splice(1, 1);
|
||||
|
||||
|
||||
// Clear search paths.
|
||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
|
||||
|
||||
|
||||
// Import common settings.
|
||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ var convertToMenuTemplate = function(items) {
|
|||
return template;
|
||||
};
|
||||
|
||||
var createMenu = function(x, y, items, document) {
|
||||
var createMenu = function(x, y, items) {
|
||||
const remote = require('electron').remote;
|
||||
const Menu = remote.Menu;
|
||||
const menu = Menu.buildFromTemplate(convertToMenuTemplate(items));
|
||||
|
|
|
@ -62,21 +62,21 @@ var dispatchEvent = function() {
|
|||
module.exports = {
|
||||
registerEvents: function(webView, viewInstanceId) {
|
||||
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function() {
|
||||
var args, event, eventName;
|
||||
event = arguments[0], eventName = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
var eventName = arguments[1];
|
||||
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
return dispatchEvent.apply(null, [webView, eventName, eventName].concat(slice.call(args)));
|
||||
});
|
||||
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function() {
|
||||
var args, channel, domEvent, event;
|
||||
event = arguments[0], channel = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
domEvent = new Event('ipc-message');
|
||||
var channel = arguments[1];
|
||||
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
var domEvent = new Event('ipc-message');
|
||||
domEvent.channel = channel;
|
||||
domEvent.args = slice.call(args);
|
||||
return webView.dispatchEvent(domEvent);
|
||||
});
|
||||
return ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId, function() {
|
||||
var args, domEvent, event, f, i, j, len, ref1;
|
||||
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
var args, domEvent, f, i, j, len, ref1;
|
||||
args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
domEvent = new Event('size-changed');
|
||||
ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight'];
|
||||
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
|
||||
|
|
|
@ -87,7 +87,7 @@ class AllowTransparencyAttribute extends BooleanAttribute {
|
|||
super(webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY, webViewImpl);
|
||||
}
|
||||
|
||||
handleMutation(oldValue, newValue) {
|
||||
handleMutation() {
|
||||
if (!this.webViewImpl.guestInstanceId) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class AutosizeDimensionAttribute extends WebViewAttribute {
|
|||
return parseInt(this.webViewImpl.webviewNode.getAttribute(this.name)) || 0;
|
||||
}
|
||||
|
||||
handleMutation(oldValue, newValue) {
|
||||
handleMutation() {
|
||||
if (!this.webViewImpl.guestInstanceId) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ var WebViewImpl = (function() {
|
|||
// Subscribe to host's zoom level changes.
|
||||
this.onZoomLevelChanged = (zoomLevel) => {
|
||||
this.webviewNode.setZoomLevel(zoomLevel);
|
||||
}
|
||||
};
|
||||
webFrame.on('zoom-level-changed', this.onZoomLevelChanged);
|
||||
}
|
||||
|
||||
|
@ -93,15 +93,13 @@ var WebViewImpl = (function() {
|
|||
this.webviewNode.setAttribute('tabIndex', -1);
|
||||
}
|
||||
this.webviewNode.addEventListener('focus', (function(_this) {
|
||||
return function(e) {
|
||||
|
||||
return function() {
|
||||
// Focus the BrowserPlugin when the <webview> takes focus.
|
||||
return _this.browserPluginNode.focus();
|
||||
};
|
||||
})(this));
|
||||
return this.webviewNode.addEventListener('blur', (function(_this) {
|
||||
return function(e) {
|
||||
|
||||
return function() {
|
||||
// Blur the BrowserPlugin when the <webview> loses focus.
|
||||
return _this.browserPluginNode.blur();
|
||||
};
|
||||
|
@ -138,12 +136,11 @@ var WebViewImpl = (function() {
|
|||
};
|
||||
|
||||
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;
|
||||
newHeight = webViewEvent.newHeight;
|
||||
node = this.webviewNode;
|
||||
width = node.offsetWidth;
|
||||
height = node.offsetHeight;
|
||||
|
||||
// Check the current bounds to make sure we do not resize <webview>
|
||||
// outside of current constraints.
|
||||
|
@ -296,8 +293,7 @@ var registerBrowserPluginElement = function() {
|
|||
};
|
||||
proto.attachedCallback = function() {
|
||||
// Load the plugin immediately.
|
||||
var unused;
|
||||
return unused = this.nonExistentAttribute;
|
||||
return this.nonExistentAttribute;
|
||||
};
|
||||
WebViewImpl.BrowserPlugin = webFrame.registerEmbedderCustomElement('browserplugin', {
|
||||
"extends": 'object',
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "python ./script/eslint.py && python ./script/cpplint.py",
|
||||
"preinstall": "node -e 'process.exit(0)'",
|
||||
"start": "python ./script/start.py",
|
||||
"test": "python ./script/test.py"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
{
|
||||
"SwitchCase": 1
|
||||
|
@ -12,20 +12,25 @@
|
|||
"single"
|
||||
],
|
||||
"semi": [
|
||||
0,
|
||||
2,
|
||||
"always"
|
||||
],
|
||||
"comma-dangle": 0,
|
||||
"linebreak-style": 0,
|
||||
"no-console": 0,
|
||||
"no-undef": 0,
|
||||
"no-unreachable": 0,
|
||||
"no-unused-vars": 0
|
||||
"no-undef": 2,
|
||||
"no-unused-vars": 2
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"browser": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"DevToolsAPI": false,
|
||||
"InspectorFrontendHost": false,
|
||||
"WebInspector": false,
|
||||
"WebView": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-empty": 0
|
||||
},
|
||||
"env": {
|
||||
"jquery": true,
|
||||
"mocha": true
|
||||
|
|
|
@ -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');
|
||||
|
||||
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');
|
||||
const isCI = remote.getGlobal('isCi');
|
||||
|
||||
describe('browser-window module', function() {
|
||||
var fixtures, w;
|
||||
|
@ -470,6 +463,7 @@ describe('browser-window module', function() {
|
|||
fs.rmdirSync(path.join(savePageDir, 'save_page_files'));
|
||||
fs.rmdirSync(savePageDir);
|
||||
} catch (e) {
|
||||
// Ignore error
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ describe('crash-reporter module', function() {
|
|||
var form;
|
||||
server.close();
|
||||
form = new multiparty.Form();
|
||||
return form.parse(req, function(error, fields, files) {
|
||||
return form.parse(req, function(error, fields) {
|
||||
if (called) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ describe('desktopCapturer', function() {
|
|||
assert.equal(error, null);
|
||||
assert.notEqual(sources.length, 0);
|
||||
if (callCount === 2) done();
|
||||
}
|
||||
};
|
||||
|
||||
desktopCapturer.getSources({types: ['window', 'screen']}, callback);
|
||||
desktopCapturer.getSources({types: ['window', 'screen']}, callback);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
@ -84,12 +84,10 @@ describe('ipc module', function() {
|
|||
return it('can be used as promise in each side', function(done) {
|
||||
var promise;
|
||||
promise = remote.require(path.join(fixtures, 'module', 'promise.js'));
|
||||
return promise.twicePromise(Promise.resolve(1234)).then((function(_this) {
|
||||
return function(value) {
|
||||
assert.equal(value, 2468);
|
||||
return done();
|
||||
};
|
||||
})(this));
|
||||
return promise.twicePromise(Promise.resolve(1234)).then(function(value) {
|
||||
assert.equal(value, 2468);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('ipc.sender.send', function() {
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
var assert, http, path, protocol, qs, remote;
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
http = require('http');
|
||||
|
||||
path = require('path');
|
||||
|
||||
qs = require('querystring');
|
||||
|
||||
remote = require('electron').remote;
|
||||
|
||||
protocol = remote.require('electron').protocol;
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
const qs = require('querystring');
|
||||
const remote = require('electron').remote;
|
||||
const protocol = remote.require('electron').protocol;
|
||||
|
||||
describe('protocol module', function() {
|
||||
var postData, protocolName, text;
|
||||
|
@ -44,12 +37,11 @@ describe('protocol module', function() {
|
|||
it('does not crash when handler is called twice', function(done) {
|
||||
var doubleHandler;
|
||||
doubleHandler = function(request, callback) {
|
||||
var error1;
|
||||
try {
|
||||
callback(text);
|
||||
return callback();
|
||||
} catch (error1) {
|
||||
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
};
|
||||
return protocol.registerStringProtocol(protocolName, doubleHandler, function(error) {
|
||||
|
@ -75,10 +67,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -175,7 +167,7 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data, statux, request) {
|
||||
success: function(data) {
|
||||
assert.equal(data, text);
|
||||
return done();
|
||||
},
|
||||
|
@ -196,10 +188,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -267,7 +259,7 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data, statux, request) {
|
||||
success: function(data) {
|
||||
assert.equal(data, text);
|
||||
return done();
|
||||
},
|
||||
|
@ -288,10 +280,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -361,7 +353,7 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data, statux, request) {
|
||||
success: function(data) {
|
||||
assert.equal(data, String(fileContent));
|
||||
return done();
|
||||
},
|
||||
|
@ -404,10 +396,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -425,10 +417,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -483,10 +475,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -504,10 +496,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: protocolName + "://fake-host",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
@ -584,12 +576,11 @@ describe('protocol module', function() {
|
|||
it('does not crash when handler is called twice', function(done) {
|
||||
var doubleHandler;
|
||||
doubleHandler = function(request, callback) {
|
||||
var error1;
|
||||
try {
|
||||
callback(text);
|
||||
return callback();
|
||||
} catch (error1) {
|
||||
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
};
|
||||
return protocol.interceptStringProtocol('http', doubleHandler, function(error) {
|
||||
|
@ -618,10 +609,10 @@ describe('protocol module', function() {
|
|||
}
|
||||
return $.ajax({
|
||||
url: 'http://fake-host',
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('request succeeded but it should not');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
assert.equal(errorType, 'error');
|
||||
return done();
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
||||
path = require('path');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
ref = require('electron'), ipcRenderer = ref.ipcRenderer, remote = ref.remote;
|
||||
|
||||
app = remote.app, ipcMain = remote.ipcMain, session = remote.session, BrowserWindow = remote.BrowserWindow;
|
||||
const ipcMain = remote.ipcMain;
|
||||
const session = remote.session;
|
||||
const BrowserWindow = remote.BrowserWindow;
|
||||
|
||||
describe('session module', function() {
|
||||
var fixtures, url, w;
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
var assert, http, remote, session;
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
http = require('http');
|
||||
|
||||
remote = require('electron').remote;
|
||||
|
||||
session = remote.session;
|
||||
const assert = require('assert');
|
||||
const http = require('http');
|
||||
const remote = require('electron').remote;
|
||||
const session = remote.session;
|
||||
|
||||
describe('webRequest module', function() {
|
||||
var defaultURL, server, ses;
|
||||
|
@ -44,10 +39,10 @@ describe('webRequest module', function() {
|
|||
});
|
||||
return $.ajax({
|
||||
url: defaultURL,
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('unexpected success');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function() {
|
||||
return done();
|
||||
}
|
||||
});
|
||||
|
@ -68,15 +63,15 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/nofilter/test');
|
||||
return $.ajax({
|
||||
url: defaultURL + "filter/test",
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('unexpected success');
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function() {
|
||||
return done();
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -96,7 +91,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -117,7 +112,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/redirect');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -138,7 +133,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -154,11 +149,11 @@ describe('webRequest module', function() {
|
|||
});
|
||||
return $.ajax({
|
||||
url: defaultURL,
|
||||
success: function(data, textStatus, request) {
|
||||
success: function(data) {
|
||||
assert.equal(data, '/header/received');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -179,7 +174,7 @@ describe('webRequest module', function() {
|
|||
});
|
||||
return $.ajax({
|
||||
url: defaultURL,
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -199,7 +194,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -222,7 +217,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -243,7 +238,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -259,7 +254,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -283,7 +278,7 @@ describe('webRequest module', function() {
|
|||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -314,11 +309,11 @@ describe('webRequest module', function() {
|
|||
});
|
||||
return $.ajax({
|
||||
url: defaultURL,
|
||||
success: function(data, status, xhr) {
|
||||
success: function(data) {
|
||||
assert.equal(data, '/redirect');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -336,11 +331,11 @@ describe('webRequest module', function() {
|
|||
});
|
||||
return $.ajax({
|
||||
url: defaultURL,
|
||||
success: function(data, status, xhr) {
|
||||
success: function(data) {
|
||||
assert.equal(data, '/');
|
||||
return done();
|
||||
},
|
||||
error: function(xhr, errorType, error) {
|
||||
error: function(xhr, errorType) {
|
||||
return done(errorType);
|
||||
}
|
||||
});
|
||||
|
@ -363,7 +358,7 @@ describe('webRequest module', function() {
|
|||
});
|
||||
return $.ajax({
|
||||
url: defaultURL,
|
||||
success: function(data) {
|
||||
success: function() {
|
||||
return done('unexpected success');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
|
||||
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;
|
||||
const ipcMain = remote.require('electron').ipcMain;
|
||||
const BrowserWindow = remote.require('electron').BrowserWindow;
|
||||
|
||||
describe('asar package', function() {
|
||||
var fixtures;
|
||||
|
@ -18,12 +15,11 @@ describe('asar package', function() {
|
|||
describe('node api', function() {
|
||||
describe('fs.readFileSync', function() {
|
||||
it('does not leak fd', function() {
|
||||
var i, j, results;
|
||||
results = [];
|
||||
for (i = j = 1; j <= 10000; i = ++j) {
|
||||
results.push(fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'lib', 'ipc.js')));
|
||||
var readCalls = 1;
|
||||
while(readCalls <= 10000) {
|
||||
fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'lib', 'ipc.js'));
|
||||
readCalls++;
|
||||
}
|
||||
return results;
|
||||
});
|
||||
it('reads a normal file', function() {
|
||||
var file1, file2, file3;
|
||||
|
@ -117,7 +113,7 @@ describe('asar package', function() {
|
|||
return it('throws ENOENT error when can not find file', function(done) {
|
||||
var p;
|
||||
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');
|
||||
return done();
|
||||
});
|
||||
|
@ -221,9 +217,8 @@ describe('asar package', function() {
|
|||
return fs.lstat(p + '/', done);
|
||||
});
|
||||
it('returns information of root', function(done) {
|
||||
var p, stats;
|
||||
p = path.join(fixtures, 'asar', 'a.asar');
|
||||
return stats = fs.lstat(p, function(err, stats) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar');
|
||||
fs.lstat(p, function(err, stats) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(stats.isFile(), false);
|
||||
assert.equal(stats.isDirectory(), true);
|
||||
|
@ -233,9 +228,8 @@ describe('asar package', function() {
|
|||
});
|
||||
});
|
||||
it('returns information of a normal file', function(done) {
|
||||
var p, stats;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1');
|
||||
return stats = fs.lstat(p, function(err, stats) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1');
|
||||
fs.lstat(p, function(err, stats) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(stats.isFile(), true);
|
||||
assert.equal(stats.isDirectory(), false);
|
||||
|
@ -245,9 +239,8 @@ describe('asar package', function() {
|
|||
});
|
||||
});
|
||||
it('returns information of a normal directory', function(done) {
|
||||
var p, stats;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
|
||||
return stats = fs.lstat(p, function(err, stats) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
|
||||
fs.lstat(p, function(err, stats) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(stats.isFile(), false);
|
||||
assert.equal(stats.isDirectory(), true);
|
||||
|
@ -257,9 +250,8 @@ describe('asar package', function() {
|
|||
});
|
||||
});
|
||||
it('returns information of a linked file', function(done) {
|
||||
var p, stats;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1');
|
||||
return stats = fs.lstat(p, function(err, stats) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1');
|
||||
fs.lstat(p, function(err, stats) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(stats.isFile(), false);
|
||||
assert.equal(stats.isDirectory(), false);
|
||||
|
@ -269,9 +261,8 @@ describe('asar package', function() {
|
|||
});
|
||||
});
|
||||
it('returns information of a linked directory', function(done) {
|
||||
var p, stats;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
|
||||
return stats = fs.lstat(p, function(err, stats) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
|
||||
fs.lstat(p, function(err, stats) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(stats.isFile(), 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) {
|
||||
var p, stats;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'file4');
|
||||
return stats = fs.lstat(p, function(err, stats) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'file4');
|
||||
fs.lstat(p, function(err) {
|
||||
assert.equal(err.code, 'ENOENT');
|
||||
return done();
|
||||
});
|
||||
|
@ -390,7 +380,7 @@ describe('asar package', function() {
|
|||
var p, parent;
|
||||
parent = fs.realpathSync(path.join(fixtures, 'asar'));
|
||||
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');
|
||||
return done();
|
||||
});
|
||||
|
@ -426,27 +416,24 @@ describe('asar package', function() {
|
|||
});
|
||||
describe('fs.readdir', function() {
|
||||
it('reads dirs from root', function(done) {
|
||||
var dirs, p;
|
||||
p = path.join(fixtures, 'asar', 'a.asar');
|
||||
return dirs = fs.readdir(p, function(err, dirs) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar');
|
||||
fs.readdir(p, function(err, dirs) {
|
||||
assert.equal(err, null);
|
||||
assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js']);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('reads dirs from a normal dir', function(done) {
|
||||
var dirs, p;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
|
||||
return dirs = fs.readdir(p, function(err, dirs) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
|
||||
fs.readdir(p, function(err, dirs) {
|
||||
assert.equal(err, null);
|
||||
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
it('reads dirs from a linked dir', function(done) {
|
||||
var dirs, p;
|
||||
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
|
||||
return dirs = fs.readdir(p, function(err, dirs) {
|
||||
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
|
||||
fs.readdir(p, function(err, dirs) {
|
||||
assert.equal(err, null);
|
||||
assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
|
||||
return done();
|
||||
|
@ -455,7 +442,7 @@ describe('asar package', function() {
|
|||
return it('throws ENOENT error when can not find file', function(done) {
|
||||
var p;
|
||||
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');
|
||||
return done();
|
||||
});
|
||||
|
@ -504,7 +491,7 @@ describe('asar package', function() {
|
|||
return it('throws ENOENT error when can not find file', function(done) {
|
||||
var p;
|
||||
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');
|
||||
return done();
|
||||
});
|
||||
|
@ -559,8 +546,7 @@ describe('asar package', function() {
|
|||
ref2 = require('child_process'), execFile = ref2.execFile, execFileSync = ref2.execFileSync;
|
||||
echo = path.join(fixtures, 'asar', 'echo.asar', 'echo');
|
||||
it('executes binaries', function(done) {
|
||||
var child;
|
||||
return child = execFile(echo, ['test'], function(error, stdout) {
|
||||
execFile(echo, ['test'], function(error, stdout) {
|
||||
assert.equal(error, null);
|
||||
assert.equal(stdout, 'test\n');
|
||||
return done();
|
||||
|
|
|
@ -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');
|
||||
|
||||
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;
|
||||
const BrowserWindow = remote.require('electron').BrowserWindow;
|
||||
const session = remote.require('electron').session;
|
||||
|
||||
describe('chromium feature', function() {
|
||||
var fixtures, listener;
|
||||
|
@ -310,8 +303,7 @@ describe('chromium feature', function() {
|
|||
return it('has user agent', function(done) {
|
||||
server = http.createServer();
|
||||
return server.listen(0, '127.0.0.1', function() {
|
||||
var port, websocket;
|
||||
port = server.address().port;
|
||||
var port = server.address().port;
|
||||
wss = new WebSocketServer({
|
||||
server: server
|
||||
});
|
||||
|
@ -323,7 +315,7 @@ describe('chromium feature', function() {
|
|||
return done('user agent is empty');
|
||||
}
|
||||
});
|
||||
return websocket = new WebSocket("ws://127.0.0.1:" + port);
|
||||
new WebSocket("ws://127.0.0.1:" + port);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
var assert, fs, path, temp;
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
temp = require('temp');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const temp = require('temp');
|
||||
|
||||
describe('third-party module', function() {
|
||||
var fixtures;
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
var assert, child_process, fs, os, path, remote;
|
||||
|
||||
assert = require('assert');
|
||||
|
||||
child_process = require('child_process');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
os = require('os');
|
||||
|
||||
remote = require('electron').remote;
|
||||
const assert = require('assert');
|
||||
const child_process = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const remote = require('electron').remote;
|
||||
|
||||
describe('node feature', function() {
|
||||
var fixtures;
|
||||
|
@ -103,7 +96,7 @@ describe('node feature', function() {
|
|||
error = new Error('boo!');
|
||||
lsts = process.listeners('uncaughtException');
|
||||
process.removeAllListeners('uncaughtException');
|
||||
process.on('uncaughtException', function(err) {
|
||||
process.on('uncaughtException', function() {
|
||||
var i, len, lst;
|
||||
process.removeAllListeners('uncaughtException');
|
||||
for (i = 0, len = lsts.length; i < len; i++) {
|
||||
|
|
|
@ -31,8 +31,7 @@ describe('<webview> tag', function() {
|
|||
return document.body.appendChild(webview);
|
||||
});
|
||||
return it('navigates to new page when changed', function(done) {
|
||||
var listener;
|
||||
listener = function(e) {
|
||||
var listener = function() {
|
||||
webview.src = "file://" + fixtures + "/pages/b.html";
|
||||
webview.addEventListener('console-message', function(e) {
|
||||
assert.equal(e.message, 'b');
|
||||
|
@ -74,11 +73,9 @@ describe('<webview> tag', function() {
|
|||
});
|
||||
if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) {
|
||||
return it('loads native modules when navigation happens', function(done) {
|
||||
var listener;
|
||||
listener = function(e) {
|
||||
var listener2;
|
||||
var listener = function() {
|
||||
webview.removeEventListener('did-finish-load', listener);
|
||||
listener2 = function(e) {
|
||||
var listener2 = function(e) {
|
||||
assert.equal(e.message, 'function');
|
||||
return done();
|
||||
};
|
||||
|
@ -123,7 +120,7 @@ describe('<webview> tag', function() {
|
|||
webview.removeEventListener('ipc-message', listener);
|
||||
return done();
|
||||
};
|
||||
listener2 = function(e) {
|
||||
listener2 = function() {
|
||||
webview.send('ping', message);
|
||||
return webview.removeEventListener('did-finish-load', listener2);
|
||||
};
|
||||
|
@ -459,7 +456,7 @@ describe('<webview> tag', function() {
|
|||
webview.removeEventListener('ipc-message', listener);
|
||||
return done();
|
||||
};
|
||||
listener2 = function(e) {
|
||||
listener2 = function() {
|
||||
webview.reload();
|
||||
return webview.removeEventListener('did-finish-load', listener2);
|
||||
};
|
||||
|
@ -520,7 +517,7 @@ describe('<webview> tag', function() {
|
|||
describe('dom-ready event', function() {
|
||||
return it('emits when document is loaded', function(done) {
|
||||
var server;
|
||||
server = http.createServer(function(req) {});
|
||||
server = http.createServer(function() {});
|
||||
return server.listen(0, '127.0.0.1', function() {
|
||||
var port;
|
||||
port = server.address().port;
|
||||
|
@ -538,11 +535,11 @@ describe('<webview> tag', function() {
|
|||
}
|
||||
return it('should support user gesture', function(done) {
|
||||
var listener, listener2;
|
||||
listener = function(e) {
|
||||
listener = function() {
|
||||
webview.removeEventListener('enter-html-full-screen', listener);
|
||||
return done();
|
||||
};
|
||||
listener2 = function(e) {
|
||||
listener2 = function() {
|
||||
var jsScript;
|
||||
jsScript = 'document.getElementsByTagName("video")[0].webkitRequestFullScreen()';
|
||||
webview.executeJavaScript(jsScript, true);
|
||||
|
@ -618,7 +615,7 @@ describe('<webview> tag', function() {
|
|||
return done();
|
||||
}
|
||||
};
|
||||
listener2 = function(e) {
|
||||
listener2 = function() {
|
||||
return requestId = webview.findInPage("virtual");
|
||||
};
|
||||
webview.addEventListener('found-in-page', listener);
|
||||
|
@ -629,7 +626,7 @@ describe('<webview> tag', function() {
|
|||
});
|
||||
return xdescribe('did-change-theme-color event', function() {
|
||||
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();
|
||||
});
|
||||
webview.src = "file://" + fixtures + "/pages/theme-color.html";
|
||||
|
|
Loading…
Reference in a new issue