return assert.equal(app.getVersion(), '0.1.0');
});
});
+
describe('app.setVersion(version)', function() {
return it('overrides the version', function() {
assert.equal(app.getVersion(), '0.1.0');
return app.setVersion('0.1.0');
});
});
+
describe('app.getName()', function() {
return it('returns the name field of package.json', function() {
return assert.equal(app.getName(), 'Electron Test');
});
});
+
describe('app.setName(name)', function() {
return it('overrides the name', function() {
assert.equal(app.getName(), 'Electron Test');
return app.setName('Electron Test');
});
});
+
describe('app.getLocale()', function() {
return it('should not be empty', function() {
return assert.notEqual(app.getLocale(), '');
});
});
+
describe('app.exit(exitCode)', function() {
- var appProcess;
- appProcess = null;
+ var appProcess = null;
+
afterEach(function() {
return appProcess != null ? appProcess.kill() : void 0;
});
+
return it('emits a process exit event with the code', function(done) {
var appPath, electronPath, output;
appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app');
});
});
});
+
return describe('BrowserWindow events', function() {
- var w;
- w = null;
+ var w = null;
+
afterEach(function() {
if (w != null) {
w.destroy();
}
return w = null;
});
+
it('should emit browser-window-focus event when window is focused', function(done) {
app.once('browser-window-focus', function(e, window) {
assert.equal(w.id, window.id);
});
return w.emit('focus');
});
+
it('should emit browser-window-blur event when window is blured', function(done) {
app.once('browser-window-blur', function(e, window) {
assert.equal(w.id, window.id);
});
return w.emit('blur');
});
+
return it('should emit browser-window-created event when window is created', function(done) {
app.once('browser-window-created', function(e, window) {
return setImmediate(function() {
const nativeImage = require('electron').nativeImage;
describe('clipboard module', function() {
- var fixtures;
- fixtures = path.resolve(__dirname, 'fixtures');
+ var fixtures = path.resolve(__dirname, 'fixtures');
+
describe('clipboard.readImage()', function() {
return it('returns NativeImage intance', function() {
var i, p;
return assert.equal(clipboard.readImage().toDataURL(), i.toDataURL());
});
});
+
describe('clipboard.readText()', function() {
return it('returns unicode string correctly', function() {
var text;
return assert.equal(clipboard.readText(), text);
});
});
+
describe('clipboard.readHtml()', function() {
return it('returns markup correctly', function() {
var markup, text;
return assert.equal(clipboard.readHtml(), markup);
});
});
+
describe('clipboard.readRtf', function() {
return it('returns rtf text correctly', function() {
var rtf = "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}";
return assert.equal(clipboard.readRtf(), rtf);
});
});
+
return describe('clipboard.write()', function() {
return it('returns data correctly', function() {
var i, markup, p, text, rtf;
const BrowserWindow = remote.require('electron').BrowserWindow;
describe('crash-reporter module', function() {
- var fixtures, isCI, w;
- fixtures = path.resolve(__dirname, 'fixtures');
- w = null;
+ var fixtures = path.resolve(__dirname, 'fixtures');
+ var w = null;
+
beforeEach(function() {
return w = new BrowserWindow({
show: false
});
});
+
afterEach(function() {
return w.destroy();
});
+
if (process.mas) {
return;
}
- isCI = remote.getGlobal('isCi');
+
+ var isCI = remote.getGlobal('isCi');
if (isCI) {
return;
}
+
it('should send minidump when renderer crashes', function(done) {
- var called, port, server;
this.timeout(120000);
- called = false;
- server = http.createServer(function(req, res) {
+
+ var called = false;
+ var server = http.createServer(function(req, res) {
var form;
server.close();
form = new multiparty.Form();
return done();
});
});
- port = remote.process.port;
+ var port = remote.process.port;
return server.listen(port, '127.0.0.1', function() {
port = server.address().port;
remote.process.port = port;
return w.loadURL(crashUrl);
});
});
+
return describe(".start(options)", function() {
return it('requires that the companyName and submitURL options be specified', function() {
assert.throws(function() {
const BrowserWindow = require('electron').remote.BrowserWindow;
describe('debugger module', function() {
- var fixtures, w;
- fixtures = path.resolve(__dirname, 'fixtures');
- w = null;
+ var fixtures = path.resolve(__dirname, 'fixtures');
+ var w = null;
+
beforeEach(function() {
if (w != null) {
w.destroy();
height: 400
});
});
+
afterEach(function() {
if (w != null) {
w.destroy();
};
describe('ipc module', function() {
- var fixtures;
- fixtures = path.join(__dirname, 'fixtures');
+ var fixtures = path.join(__dirname, 'fixtures');
+
describe('remote.require', function() {
it('should returns same object for the same module', function() {
var dialog1, dialog2;
dialog2 = remote.require('electron');
return assert.equal(dialog1, dialog2);
});
+
it('should work when object contains id property', function() {
var a;
a = remote.require(path.join(fixtures, 'module', 'id.js'));
return assert.equal(a.id, 1127);
});
+
return it('should search module from the user app', function() {
comparePaths(path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js'));
return comparePaths(path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules'));
});
});
+
describe('remote.createFunctionWithReturnValue', function() {
return it('should be called in browser synchronously', function() {
- var buf, call, result;
- buf = new Buffer('test');
- call = remote.require(path.join(fixtures, 'module', 'call.js'));
- result = call.call(remote.createFunctionWithReturnValue(buf));
+ var buf = new Buffer('test');
+ var call = remote.require(path.join(fixtures, 'module', 'call.js'));
+ var result = call.call(remote.createFunctionWithReturnValue(buf));
return assert.equal(result.constructor.name, 'Buffer');
});
});
+
describe('remote object in renderer', function() {
it('can change its properties', function() {
- var property, property2;
- property = remote.require(path.join(fixtures, 'module', 'property.js'));
+ var property = remote.require(path.join(fixtures, 'module', 'property.js'));
assert.equal(property.property, 1127);
property.property = 1007;
assert.equal(property.property, 1007);
- property2 = remote.require(path.join(fixtures, 'module', 'property.js'));
+ var property2 = remote.require(path.join(fixtures, 'module', 'property.js'));
assert.equal(property2.property, 1007);
return property.property = 1127;
});
+
return it('can construct an object from its member', function() {
var call, obj;
call = remote.require(path.join(fixtures, 'module', 'call.js'));
return assert.equal(obj.test, 'test');
});
});
+
describe('remote value in browser', function() {
- var print;
- print = path.join(fixtures, 'module', 'print_name.js');
+ var print = path.join(fixtures, 'module', 'print_name.js');
+
it('keeps its constructor name for objects', function() {
- var buf, print_name;
- buf = new Buffer('test');
- print_name = remote.require(print);
+ var buf = new Buffer('test');
+ var print_name = remote.require(print);
return assert.equal(print_name.print(buf), 'Buffer');
});
+
return it('supports instanceof Date', function() {
- var now, print_name;
- now = new Date();
- print_name = remote.require(print);
+ var now = new Date();
+ var print_name = remote.require(print);
assert.equal(print_name.print(now), 'Date');
return assert.deepEqual(print_name.echo(now), now);
});
});
+
describe('remote promise', function() {
return it('can be used as promise in each side', function(done) {
- var promise;
- promise = remote.require(path.join(fixtures, 'module', 'promise.js'));
+ var promise = remote.require(path.join(fixtures, 'module', 'promise.js'));
return promise.twicePromise(Promise.resolve(1234)).then(function(value) {
assert.equal(value, 2468);
return done();
});
});
});
+
describe('ipc.sender.send', function() {
return it('should work when sending an object containing id property', function(done) {
- var obj;
- obj = {
+ var obj = {
id: 1,
name: 'ly'
};
return ipcRenderer.send('message', obj);
});
});
+
describe('ipc.sendSync', function() {
it('can be replied by setting event.returnValue', function() {
- var msg;
- msg = ipcRenderer.sendSync('echo', 'test');
+ var msg = ipcRenderer.sendSync('echo', 'test');
return assert.equal(msg, 'test');
});
+
return it('does not crash when reply is not sent and browser is destroyed', function(done) {
- var w;
this.timeout(10000);
- w = new BrowserWindow({
+
+ var w = new BrowserWindow({
show: false
});
ipcMain.once('send-sync-message', function(event) {
return w.loadURL('file://' + path.join(fixtures, 'api', 'send-sync-message.html'));
});
});
+
return describe('remote listeners', function() {
- var w;
- w = null;
+ var w = null;
+
afterEach(function() {
return w.destroy();
});
+
return it('can be added and removed correctly', function() {
- var listener;
w = new BrowserWindow({
show: false
});
- listener = function() {};
+ var listener = function() {};
w.on('test', listener);
assert.equal(w.listenerCount('test'), 1);
w.removeListener('test', listener);
describe('menu module', function() {
describe('Menu.buildFromTemplate', function() {
it('should be able to attach extra fields', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: 'text',
extra: 'field'
]);
return assert.equal(menu.items[0].extra, 'field');
});
+
it('does not modify the specified template', function() {
- var template;
- template = ipcRenderer.sendSync('eval', "var template = [{label: 'text', submenu: [{label: 'sub'}]}];\nrequire('electron').Menu.buildFromTemplate(template);\ntemplate;");
+ var template = ipcRenderer.sendSync('eval', "var template = [{label: 'text', submenu: [{label: 'sub'}]}];\nrequire('electron').Menu.buildFromTemplate(template);\ntemplate;");
return assert.deepStrictEqual(template, [
{
label: 'text',
}
]);
});
+
return describe('Menu.buildFromTemplate should reorder based on item position specifiers', function() {
it('should position before existing item', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: '2',
id: '2'
assert.equal(menu.items[1].label, '2');
return assert.equal(menu.items[2].label, '3');
});
+
it('should position after existing item', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: '1',
id: '1'
assert.equal(menu.items[1].label, '2');
return assert.equal(menu.items[2].label, '3');
});
+
it('should position at endof existing separator groups', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
type: 'separator',
id: 'numbers'
assert.equal(menu.items[6].label, 'b');
return assert.equal(menu.items[7].label, 'c');
});
+
it('should create separator group if endof does not reference existing separator group', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: 'a',
id: 'a',
assert.equal(menu.items[6].label, '2');
return assert.equal(menu.items[7].label, '3');
});
+
return it('should continue inserting items at next index when no specifier is present', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: '4',
id: '4'
});
});
});
+
describe('Menu.insert', function() {
return it('should store item in @items by its index', function() {
- var item, menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: '1'
}, {
label: '3'
}
]);
- item = new MenuItem({
+ var item = new MenuItem({
label: 'inserted'
});
menu.insert(1, item);
return assert.equal(menu.items[3].label, '3');
});
});
+
describe('MenuItem.click', function() {
return it('should be called with the item object passed', function(done) {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: 'text',
click: function(item) {
return menu.delegate.executeCommand(menu.items[0].commandId);
});
});
+
return describe('MenuItem with checked property', function() {
it('clicking an checkbox item should flip the checked property', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: 'text',
type: 'checkbox'
menu.delegate.executeCommand(menu.items[0].commandId);
return assert.equal(menu.items[0].checked, true);
});
+
it('clicking an radio item should always make checked property true', function() {
- var menu;
- menu = Menu.buildFromTemplate([
+ var menu = Menu.buildFromTemplate([
{
label: 'text',
type: 'radio'
menu.delegate.executeCommand(menu.items[0].commandId);
return assert.equal(menu.items[0].checked, true);
});
+
it('at least have one item checked in each group', function() {
var i, j, k, menu, template;
template = [];
assert.equal(menu.items[0].checked, true);
return assert.equal(menu.items[12].checked, true);
});
+
it('should assign groupId automatically', function() {
var groupId, i, j, k, l, m, menu, results, template;
template = [];
}
return results;
});
+
return it("setting 'checked' should flip other items' 'checked' property", function() {
var i, j, k, l, m, menu, n, o, p, q, results, template;
template = [];
const protocol = remote.require('electron').protocol;
describe('protocol module', function() {
- var postData, protocolName, text;
- protocolName = 'sp';
- text = 'valar morghulis';
- postData = {
+ var protocolName = 'sp';
+ var text = 'valar morghulis';
+ var postData = {
name: 'post test',
type: 'string'
};
+
afterEach(function(done) {
return protocol.unregisterProtocol(protocolName, function() {
return protocol.uninterceptProtocol('http', function() {
});
});
});
+
describe('protocol.register(Any)Protocol', function() {
- var emptyHandler;
- emptyHandler = function(request, callback) {
+ var emptyHandler = function(request, callback) {
return callback();
};
+
it('throws error when scheme is already registered', function(done) {
return protocol.registerStringProtocol(protocolName, emptyHandler, function(error) {
assert.equal(error, null);
});
});
});
+
it('does not crash when handler is called twice', function(done) {
- var doubleHandler;
- doubleHandler = function(request, callback) {
+ var doubleHandler = function(request, callback) {
try {
callback(text);
return callback();
});
});
});
+
it('sends error when callback is called with nothing', function(done) {
return protocol.registerBufferProtocol(protocolName, emptyHandler, function(error) {
if (error) {
});
});
});
+
return it('does not crash when callback is called in next tick', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return setImmediate(function() {
return callback(text);
});
});
});
});
+
describe('protocol.unregisterProtocol', function() {
return it('returns error when scheme does not exist', function(done) {
return protocol.unregisterProtocol('not-exist', function(error) {
});
});
});
+
describe('protocol.registerStringProtocol', function() {
it('sends string as response', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(text);
};
return protocol.registerStringProtocol(protocolName, handler, function(error) {
});
});
});
+
it('sets Access-Control-Allow-Origin', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(text);
};
return protocol.registerStringProtocol(protocolName, handler, function(error) {
});
});
});
+
it('sends object as response', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback({
data: text,
mimeType: 'text/html'
});
});
});
+
return it('fails when sending object other than string', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(new Date);
};
return protocol.registerBufferProtocol(protocolName, handler, function(error) {
});
});
});
+
describe('protocol.registerBufferProtocol', function() {
- var buffer;
- buffer = new Buffer(text);
+ var buffer = new Buffer(text);
+
it('sends Buffer as response', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(buffer);
};
return protocol.registerBufferProtocol(protocolName, handler, function(error) {
});
});
});
+
it('sets Access-Control-Allow-Origin', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(buffer);
};
+
return protocol.registerBufferProtocol(protocolName, handler, function(error) {
if (error) {
return done(error);
});
});
});
+
it('sends object as response', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback({
data: buffer,
mimeType: 'text/html'
});
});
});
+
return it('fails when sending string', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(text);
};
return protocol.registerBufferProtocol(protocolName, handler, function(error) {
});
});
});
+
describe('protocol.registerFileProtocol', function() {
- var fileContent, filePath, normalContent, normalPath;
- filePath = path.join(__dirname, 'fixtures', 'asar', 'a.asar', 'file1');
- fileContent = require('fs').readFileSync(filePath);
- normalPath = path.join(__dirname, 'fixtures', 'pages', 'a.html');
- normalContent = require('fs').readFileSync(normalPath);
+ var filePath = path.join(__dirname, 'fixtures', 'asar', 'a.asar', 'file1');
+ var fileContent = require('fs').readFileSync(filePath);
+ var normalPath = path.join(__dirname, 'fixtures', 'pages', 'a.html');
+ var normalContent = require('fs').readFileSync(normalPath);
+
it('sends file path as response', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(filePath);
};
return protocol.registerFileProtocol(protocolName, handler, function(error) {
});
});
});
+
it('sets Access-Control-Allow-Origin', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(filePath);
};
return protocol.registerFileProtocol(protocolName, handler, function(error) {
});
});
});
+
it('can send normal file', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(normalPath);
};
+
return protocol.registerFileProtocol(protocolName, handler, function(error) {
if (error) {
return done(error);
});
});
});
+
it('fails when sending unexist-file', function(done) {
- var fakeFilePath, handler;
- fakeFilePath = path.join(__dirname, 'fixtures', 'asar', 'a.asar', 'not-exist');
- handler = function(request, callback) {
+ var fakeFilePath = path.join(__dirname, 'fixtures', 'asar', 'a.asar', 'not-exist');
+ var handler = function(request, callback) {
return callback(fakeFilePath);
};
return protocol.registerBufferProtocol(protocolName, handler, function(error) {
});
});
});
+
return it('fails when sending unsupported content', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(new Date);
};
return protocol.registerBufferProtocol(protocolName, handler, function(error) {
});
});
});
+
describe('protocol.registerHttpProtocol', function() {
it('sends url as response', function(done) {
- var server;
- server = http.createServer(function(req, res) {
+ var server = http.createServer(function(req, res) {
assert.notEqual(req.headers.accept, '');
res.end(text);
return server.close();
});
});
});
+
it('fails when sending invalid url', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback({
url: 'url'
});
});
});
});
+
return it('fails when sending unsupported content', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(new Date);
};
return protocol.registerHttpProtocol(protocolName, handler, function(error) {
});
});
});
+
describe('protocol.isProtocolHandled', function() {
it('returns true for file:', function(done) {
return protocol.isProtocolHandled('file', function(result) {
return done();
});
});
+
it('returns true for http:', function(done) {
return protocol.isProtocolHandled('http', function(result) {
assert.equal(result, true);
return done();
});
});
+
it('returns true for https:', function(done) {
return protocol.isProtocolHandled('https', function(result) {
assert.equal(result, true);
return done();
});
});
+
it('returns false when scheme is not registred', function(done) {
return protocol.isProtocolHandled('no-exist', function(result) {
assert.equal(result, false);
return done();
});
});
+
it('returns true for custom protocol', function(done) {
- var emptyHandler;
- emptyHandler = function(request, callback) {
+ var emptyHandler = function(request, callback) {
return callback();
};
return protocol.registerStringProtocol(protocolName, emptyHandler, function(error) {
});
});
});
+
return it('returns true for intercepted protocol', function(done) {
- var emptyHandler;
- emptyHandler = function(request, callback) {
+ var emptyHandler = function(request, callback) {
return callback();
};
return protocol.interceptStringProtocol('http', emptyHandler, function(error) {
});
});
});
+
describe('protocol.intercept(Any)Protocol', function() {
- var emptyHandler;
- emptyHandler = function(request, callback) {
+ var emptyHandler = function(request, callback) {
return callback();
};
+
it('throws error when scheme is already intercepted', function(done) {
return protocol.interceptStringProtocol('http', emptyHandler, function(error) {
assert.equal(error, null);
});
});
});
+
it('does not crash when handler is called twice', function(done) {
- var doubleHandler;
- doubleHandler = function(request, callback) {
+ var doubleHandler = function(request, callback) {
try {
callback(text);
return callback();
});
});
});
+
return it('sends error when callback is called with nothing', function(done) {
if (process.env.TRAVIS === 'true') {
return done();
});
});
});
+
describe('protocol.interceptStringProtocol', function() {
it('can intercept http protocol', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(text);
};
return protocol.interceptStringProtocol('http', handler, function(error) {
});
});
});
+
it('can set content-type', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback({
mimeType: 'application/json',
data: '{"value": 1}'
});
});
});
+
return it('can receive post data', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
var uploadData;
uploadData = request.uploadData[0].bytes.toString();
return callback({
});
});
});
+
describe('protocol.interceptBufferProtocol', function() {
it('can intercept http protocol', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
return callback(new Buffer(text));
};
return protocol.interceptBufferProtocol('http', handler, function(error) {
});
});
});
+
return it('can receive post data', function(done) {
- var handler;
- handler = function(request, callback) {
+ var handler = function(request, callback) {
var uploadData;
uploadData = request.uploadData[0].bytes;
return callback(uploadData);
});
});
});
+
describe('protocol.interceptHttpProtocol', function() {
return it('can send POST request', function(done) {
- var server;
- server = http.createServer(function(req, res) {
+ var server = http.createServer(function(req, res) {
var body;
body = '';
req.on('data', function(chunk) {
return server.close();
});
return server.listen(0, '127.0.0.1', function() {
- var handler, port, url;
- port = server.address().port;
- url = "http://127.0.0.1:" + port;
- handler = function(request, callback) {
+ var port = server.address().port;
+ var url = "http://127.0.0.1:" + port;
+ var handler = function(request, callback) {
var data;
data = {
url: url,
});
});
});
+
return describe('protocol.uninterceptProtocol', function() {
it('returns error when scheme does not exist', function(done) {
return protocol.uninterceptProtocol('not-exist', function(error) {
return done();
});
});
+
return it('returns error when scheme is not intercepted', function(done) {
return protocol.uninterceptProtocol('http', function(error) {
assert.notEqual(error, null);
describe('screen module', function() {
describe('screen.getCursorScreenPoint()', function() {
return it('returns a point object', function() {
- var point;
- point = screen.getCursorScreenPoint();
+ var point = screen.getCursorScreenPoint();
assert.equal(typeof point.x, 'number');
return assert.equal(typeof point.y, 'number');
});
});
+
return describe('screen.getPrimaryDisplay()', function() {
return it('returns a display object', function() {
- var display;
- display = screen.getPrimaryDisplay();
+ var display = screen.getPrimaryDisplay();
assert.equal(typeof display.scaleFactor, 'number');
assert(display.size.width > 0);
return assert(display.size.height > 0);
const BrowserWindow = remote.BrowserWindow;
describe('session module', function() {
- var fixtures, url, w;
this.timeout(10000);
- fixtures = path.resolve(__dirname, 'fixtures');
- w = null;
- url = "http://127.0.0.1";
+
+ var fixtures = path.resolve(__dirname, 'fixtures');
+ var w = null;
+ var url = "http://127.0.0.1";
+
beforeEach(function() {
return w = new BrowserWindow({
show: false,
height: 400
});
});
+
afterEach(function() {
return w.destroy();
});
});
});
});
+
it('should over-write the existent cookie', function(done) {
return session.defaultSession.cookies.set({
url: url,
});
});
});
+
it('should remove cookies', function(done) {
return session.defaultSession.cookies.set({
url: url,
height: 400
});
});
+
afterEach(function() {
return w.destroy();
});
assert(fs.existsSync(downloadFilePath));
return fs.unlinkSync(downloadFilePath);
};
+
it('can download using BrowserWindow.loadURL', function(done) {
return downloadServer.listen(0, '127.0.0.1', function() {
var port;
});
});
});
+
it('can download using WebView.downloadURL', function(done) {
return downloadServer.listen(0, '127.0.0.1', function() {
var port, webview;
return document.body.appendChild(webview);
});
});
+
it('can cancel download', function(done) {
return downloadServer.listen(0, '127.0.0.1', function() {
var port;
const webFrame = require('electron').webFrame;
describe('webFrame module', function() {
- var fixtures;
- fixtures = path.resolve(__dirname, 'fixtures');
+ var fixtures = path.resolve(__dirname, 'fixtures');
return describe('webFrame.registerURLSchemeAsPrivileged', function() {
return it('supports fetch api', function(done) {
- var url;
webFrame.registerURLSchemeAsPrivileged('file');
- url = "file://" + fixtures + "/assets/logo.png";
+ var url = "file://" + fixtures + "/assets/logo.png";
return fetch(url).then(function(response) {
assert(response.ok);
return done();
const session = remote.session;
describe('webRequest module', function() {
- var defaultURL, server, ses;
- ses = session.defaultSession;
- server = http.createServer(function(req, res) {
+ var ses = session.defaultSession;
+ var server = http.createServer(function(req, res) {
var content;
res.setHeader('Custom', ['Header']);
content = req.url;
}
return res.end(content);
});
- defaultURL = null;
+ var defaultURL = null;
+
before(function(done) {
return server.listen(0, '127.0.0.1', function() {
var port;
return done();
});
});
+
after(function() {
return server.close();
});
+
describe('webRequest.onBeforeRequest', function() {
afterEach(function() {
return ses.webRequest.onBeforeRequest(null);
});
+
it('can cancel the request', function(done) {
ses.webRequest.onBeforeRequest(function(details, callback) {
return callback({
}
});
});
+
it('can filter URLs', function(done) {
- var filter;
- filter = {
+ var filter = {
urls: [defaultURL + "filter/*"]
};
ses.webRequest.onBeforeRequest(filter, function(details, callback) {
}
});
});
+
it('receives details object', function(done) {
ses.webRequest.onBeforeRequest(function(details, callback) {
assert.equal(typeof details.id, 'number');
}
});
});
+
it('receives post data in details object', function(done) {
var postData = {
name: 'post test',
}
});
});
+
return it('can redirect the request', function(done) {
ses.webRequest.onBeforeRequest(function(details, callback) {
if (details.url === defaultURL) {
});
});
});
+
describe('webRequest.onBeforeSendHeaders', function() {
afterEach(function() {
return ses.webRequest.onBeforeSendHeaders(null);
});
+
it('receives details object', function(done) {
ses.webRequest.onBeforeSendHeaders(function(details, callback) {
assert.equal(typeof details.requestHeaders, 'object');
}
});
});
+
it('can change the request headers', function(done) {
ses.webRequest.onBeforeSendHeaders(function(details, callback) {
var requestHeaders;
}
});
});
+
return it('resets the whole headers', function(done) {
var requestHeaders;
requestHeaders = {
});
});
});
+
describe('webRequest.onSendHeaders', function() {
afterEach(function() {
return ses.webRequest.onSendHeaders(null);
});
+
return it('receives details object', function(done) {
ses.webRequest.onSendHeaders(function(details) {
return assert.equal(typeof details.requestHeaders, 'object');
});
});
});
+
describe('webRequest.onHeadersReceived', function() {
afterEach(function() {
return ses.webRequest.onHeadersReceived(null);
});
+
it('receives details object', function(done) {
ses.webRequest.onHeadersReceived(function(details, callback) {
assert.equal(details.statusLine, 'HTTP/1.1 200 OK');
}
});
});
+
it('can change the response header', function(done) {
ses.webRequest.onHeadersReceived(function(details, callback) {
var responseHeaders;
}
});
});
+
return it('does not change header by default', function(done) {
ses.webRequest.onHeadersReceived(function(details, callback) {
return callback({});
});
});
});
+
describe('webRequest.onResponseStarted', function() {
afterEach(function() {
return ses.webRequest.onResponseStarted(null);
});
+
return it('receives details object', function(done) {
ses.webRequest.onResponseStarted(function(details) {
assert.equal(typeof details.fromCache, 'boolean');
});
});
});
+
describe('webRequest.onBeforeRedirect', function() {
afterEach(function() {
ses.webRequest.onBeforeRedirect(null);
return ses.webRequest.onBeforeRequest(null);
});
+
return it('receives details object', function(done) {
var redirectURL;
redirectURL = defaultURL + "redirect";
});
});
});
+
describe('webRequest.onCompleted', function() {
afterEach(function() {
return ses.webRequest.onCompleted(null);
});
+
return it('receives details object', function(done) {
ses.webRequest.onCompleted(function(details) {
assert.equal(typeof details.fromCache, 'boolean');
});
});
});
+
return describe('webRequest.onErrorOccurred', function() {
afterEach(function() {
ses.webRequest.onErrorOccurred(null);
return ses.webRequest.onBeforeRequest(null);
});
+
return it('receives details object', function(done) {
ses.webRequest.onBeforeRequest(function(details, callback) {
return callback({
const BrowserWindow = remote.require('electron').BrowserWindow;
describe('asar package', function() {
- var fixtures;
- fixtures = path.join(__dirname, 'fixtures');
+ var fixtures = path.join(__dirname, 'fixtures');
+
describe('node api', function() {
describe('fs.readFileSync', function() {
it('does not leak fd', function() {
readCalls++;
}
});
+
it('reads a normal file', function() {
var file1, file2, file3;
file1 = path.join(fixtures, 'asar', 'a.asar', 'file1');
file3 = path.join(fixtures, 'asar', 'a.asar', 'file3');
return assert.equal(fs.readFileSync(file3).toString().trim(), 'file3');
});
+
it('reads from a empty file', function() {
var buffer, file;
file = path.join(fixtures, 'asar', 'empty.asar', 'file1');
assert.equal(buffer.length, 0);
return assert.equal(buffer.toString(), '');
});
+
it('reads a linked file', function() {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'link1');
return assert.equal(fs.readFileSync(p).toString().trim(), 'file1');
});
+
it('reads a file from linked directory', function() {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1');
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
return assert.equal(fs.readFileSync(p).toString().trim(), 'file1');
});
+
it('throws ENOENT error when can not find file', function() {
var p, throws;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
};
return assert.throws(throws, /ENOENT/);
});
+
it('passes ENOENT error to callback when can not find file', function() {
var async, p;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
});
return async = true;
});
+
return it('reads a normal file with unpacked files', function() {
var p;
p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt');
return assert.equal(fs.readFileSync(p).toString().trim(), 'a');
});
});
+
describe('fs.readFile', function() {
it('reads a normal file', function(done) {
var p;
return done();
});
});
+
it('reads from a empty file', function(done) {
var p;
p = path.join(fixtures, 'asar', 'empty.asar', 'file1');
return done();
});
});
+
it('reads a linked file', function(done) {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'link1');
return done();
});
});
+
it('reads a file from linked directory', function(done) {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
return done();
});
});
+
return it('throws ENOENT error when can not find file', function(done) {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
});
});
});
+
describe('fs.lstatSync', function() {
it('handles path with trailing slash correctly', function() {
var p;
fs.lstatSync(p);
return fs.lstatSync(p + '/');
});
+
it('returns information of root', function() {
var p, stats;
p = path.join(fixtures, 'asar', 'a.asar');
assert.equal(stats.isSymbolicLink(), false);
return assert.equal(stats.size, 0);
});
+
it('returns information of a normal file', function() {
var file, j, len, p, ref2, results, stats;
ref2 = ['file1', 'file2', 'file3', path.join('dir1', 'file1'), path.join('link2', 'file1')];
}
return results;
});
+
it('returns information of a normal directory', function() {
var file, j, len, p, ref2, results, stats;
ref2 = ['dir1', 'dir2', 'dir3'];
}
return results;
});
+
it('returns information of a linked file', function() {
var file, j, len, p, ref2, results, stats;
ref2 = ['link1', path.join('dir1', 'link1'), path.join('link2', 'link2')];
}
return results;
});
+
it('returns information of a linked directory', function() {
var file, j, len, p, ref2, results, stats;
ref2 = ['link2', path.join('dir1', 'link2'), path.join('link2', 'link2')];
}
return results;
});
+
return it('throws ENOENT error when can not find file', function() {
var file, j, len, p, ref2, results, throws;
ref2 = ['file4', 'file5', path.join('dir1', 'file4')];
return results;
});
});
+
describe('fs.lstat', function() {
it('handles path with trailing slash correctly', function(done) {
- var p;
- p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
return fs.lstat(p + '/', done);
});
+
it('returns information of root', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar');
fs.lstat(p, function(err, stats) {
return done();
});
});
+
it('returns information of a normal file', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1');
fs.lstat(p, function(err, stats) {
return done();
});
});
+
it('returns information of a normal directory', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
fs.lstat(p, function(err, stats) {
return done();
});
});
+
it('returns information of a linked file', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link1');
fs.lstat(p, function(err, stats) {
return done();
});
});
+
it('returns information of a linked directory', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
fs.lstat(p, function(err, stats) {
return done();
});
});
+
return it('throws ENOENT error when can not find file', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'file4');
fs.lstat(p, function(err) {
});
});
});
+
describe('fs.realpathSync', function() {
it('returns real path root', function() {
- var p, parent, r;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = 'a.asar';
- r = fs.realpathSync(path.join(parent, p));
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = 'a.asar';
+ var r = fs.realpathSync(path.join(parent, p));
return assert.equal(r, path.join(parent, p));
});
+
it('returns real path of a normal file', function() {
- var p, parent, r;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'file1');
- r = fs.realpathSync(path.join(parent, p));
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'file1');
+ var r = fs.realpathSync(path.join(parent, p));
return assert.equal(r, path.join(parent, p));
});
+
it('returns real path of a normal directory', function() {
- var p, parent, r;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'dir1');
- r = fs.realpathSync(path.join(parent, p));
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'dir1');
+ var r = fs.realpathSync(path.join(parent, p));
return assert.equal(r, path.join(parent, p));
});
+
it('returns real path of a linked file', function() {
- var p, parent, r;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'link2', 'link1');
- r = fs.realpathSync(path.join(parent, p));
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'link2', 'link1');
+ var r = fs.realpathSync(path.join(parent, p));
return assert.equal(r, path.join(parent, 'a.asar', 'file1'));
});
+
it('returns real path of a linked directory', function() {
- var p, parent, r;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'link2', 'link2');
- r = fs.realpathSync(path.join(parent, p));
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'link2', 'link2');
+ var r = fs.realpathSync(path.join(parent, p));
return assert.equal(r, path.join(parent, 'a.asar', 'dir1'));
});
+
return it('throws ENOENT error when can not find file', function() {
- var p, parent, throws;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'not-exist');
- throws = function() {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'not-exist');
+ var throws = function() {
return fs.realpathSync(path.join(parent, p));
};
return assert.throws(throws, /ENOENT/);
});
});
+
describe('fs.realpath', function() {
it('returns real path root', function(done) {
- var p, parent;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = 'a.asar';
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = 'a.asar';
return fs.realpath(path.join(parent, p), function(err, r) {
assert.equal(err, null);
assert.equal(r, path.join(parent, p));
return done();
});
});
+
it('returns real path of a normal file', function(done) {
- var p, parent;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'file1');
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'file1');
return fs.realpath(path.join(parent, p), function(err, r) {
assert.equal(err, null);
assert.equal(r, path.join(parent, p));
return done();
});
});
+
it('returns real path of a normal directory', function(done) {
- var p, parent;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'dir1');
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'dir1');
return fs.realpath(path.join(parent, p), function(err, r) {
assert.equal(err, null);
assert.equal(r, path.join(parent, p));
return done();
});
});
+
it('returns real path of a linked file', function(done) {
- var p, parent;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'link2', 'link1');
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'link2', 'link1');
return fs.realpath(path.join(parent, p), function(err, r) {
assert.equal(err, null);
assert.equal(r, path.join(parent, 'a.asar', 'file1'));
return done();
});
});
+
it('returns real path of a linked directory', function(done) {
- var p, parent;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'link2', 'link2');
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'link2', 'link2');
return fs.realpath(path.join(parent, p), function(err, r) {
assert.equal(err, null);
assert.equal(r, path.join(parent, 'a.asar', 'dir1'));
});
});
return it('throws ENOENT error when can not find file', function(done) {
- var p, parent;
- parent = fs.realpathSync(path.join(fixtures, 'asar'));
- p = path.join('a.asar', 'not-exist');
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'));
+ var p = path.join('a.asar', 'not-exist');
return fs.realpath(path.join(parent, p), function(err) {
assert.equal(err.code, 'ENOENT');
return done();
});
describe('fs.readdirSync', function() {
it('reads dirs from root', function() {
- var dirs, p;
- p = path.join(fixtures, 'asar', 'a.asar');
- dirs = fs.readdirSync(p);
+ var p = path.join(fixtures, 'asar', 'a.asar');
+ var dirs = fs.readdirSync(p);
return assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js']);
});
+
it('reads dirs from a normal dir', function() {
- var dirs, p;
- p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
- dirs = fs.readdirSync(p);
+ var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
+ var dirs = fs.readdirSync(p);
return assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
});
+
it('reads dirs from a linked dir', function() {
- var dirs, p;
- p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
- dirs = fs.readdirSync(p);
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
+ var dirs = fs.readdirSync(p);
return assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
});
+
return it('throws ENOENT error when can not find file', function() {
- var p, throws;
- p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- throws = function() {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
+ var throws = function() {
return fs.readdirSync(p);
};
return assert.throws(throws, /ENOENT/);
});
});
+
describe('fs.readdir', function() {
it('reads dirs from root', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar');
return done();
});
});
+
it('reads dirs from a normal dir', function(done) {
var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
fs.readdir(p, function(err, dirs) {
return done();
});
});
+
return it('throws ENOENT error when can not find file', function(done) {
- var p;
- p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return fs.readdir(p, function(err) {
assert.equal(err.code, 'ENOENT');
return done();
});
});
});
+
describe('fs.openSync', function() {
it('opens a normal/linked/under-linked-directory file', function() {
var buffer, fd, file, j, len, p, ref2, results;
}
return results;
});
+
return it('throws ENOENT error when can not find file', function() {
- var p, throws;
- p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- throws = function() {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
+ var throws = function() {
return fs.openSync(p);
};
return assert.throws(throws, /ENOENT/);
});
});
+
describe('fs.open', function() {
it('opens a normal file', function(done) {
- var p;
- p = path.join(fixtures, 'asar', 'a.asar', 'file1');
+ var p = path.join(fixtures, 'asar', 'a.asar', 'file1');
return fs.open(p, 'r', function(err, fd) {
var buffer;
assert.equal(err, null);
});
});
});
+
return it('throws ENOENT error when can not find file', function(done) {
- var p;
- p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return fs.open(p, 'r', function(err) {
assert.equal(err.code, 'ENOENT');
return done();
});
});
});
+
describe('fs.mkdir', function() {
return it('throws error when calling inside asar archive', function(done) {
- var p;
- p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return fs.mkdir(p, function(err) {
assert.equal(err.code, 'ENOTDIR');
return done();
});
});
});
+
describe('fs.mkdirSync', function() {
return it('throws error when calling inside asar archive', function() {
- var p;
- p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
return assert.throws((function() {
return fs.mkdirSync(p);
}), new RegExp('ENOTDIR'));
});
});
+
describe('child_process.fork', function() {
it('opens a normal js file', function(done) {
- var child;
- child = child_process.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'));
+ var child = child_process.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'));
child.on('message', function(msg) {
assert.equal(msg, 'message');
return done();
});
return child.send('message');
});
+
return it('supports asar in the forked js', function(done) {
- var child, file;
- file = path.join(fixtures, 'asar', 'a.asar', 'file1');
- child = child_process.fork(path.join(fixtures, 'module', 'asar.js'));
+ var file = path.join(fixtures, 'asar', 'a.asar', 'file1');
+ var child = child_process.fork(path.join(fixtures, 'module', 'asar.js'));
child.on('message', function(content) {
assert.equal(content, fs.readFileSync(file).toString());
return done();
return child.send(file);
});
});
+
describe('child_process.execFile', function() {
var echo, execFile, execFileSync, ref2;
if (process.platform !== 'darwin') {
}
ref2 = require('child_process'), execFile = ref2.execFile, execFileSync = ref2.execFileSync;
echo = path.join(fixtures, 'asar', 'echo.asar', 'echo');
+
it('executes binaries', function(done) {
execFile(echo, ['test'], function(error, stdout) {
assert.equal(error, null);
return done();
});
});
+
return xit('execFileSync executes binaries', function() {
var output;
output = execFileSync(echo, ['test']);
return assert.equal(String(output), 'test\n');
});
});
+
describe('internalModuleReadFile', function() {
- var internalModuleReadFile;
- internalModuleReadFile = process.binding('fs').internalModuleReadFile;
+ var internalModuleReadFile = process.binding('fs').internalModuleReadFile;
+
it('read a normal file', function() {
var file1, file2, file3;
file1 = path.join(fixtures, 'asar', 'a.asar', 'file1');
file3 = path.join(fixtures, 'asar', 'a.asar', 'file3');
return assert.equal(internalModuleReadFile(file3).toString().trim(), 'file3');
});
+
return it('reads a normal file with unpacked files', function() {
var p;
p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt');
return assert.equal(internalModuleReadFile(p).toString().trim(), 'a');
});
});
+
return describe('process.noAsar', function() {
- var errorName;
- errorName = process.platform === 'win32' ? 'ENOENT' : 'ENOTDIR';
+ var errorName = process.platform === 'win32' ? 'ENOENT' : 'ENOTDIR';
+
beforeEach(function() {
return process.noAsar = true;
});
+
afterEach(function() {
return process.noAsar = false;
});
+
it('disables asar support in sync API', function() {
- var dir, file;
- file = path.join(fixtures, 'asar', 'a.asar', 'file1');
- dir = path.join(fixtures, 'asar', 'a.asar', 'dir1');
+ var file = path.join(fixtures, 'asar', 'a.asar', 'file1');
+ var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1');
assert.throws((function() {
return fs.readFileSync(file);
}), new RegExp(errorName));
return fs.readdirSync(dir);
}), new RegExp(errorName));
});
+
it('disables asar support in async API', function(done) {
var dir, file;
file = path.join(fixtures, 'asar', 'a.asar', 'file1');
});
});
});
+
return it('treats *.asar as normal file', function() {
var asar, content1, content2, originalFs;
originalFs = require('original-fs');
});
});
});
+
describe('asar protocol', function() {
- var url;
- url = require('url');
+ var url = require('url');
+
it('can request a file in package', function(done) {
- var p;
- p = path.resolve(fixtures, 'asar', 'a.asar', 'file1');
+ var p = path.resolve(fixtures, 'asar', 'a.asar', 'file1');
return $.get("file://" + p, function(data) {
assert.equal(data.trim(), 'file1');
return done();
});
});
+
it('can request a file in package with unpacked files', function(done) {
- var p;
- p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt');
+ var p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt');
return $.get("file://" + p, function(data) {
assert.equal(data.trim(), 'a');
return done();
});
});
+
it('can request a linked file in package', function(done) {
- var p;
- p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1');
+ var p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1');
return $.get("file://" + p, function(data) {
assert.equal(data.trim(), 'file1');
return done();
});
});
+
it('can request a file in filesystem', function(done) {
- var p;
- p = path.resolve(fixtures, 'asar', 'file');
+ var p = path.resolve(fixtures, 'asar', 'file');
return $.get("file://" + p, function(data) {
assert.equal(data.trim(), 'file');
return done();
});
});
+
it('gets 404 when file is not found', function(done) {
- var p;
- p = path.resolve(fixtures, 'asar', 'a.asar', 'no-exist');
+ var p = path.resolve(fixtures, 'asar', 'a.asar', 'no-exist');
return $.ajax({
url: "file://" + p,
error: function(err) {
}
});
});
+
it('sets __dirname correctly', function(done) {
- var p, u, w;
after(function() {
w.destroy();
return ipcMain.removeAllListeners('dirname');
});
- w = new BrowserWindow({
+
+ var w = new BrowserWindow({
show: false,
width: 400,
height: 400
});
- p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html');
- u = url.format({
+ var p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html');
+ var u = url.format({
protocol: 'file',
slashed: true,
pathname: p
});
return w.loadURL(u);
});
+
return it('loads script tag in html', function(done) {
- var p, u, w;
after(function() {
w.destroy();
return ipcMain.removeAllListeners('ping');
});
- w = new BrowserWindow({
+
+ var w = new BrowserWindow({
show: false,
width: 400,
height: 400
});
- p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html');
- u = url.format({
+ var p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html');
+ var u = url.format({
protocol: 'file',
slashed: true,
pathname: p
});
});
});
+
describe('original-fs module', function() {
- var originalFs;
- originalFs = require('original-fs');
+ var originalFs = require('original-fs');
+
it('treats .asar as file', function() {
var file, stats;
file = path.join(fixtures, 'asar', 'a.asar');
stats = originalFs.statSync(file);
return assert(stats.isFile());
});
+
return it('is available in forked scripts', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'original-fs.js'));
return child.send('message');
});
});
+
describe('graceful-fs module', function() {
- var gfs;
- gfs = require('graceful-fs');
+ var gfs = require('graceful-fs');
+
it('recognize asar archvies', function() {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'link1');
return assert.notEqual(fs.readdir, gfs.readdir);
});
});
+
describe('mkdirp module', function() {
- var mkdirp;
- mkdirp = require('mkdirp');
+ var mkdirp = require('mkdirp');
+
return it('throws error when calling inside asar archive', function() {
var p;
p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
}), new RegExp('ENOTDIR'));
});
});
+
return describe('native-image', function() {
it('reads image from asar archive', function() {
- var logo, p;
- p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png');
- logo = nativeImage.createFromPath(p);
+ var p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png');
+ var logo = nativeImage.createFromPath(p);
return assert.deepEqual(logo.getSize(), {
width: 55,
height: 55
});
});
+
return it('reads image from asar archive with unpacked files', function() {
- var logo, p;
- p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png');
- logo = nativeImage.createFromPath(p);
+ var p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png');
+ var logo = nativeImage.createFromPath(p);
return assert.deepEqual(logo.getSize(), {
width: 1024,
height: 1024
const session = remote.require('electron').session;
describe('chromium feature', function() {
- var fixtures, listener;
- fixtures = path.resolve(__dirname, 'fixtures');
- listener = null;
+ var fixtures = path.resolve(__dirname, 'fixtures');
+ var listener = null;
+
afterEach(function() {
if (listener != null) {
window.removeEventListener('message', listener);
}
return listener = null;
});
+
xdescribe('heap snapshot', function() {
return it('does not crash', function() {
return process.atomBinding('v8_util').takeHeapSnapshot();
});
});
+
describe('sending request of http protocol urls', function() {
return it('does not crash', function(done) {
var server;
});
});
});
+
describe('document.hidden', function() {
- var url, w;
- url = "file://" + fixtures + "/pages/document-hidden.html";
- w = null;
+ var url = "file://" + fixtures + "/pages/document-hidden.html";
+ var w = null;
+
afterEach(function() {
return w != null ? w.destroy() : void 0;
});
+
it('is set correctly when window is not shown', function(done) {
w = new BrowserWindow({
show: false
});
return w.loadURL(url);
});
+
return it('is set correctly when window is inactive', function(done) {
w = new BrowserWindow({
show: false
return w.loadURL(url);
});
});
+
xdescribe('navigator.webkitGetUserMedia', function() {
return it('calls its callbacks', function(done) {
this.timeout(5000);
});
});
});
+
describe('navigator.language', function() {
return it('should not be empty', function() {
return assert.notEqual(navigator.language, '');
});
});
+
describe('navigator.serviceWorker', function() {
- var url, w;
- url = "file://" + fixtures + "/pages/service-worker/index.html";
- w = null;
+ var url = "file://" + fixtures + "/pages/service-worker/index.html";
+ var w = null;
+
afterEach(function() {
return w != null ? w.destroy() : void 0;
});
+
return it('should register for file scheme', function(done) {
w = new BrowserWindow({
show: false
return w.loadURL(url);
});
});
+
describe('window.open', function() {
this.timeout(20000);
+
it('returns a BrowserWindowProxy object', function() {
var b;
b = window.open('about:blank', '', 'show=no');
assert.equal(b.constructor.name, 'BrowserWindowProxy');
return b.close();
});
+
it('accepts "node-integration" as feature', function(done) {
var b;
listener = function(event) {
window.addEventListener('message', listener);
return b = window.open("file://" + fixtures + "/pages/window-opener-node.html", '', 'nodeIntegration=no,show=no');
});
+
it('inherit options of parent window', function(done) {
var b;
listener = function(event) {
window.addEventListener('message', listener);
return b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', 'show=no');
});
+
return it('does not override child options', function(done) {
var b, size;
size = {
return b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', "show=no,width=" + size.width + ",height=" + size.height);
});
});
+
describe('window.opener', function() {
var url, w;
this.timeout(10000);
return b = window.open(url, '', 'show=no');
});
});
+
describe('window.postMessage', function() {
return it('sets the source and origin correctly', function(done) {
var b, sourceId;
});
});
});
+
describe('window.opener.postMessage', function() {
return it('sets source and origin correctly', function(done) {
var b;
return b = window.open("file://" + fixtures + "/pages/window-opener-postMessage.html", '', 'show=no');
});
});
+
describe('creating a Uint8Array under browser side', function() {
return it('does not crash', function() {
var RUint8Array;
return new RUint8Array;
});
});
+
describe('webgl', function() {
return it('can be get as context in canvas', function() {
var webgl;
return assert.notEqual(webgl, null);
});
});
+
describe('web workers', function() {
it('Worker can work', function(done) {
var message, worker;
};
return worker.postMessage(message);
});
+
return it('SharedWorker can work', function(done) {
var message, worker;
worker = new SharedWorker('../fixtures/workers/shared_worker.js');
return worker.port.postMessage(message);
});
});
+
describe('iframe', function() {
- var iframe;
- iframe = null;
+ var iframe = null;
+
beforeEach(function() {
return iframe = document.createElement('iframe');
});
+
afterEach(function() {
return document.body.removeChild(iframe);
});
+
return it('does not have node integration', function(done) {
iframe.src = "file://" + fixtures + "/pages/set-global.html";
document.body.appendChild(iframe);
};
});
});
+
describe('storage', function() {
return it('requesting persitent quota works', function(done) {
return navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function(grantedBytes) {
});
});
});
+
describe('websockets', function() {
- var WebSocketServer, server, wss;
- wss = null;
- server = null;
- WebSocketServer = ws.Server;
+ var wss = null;
+ var server = null;
+ var WebSocketServer = ws.Server;
+
afterEach(function() {
wss.close();
return server.close();
});
+
return it('has user agent', function(done) {
server = http.createServer();
return server.listen(0, '127.0.0.1', function() {
});
});
});
+
return describe('Promise', function() {
it('resolves correctly in Node.js calls', function(done) {
document.registerElement('x-element', {
return called = true;
});
});
+
return it('resolves correctly in Electron calls', function(done) {
document.registerElement('y-element', {
prototype: Object.create(HTMLElement.prototype, {
const temp = require('temp');
describe('third-party module', function() {
- var fixtures;
- fixtures = path.join(__dirname, 'fixtures');
+ var fixtures = path.join(__dirname, 'fixtures');
temp.track();
+
if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) {
describe('runas', function() {
it('can be required in renderer', function() {
return require('runas');
});
+
return it('can be required in node binary', function(done) {
var child, runas;
runas = path.join(fixtures, 'module', 'runas.js');
});
});
});
+
describe('ffi', function() {
return it('does not crash', function() {
var ffi, libm;
});
});
}
+
return describe('q', function() {
var Q;
Q = require('q');
const remote = require('electron').remote;
describe('node feature', function() {
- var fixtures;
- fixtures = path.join(__dirname, 'fixtures');
+ var fixtures = path.join(__dirname, 'fixtures');
+
describe('child_process', function() {
return describe('child_process.fork', function() {
it('works in current process', function(done) {
});
return child.send('message');
});
+
it('preserves args', function(done) {
var args, child;
args = ['--expose_gc', '-test', '1'];
});
return child.send('message');
});
+
it('works in forked process', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'fork_ping.js'));
});
return child.send('message');
});
+
it('works in forked process when options.env is specifed', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'fork_ping.js'), [], {
});
return child.send('message');
});
+
it('works in browser process', function(done) {
var child, fork;
fork = remote.require('child_process').fork;
});
return child.send('message');
});
+
it('has String::localeCompare working in script', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'locale-compare.js'));
});
return child.send('message');
});
+
return it('has setImmediate working in script', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'set-immediate.js'));
});
});
});
+
describe('contexts', function() {
describe('setTimeout in fs callback', function() {
if (process.env.TRAVIS === 'true') {
return;
}
+
return it('does not crash', function(done) {
return fs.readFile(__filename, function() {
return setTimeout(done, 0);
});
});
});
+
describe('throw error in node context', function() {
return it('gets caught', function(done) {
var error, lsts;
});
});
});
+
describe('setTimeout called under Chromium event loop in browser process', function() {
return it('can be scheduled in time', function(done) {
return remote.getGlobal('setTimeout')(done, 0);
});
});
+
return describe('setInterval called under Chromium event loop in browser process', function() {
return it('can be scheduled in time', function(done) {
var clear, interval;
});
});
});
+
describe('message loop', function() {
describe('process.nextTick', function() {
it('emits the callback', function(done) {
return process.nextTick(done);
});
+
return it('works in nested calls', function(done) {
return process.nextTick(function() {
return process.nextTick(function() {
});
});
});
+
return describe('setImmediate', function() {
it('emits the callback', function(done) {
return setImmediate(done);
});
+
return it('works in nested calls', function(done) {
return setImmediate(function() {
return setImmediate(function() {
});
});
});
+
describe('net.connect', function() {
if (process.platform !== 'darwin') {
return;
}
+
return it('emit error when connect to a socket path without listeners', function(done) {
var child, script, socketPath;
socketPath = path.join(os.tmpdir(), 'atom-shell-test.sock');
});
});
});
+
describe('Buffer', function() {
it('can be created from WebKit external string', function() {
var b, p;
assert.equal(b.toString(), '闲云潭影日悠悠,物换星移几度秋');
return assert.equal(Buffer.byteLength(p.innerText), 45);
});
+
return it('correctly parses external one-byte UTF8 string', function() {
var b, p;
p = document.createElement('p');