diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js
index beb84a8d7486..77e8b004bfe6 100644
--- a/spec/api-browser-window-spec.js
+++ b/spec/api-browser-window-spec.js
@@ -1,782 +1,782 @@
-'use strict';
+'use strict'
-const assert = require('assert');
-const fs = require('fs');
-const path = require('path');
-const os = require('os');
+const assert = require('assert')
+const fs = require('fs')
+const path = require('path')
+const os = require('os')
-const remote = require('electron').remote;
-const screen = require('electron').screen;
+const remote = require('electron').remote
+const screen = require('electron').screen
-const app = remote.require('electron').app;
-const ipcMain = remote.require('electron').ipcMain;
-const ipcRenderer = require('electron').ipcRenderer;
-const BrowserWindow = remote.require('electron').BrowserWindow;
+const app = remote.require('electron').app
+const ipcMain = remote.require('electron').ipcMain
+const ipcRenderer = require('electron').ipcRenderer
+const BrowserWindow = remote.require('electron').BrowserWindow
-const isCI = remote.getGlobal('isCi');
+const isCI = remote.getGlobal('isCi')
-describe('browser-window module', function() {
- var fixtures = path.resolve(__dirname, 'fixtures');
- var w = null;
+describe('browser-window module', function () {
+ var fixtures = path.resolve(__dirname, 'fixtures')
+ var w = null
- beforeEach(function() {
+ beforeEach(function () {
if (w != null) {
- w.destroy();
+ w.destroy()
}
w = new BrowserWindow({
show: false,
width: 400,
height: 400
- });
- });
+ })
+ })
- afterEach(function() {
+ afterEach(function () {
if (w != null) {
- w.destroy();
+ w.destroy()
}
- w = null;
- });
+ w = null
+ })
- describe('BrowserWindow.close()', function() {
- it('should emit unload handler', function(done) {
- w.webContents.on('did-finish-load', function() {
- w.close();
- });
- w.on('closed', function() {
- var test = path.join(fixtures, 'api', 'unload');
- var content = fs.readFileSync(test);
- fs.unlinkSync(test);
- assert.equal(String(content), 'unload');
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'unload.html'));
- });
+ describe('BrowserWindow.close()', function () {
+ it('should emit unload handler', function (done) {
+ w.webContents.on('did-finish-load', function () {
+ w.close()
+ })
+ w.on('closed', function () {
+ var test = path.join(fixtures, 'api', 'unload')
+ var content = fs.readFileSync(test)
+ fs.unlinkSync(test)
+ assert.equal(String(content), 'unload')
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'unload.html'))
+ })
- it('should emit beforeunload handler', function(done) {
- w.on('onbeforeunload', function() {
- done();
- });
- w.webContents.on('did-finish-load', function() {
- w.close();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'beforeunload-false.html'));
- });
- });
+ it('should emit beforeunload handler', function (done) {
+ w.on('onbeforeunload', function () {
+ done()
+ })
+ w.webContents.on('did-finish-load', function () {
+ w.close()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'beforeunload-false.html'))
+ })
+ })
- describe('window.close()', function() {
- it('should emit unload handler', function(done) {
- w.on('closed', function() {
- var test = path.join(fixtures, 'api', 'close');
- var content = fs.readFileSync(test);
- fs.unlinkSync(test);
- assert.equal(String(content), 'close');
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'close.html'));
- });
+ describe('window.close()', function () {
+ it('should emit unload handler', function (done) {
+ w.on('closed', function () {
+ var test = path.join(fixtures, 'api', 'close')
+ var content = fs.readFileSync(test)
+ fs.unlinkSync(test)
+ assert.equal(String(content), 'close')
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'close.html'))
+ })
- it('should emit beforeunload handler', function(done) {
- w.on('onbeforeunload', function() {
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'));
- });
- });
+ it('should emit beforeunload handler', function (done) {
+ w.on('onbeforeunload', function () {
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'))
+ })
+ })
- describe('BrowserWindow.destroy()', function() {
- it('prevents users to access methods of webContents', function() {
- var webContents = w.webContents;
- w.destroy();
- assert.throws((function() {
- webContents.getId();
- }), /Object has been destroyed/);
- });
- });
+ describe('BrowserWindow.destroy()', function () {
+ it('prevents users to access methods of webContents', function () {
+ var webContents = w.webContents
+ w.destroy()
+ assert.throws((function () {
+ webContents.getId()
+ }), /Object has been destroyed/)
+ })
+ })
- describe('BrowserWindow.loadURL(url)', function() {
- it('should emit did-start-loading event', function(done) {
- w.webContents.on('did-start-loading', function() {
- done();
- });
- w.loadURL('about:blank');
- });
+ describe('BrowserWindow.loadURL(url)', function () {
+ it('should emit did-start-loading event', function (done) {
+ w.webContents.on('did-start-loading', function () {
+ done()
+ })
+ w.loadURL('about:blank')
+ })
- it('should emit did-fail-load event for files that do not exist', function(done) {
- w.webContents.on('did-fail-load', function(event, code) {
- assert.equal(code, -6);
- done();
- });
- w.loadURL('file://a.txt');
- });
+ it('should emit did-fail-load event for files that do not exist', function (done) {
+ w.webContents.on('did-fail-load', function (event, code) {
+ assert.equal(code, -6)
+ done()
+ })
+ w.loadURL('file://a.txt')
+ })
- it('should emit did-fail-load event for invalid URL', function(done) {
- w.webContents.on('did-fail-load', function(event, code, desc) {
- assert.equal(desc, 'ERR_INVALID_URL');
- assert.equal(code, -300);
- done();
- });
- w.loadURL('http://example:port');
- });
- });
+ it('should emit did-fail-load event for invalid URL', function (done) {
+ w.webContents.on('did-fail-load', function (event, code, desc) {
+ assert.equal(desc, 'ERR_INVALID_URL')
+ assert.equal(code, -300)
+ done()
+ })
+ w.loadURL('http://example:port')
+ })
+ })
- describe('BrowserWindow.show()', function() {
+ describe('BrowserWindow.show()', function () {
if (isCI) {
- return;
+ return
}
- it('should focus on window', function() {
- w.show();
- assert(w.isFocused());
- });
+ it('should focus on window', function () {
+ w.show()
+ assert(w.isFocused())
+ })
- it('should make the window visible', function() {
- w.show();
- assert(w.isVisible());
- });
+ it('should make the window visible', function () {
+ w.show()
+ assert(w.isVisible())
+ })
- it('emits when window is shown', function(done) {
- this.timeout(10000);
- w.once('show', function() {
- assert.equal(w.isVisible(), true);
- done();
- });
- w.show();
- });
- });
+ it('emits when window is shown', function (done) {
+ this.timeout(10000)
+ w.once('show', function () {
+ assert.equal(w.isVisible(), true)
+ done()
+ })
+ w.show()
+ })
+ })
- describe('BrowserWindow.hide()', function() {
+ describe('BrowserWindow.hide()', function () {
if (isCI) {
- return;
+ return
}
- it('should defocus on window', function() {
- w.hide();
- assert(!w.isFocused());
- });
+ it('should defocus on window', function () {
+ w.hide()
+ assert(!w.isFocused())
+ })
- it('should make the window not visible', function() {
- w.show();
- w.hide();
- assert(!w.isVisible());
- });
+ it('should make the window not visible', function () {
+ w.show()
+ w.hide()
+ assert(!w.isVisible())
+ })
- it('emits when window is hidden', function(done) {
- this.timeout(10000);
- w.show();
- w.once('hide', function() {
- assert.equal(w.isVisible(), false);
- done();
- });
- w.hide();
- });
- });
+ it('emits when window is hidden', function (done) {
+ this.timeout(10000)
+ w.show()
+ w.once('hide', function () {
+ assert.equal(w.isVisible(), false)
+ done()
+ })
+ w.hide()
+ })
+ })
- describe('BrowserWindow.showInactive()', function() {
- it('should not focus on window', function() {
- w.showInactive();
- assert(!w.isFocused());
- });
- });
+ describe('BrowserWindow.showInactive()', function () {
+ it('should not focus on window', function () {
+ w.showInactive()
+ assert(!w.isFocused())
+ })
+ })
- describe('BrowserWindow.focus()', function() {
- it('does not make the window become visible', function() {
- assert.equal(w.isVisible(), false);
- w.focus();
- assert.equal(w.isVisible(), false);
- });
- });
+ describe('BrowserWindow.focus()', function () {
+ it('does not make the window become visible', function () {
+ assert.equal(w.isVisible(), false)
+ w.focus()
+ assert.equal(w.isVisible(), false)
+ })
+ })
- describe('BrowserWindow.blur()', function() {
- it('removes focus from window', function() {
- w.blur();
- assert(!w.isFocused());
- });
- });
+ describe('BrowserWindow.blur()', function () {
+ it('removes focus from window', function () {
+ w.blur()
+ assert(!w.isFocused())
+ })
+ })
- describe('BrowserWindow.capturePage(rect, callback)', function() {
- it('calls the callback with a Buffer', function(done) {
+ describe('BrowserWindow.capturePage(rect, callback)', function () {
+ it('calls the callback with a Buffer', function (done) {
w.capturePage({
x: 0,
y: 0,
width: 100,
height: 100
- }, function(image) {
- assert.equal(image.isEmpty(), true);
- done();
- });
- });
- });
+ }, function (image) {
+ assert.equal(image.isEmpty(), true)
+ done()
+ })
+ })
+ })
- describe('BrowserWindow.setSize(width, height)', function() {
- it('sets the window size', function(done) {
- var size = [300, 400];
- w.once('resize', function() {
- var newSize = w.getSize();
- assert.equal(newSize[0], size[0]);
- assert.equal(newSize[1], size[1]);
- done();
- });
- w.setSize(size[0], size[1]);
- });
- });
+ describe('BrowserWindow.setSize(width, height)', function () {
+ it('sets the window size', function (done) {
+ var size = [300, 400]
+ w.once('resize', function () {
+ var newSize = w.getSize()
+ assert.equal(newSize[0], size[0])
+ assert.equal(newSize[1], size[1])
+ done()
+ })
+ w.setSize(size[0], size[1])
+ })
+ })
- describe('BrowserWindow.setPosition(x, y)', function() {
- it('sets the window position', function(done) {
- var pos = [10, 10];
- w.once('move', function() {
- var newPos = w.getPosition();
- assert.equal(newPos[0], pos[0]);
- assert.equal(newPos[1], pos[1]);
- done();
- });
- w.setPosition(pos[0], pos[1]);
- });
- });
+ describe('BrowserWindow.setPosition(x, y)', function () {
+ it('sets the window position', function (done) {
+ var pos = [10, 10]
+ w.once('move', function () {
+ var newPos = w.getPosition()
+ assert.equal(newPos[0], pos[0])
+ assert.equal(newPos[1], pos[1])
+ done()
+ })
+ w.setPosition(pos[0], pos[1])
+ })
+ })
- describe('BrowserWindow.setContentSize(width, height)', function() {
- it('sets the content size', function() {
- var size = [400, 400];
- w.setContentSize(size[0], size[1]);
- var after = w.getContentSize();
- assert.equal(after[0], size[0]);
- assert.equal(after[1], size[1]);
- });
+ describe('BrowserWindow.setContentSize(width, height)', function () {
+ it('sets the content size', function () {
+ var size = [400, 400]
+ w.setContentSize(size[0], size[1])
+ var after = w.getContentSize()
+ assert.equal(after[0], size[0])
+ assert.equal(after[1], size[1])
+ })
- it('works for framless window', function() {
- w.destroy();
+ it('works for framless window', function () {
+ w.destroy()
w = new BrowserWindow({
show: false,
frame: false,
width: 400,
height: 400
- });
- var size = [400, 400];
- w.setContentSize(size[0], size[1]);
- var after = w.getContentSize();
- assert.equal(after[0], size[0]);
- assert.equal(after[1], size[1]);
- });
- });
+ })
+ var size = [400, 400]
+ w.setContentSize(size[0], size[1])
+ var after = w.getContentSize()
+ assert.equal(after[0], size[0])
+ assert.equal(after[1], size[1])
+ })
+ })
- describe('BrowserWindow.fromId(id)', function() {
- it('returns the window with id', function() {
- assert.equal(w.id, BrowserWindow.fromId(w.id).id);
- });
- });
+ describe('BrowserWindow.fromId(id)', function () {
+ it('returns the window with id', function () {
+ assert.equal(w.id, BrowserWindow.fromId(w.id).id)
+ })
+ })
- describe('"useContentSize" option', function() {
- it('make window created with content size when used', function() {
- w.destroy();
+ describe('"useContentSize" option', function () {
+ it('make window created with content size when used', function () {
+ w.destroy()
w = new BrowserWindow({
show: false,
width: 400,
height: 400,
useContentSize: true
- });
- var contentSize = w.getContentSize();
- assert.equal(contentSize[0], 400);
- assert.equal(contentSize[1], 400);
- });
+ })
+ var contentSize = w.getContentSize()
+ assert.equal(contentSize[0], 400)
+ assert.equal(contentSize[1], 400)
+ })
- it('make window created with window size when not used', function() {
- var size = w.getSize();
- assert.equal(size[0], 400);
- assert.equal(size[1], 400);
- });
+ it('make window created with window size when not used', function () {
+ var size = w.getSize()
+ assert.equal(size[0], 400)
+ assert.equal(size[1], 400)
+ })
- it('works for framless window', function() {
- w.destroy();
+ it('works for framless window', function () {
+ w.destroy()
w = new BrowserWindow({
show: false,
frame: false,
width: 400,
height: 400,
useContentSize: true
- });
- var contentSize = w.getContentSize();
- assert.equal(contentSize[0], 400);
- assert.equal(contentSize[1], 400);
- var size = w.getSize();
- assert.equal(size[0], 400);
- assert.equal(size[1], 400);
- });
- });
+ })
+ var contentSize = w.getContentSize()
+ assert.equal(contentSize[0], 400)
+ assert.equal(contentSize[1], 400)
+ var size = w.getSize()
+ assert.equal(size[0], 400)
+ assert.equal(size[1], 400)
+ })
+ })
- describe('"title-bar-style" option', function() {
+ describe('"title-bar-style" option', function () {
if (process.platform !== 'darwin') {
- return;
+ return
}
if (parseInt(os.release().split('.')[0]) < 14) {
- return;
+ return
}
- it('creates browser window with hidden title bar', function() {
- w.destroy();
+ it('creates browser window with hidden title bar', function () {
+ w.destroy()
w = new BrowserWindow({
show: false,
width: 400,
height: 400,
titleBarStyle: 'hidden'
- });
- var contentSize = w.getContentSize();
- assert.equal(contentSize[1], 400);
- });
+ })
+ var contentSize = w.getContentSize()
+ assert.equal(contentSize[1], 400)
+ })
- it('creates browser window with hidden inset title bar', function() {
- w.destroy();
+ it('creates browser window with hidden inset title bar', function () {
+ w.destroy()
w = new BrowserWindow({
show: false,
width: 400,
height: 400,
titleBarStyle: 'hidden-inset'
- });
- var contentSize = w.getContentSize();
- assert.equal(contentSize[1], 400);
- });
- });
+ })
+ var contentSize = w.getContentSize()
+ assert.equal(contentSize[1], 400)
+ })
+ })
- describe('"enableLargerThanScreen" option', function() {
+ describe('"enableLargerThanScreen" option', function () {
if (process.platform === 'linux') {
- return;
+ return
}
- beforeEach(function() {
- w.destroy();
+ beforeEach(function () {
+ w.destroy()
w = new BrowserWindow({
show: true,
width: 400,
height: 400,
enableLargerThanScreen: true
- });
- });
+ })
+ })
- it('can move the window out of screen', function() {
- w.setPosition(-10, -10);
- var after = w.getPosition();
- assert.equal(after[0], -10);
- assert.equal(after[1], -10);
- });
+ it('can move the window out of screen', function () {
+ w.setPosition(-10, -10)
+ var after = w.getPosition()
+ assert.equal(after[0], -10)
+ assert.equal(after[1], -10)
+ })
- it('can set the window larger than screen', function() {
- var size = screen.getPrimaryDisplay().size;
- size.width += 100;
- size.height += 100;
- w.setSize(size.width, size.height);
- var after = w.getSize();
- assert.equal(after[0], size.width);
- assert.equal(after[1], size.height);
- });
- });
+ it('can set the window larger than screen', function () {
+ var size = screen.getPrimaryDisplay().size
+ size.width += 100
+ size.height += 100
+ w.setSize(size.width, size.height)
+ var after = w.getSize()
+ assert.equal(after[0], size.width)
+ assert.equal(after[1], size.height)
+ })
+ })
- describe('"web-preferences" option', function() {
- afterEach(function() {
- ipcMain.removeAllListeners('answer');
- });
+ describe('"web-preferences" option', function () {
+ afterEach(function () {
+ ipcMain.removeAllListeners('answer')
+ })
- describe('"preload" option', function() {
- it('loads the script before other scripts in window', function(done) {
- var preload = path.join(fixtures, 'module', 'set-global.js');
- ipcMain.once('answer', function(event, test) {
- assert.equal(test, 'preload');
- done();
- });
- w.destroy();
+ describe('"preload" option', function () {
+ it('loads the script before other scripts in window', function (done) {
+ var preload = path.join(fixtures, 'module', 'set-global.js')
+ ipcMain.once('answer', function (event, test) {
+ assert.equal(test, 'preload')
+ done()
+ })
+ w.destroy()
w = new BrowserWindow({
show: false,
webPreferences: {
preload: preload
}
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html'));
- });
- });
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'preload.html'))
+ })
+ })
- describe('"node-integration" option', function() {
- it('disables node integration when specified to false', function(done) {
- var preload = path.join(fixtures, 'module', 'send-later.js');
- ipcMain.once('answer', function(event, test) {
- assert.equal(test, 'undefined');
- done();
- });
- w.destroy();
+ describe('"node-integration" option', function () {
+ it('disables node integration when specified to false', function (done) {
+ var preload = path.join(fixtures, 'module', 'send-later.js')
+ ipcMain.once('answer', function (event, test) {
+ assert.equal(test, 'undefined')
+ done()
+ })
+ w.destroy()
w = new BrowserWindow({
show: false,
webPreferences: {
preload: preload,
nodeIntegration: false
}
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'blank.html'));
- });
- });
- });
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'blank.html'))
+ })
+ })
+ })
- describe('beforeunload handler', function() {
- it('returning true would not prevent close', function(done) {
- w.on('closed', function() {
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-true.html'));
- });
+ describe('beforeunload handler', function () {
+ it('returning true would not prevent close', function (done) {
+ w.on('closed', function () {
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-true.html'))
+ })
- it('returning non-empty string would not prevent close', function(done) {
- w.on('closed', function() {
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-string.html'));
- });
+ it('returning non-empty string would not prevent close', function (done) {
+ w.on('closed', function () {
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-string.html'))
+ })
- it('returning false would prevent close', function(done) {
- w.on('onbeforeunload', function() {
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'));
- });
+ it('returning false would prevent close', function (done) {
+ w.on('onbeforeunload', function () {
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html'))
+ })
- it('returning empty string would prevent close', function(done) {
- w.on('onbeforeunload', function() {
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html'));
- });
- });
+ it('returning empty string would prevent close', function (done) {
+ w.on('onbeforeunload', function () {
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html'))
+ })
+ })
- describe('new-window event', function() {
+ describe('new-window event', function () {
if (isCI && process.platform === 'darwin') {
- return;
+ return
}
- it('emits when window.open is called', function(done) {
- w.webContents.once('new-window', function(e, url, frameName) {
- e.preventDefault();
- assert.equal(url, 'http://host/');
- assert.equal(frameName, 'host');
- done();
- });
- w.loadURL("file://" + fixtures + "/pages/window-open.html");
- });
+ it('emits when window.open is called', function (done) {
+ w.webContents.once('new-window', function (e, url, frameName) {
+ e.preventDefault()
+ assert.equal(url, 'http://host/')
+ assert.equal(frameName, 'host')
+ done()
+ })
+ w.loadURL('file://' + fixtures + '/pages/window-open.html')
+ })
- it('emits when link with target is called', function(done) {
- this.timeout(10000);
- w.webContents.once('new-window', function(e, url, frameName) {
- e.preventDefault();
- assert.equal(url, 'http://host/');
- assert.equal(frameName, 'target');
- done();
- });
- w.loadURL("file://" + fixtures + "/pages/target-name.html");
- });
- });
+ it('emits when link with target is called', function (done) {
+ this.timeout(10000)
+ w.webContents.once('new-window', function (e, url, frameName) {
+ e.preventDefault()
+ assert.equal(url, 'http://host/')
+ assert.equal(frameName, 'target')
+ done()
+ })
+ w.loadURL('file://' + fixtures + '/pages/target-name.html')
+ })
+ })
- describe('maximize event', function() {
+ describe('maximize event', function () {
if (isCI) {
- return;
+ return
}
- it('emits when window is maximized', function(done) {
- this.timeout(10000);
- w.once('maximize', function() {
- done();
- });
- w.show();
- w.maximize();
- });
- });
+ it('emits when window is maximized', function (done) {
+ this.timeout(10000)
+ w.once('maximize', function () {
+ done()
+ })
+ w.show()
+ w.maximize()
+ })
+ })
- describe('unmaximize event', function() {
+ describe('unmaximize event', function () {
if (isCI) {
- return;
+ return
}
- it('emits when window is unmaximized', function(done) {
- this.timeout(10000);
- w.once('unmaximize', function() {
- done();
- });
- w.show();
- w.maximize();
- w.unmaximize();
- });
- });
+ it('emits when window is unmaximized', function (done) {
+ this.timeout(10000)
+ w.once('unmaximize', function () {
+ done()
+ })
+ w.show()
+ w.maximize()
+ w.unmaximize()
+ })
+ })
- describe('minimize event', function() {
+ describe('minimize event', function () {
if (isCI) {
- return;
+ return
}
- it('emits when window is minimized', function(done) {
- this.timeout(10000);
- w.once('minimize', function() {
- done();
- });
- w.show();
- w.minimize();
- });
- });
+ it('emits when window is minimized', function (done) {
+ this.timeout(10000)
+ w.once('minimize', function () {
+ done()
+ })
+ w.show()
+ w.minimize()
+ })
+ })
- describe('beginFrameSubscription method', function() {
- this.timeout(20000);
+ describe('beginFrameSubscription method', function () {
+ this.timeout(20000)
- it('subscribes frame updates', function(done) {
- let called = false;
- w.loadURL("file://" + fixtures + "/api/blank.html");
- w.webContents.beginFrameSubscription(function(data) {
+ it('subscribes frame updates', function (done) {
+ let called = false
+ w.loadURL('file://' + fixtures + '/api/blank.html')
+ w.webContents.beginFrameSubscription(function (data) {
// This callback might be called twice.
if (called)
- return;
- called = true;
+ return
+ called = true
- assert.notEqual(data.length, 0);
- w.webContents.endFrameSubscription();
- done();
- });
- });
- });
+ assert.notEqual(data.length, 0)
+ w.webContents.endFrameSubscription()
+ done()
+ })
+ })
+ })
- describe('savePage method', function() {
- const savePageDir = path.join(fixtures, 'save_page');
- const savePageHtmlPath = path.join(savePageDir, 'save_page.html');
- const savePageJsPath = path.join(savePageDir, 'save_page_files', 'test.js');
- const savePageCssPath = path.join(savePageDir, 'save_page_files', 'test.css');
+ describe('savePage method', function () {
+ const savePageDir = path.join(fixtures, 'save_page')
+ const savePageHtmlPath = path.join(savePageDir, 'save_page.html')
+ const savePageJsPath = path.join(savePageDir, 'save_page_files', 'test.js')
+ const savePageCssPath = path.join(savePageDir, 'save_page_files', 'test.css')
- after(function() {
+ after(function () {
try {
- fs.unlinkSync(savePageCssPath);
- fs.unlinkSync(savePageJsPath);
- fs.unlinkSync(savePageHtmlPath);
- fs.rmdirSync(path.join(savePageDir, 'save_page_files'));
- fs.rmdirSync(savePageDir);
+ fs.unlinkSync(savePageCssPath)
+ fs.unlinkSync(savePageJsPath)
+ fs.unlinkSync(savePageHtmlPath)
+ fs.rmdirSync(path.join(savePageDir, 'save_page_files'))
+ fs.rmdirSync(savePageDir)
} catch (e) {
// Ignore error
}
- });
+ })
- it('should save page to disk', function(done) {
- w.webContents.on('did-finish-load', function() {
- w.webContents.savePage(savePageHtmlPath, 'HTMLComplete', function(error) {
- assert.equal(error, null);
- assert(fs.existsSync(savePageHtmlPath));
- assert(fs.existsSync(savePageJsPath));
- assert(fs.existsSync(savePageCssPath));
- done();
- });
- });
- w.loadURL("file://" + fixtures + "/pages/save_page/index.html");
- });
- });
+ it('should save page to disk', function (done) {
+ w.webContents.on('did-finish-load', function () {
+ w.webContents.savePage(savePageHtmlPath, 'HTMLComplete', function (error) {
+ assert.equal(error, null)
+ assert(fs.existsSync(savePageHtmlPath))
+ assert(fs.existsSync(savePageJsPath))
+ assert(fs.existsSync(savePageCssPath))
+ done()
+ })
+ })
+ w.loadURL('file://' + fixtures + '/pages/save_page/index.html')
+ })
+ })
- describe('BrowserWindow options argument is optional', function() {
- it('should create a window with default size (800x600)', function() {
- w.destroy();
- w = new BrowserWindow();
- var size = w.getSize();
- assert.equal(size[0], 800);
- assert.equal(size[1], 600);
- });
- });
+ describe('BrowserWindow options argument is optional', function () {
+ it('should create a window with default size (800x600)', function () {
+ w.destroy()
+ w = new BrowserWindow()
+ var size = w.getSize()
+ assert.equal(size[0], 800)
+ assert.equal(size[1], 600)
+ })
+ })
- describe('window states', function() {
- describe('resizable state', function() {
- it('can be changed with resizable option', function() {
- w.destroy();
- w = new BrowserWindow({show: false, resizable: false});
- assert.equal(w.isResizable(), false);
- });
+ describe('window states', function () {
+ describe('resizable state', function () {
+ it('can be changed with resizable option', function () {
+ w.destroy()
+ w = new BrowserWindow({show: false, resizable: false})
+ assert.equal(w.isResizable(), false)
+ })
- it('can be changed with setResizable method', function() {
- assert.equal(w.isResizable(), true);
- w.setResizable(false);
- assert.equal(w.isResizable(), false);
- w.setResizable(true);
- assert.equal(w.isResizable(), true);
- });
- });
- });
+ it('can be changed with setResizable method', function () {
+ assert.equal(w.isResizable(), true)
+ w.setResizable(false)
+ assert.equal(w.isResizable(), false)
+ w.setResizable(true)
+ assert.equal(w.isResizable(), true)
+ })
+ })
+ })
- describe('window states (excluding Linux)', function() {
+ describe('window states (excluding Linux)', function () {
// Not implemented on Linux.
if (process.platform == 'linux')
- return;
+ return
- describe('movable state', function() {
- it('can be changed with movable option', function() {
- w.destroy();
- w = new BrowserWindow({show: false, movable: false});
- assert.equal(w.isMovable(), false);
- });
+ describe('movable state', function () {
+ it('can be changed with movable option', function () {
+ w.destroy()
+ w = new BrowserWindow({show: false, movable: false})
+ assert.equal(w.isMovable(), false)
+ })
- it('can be changed with setMovable method', function() {
- assert.equal(w.isMovable(), true);
- w.setMovable(false);
- assert.equal(w.isMovable(), false);
- w.setMovable(true);
- assert.equal(w.isMovable(), true);
- });
- });
+ it('can be changed with setMovable method', function () {
+ assert.equal(w.isMovable(), true)
+ w.setMovable(false)
+ assert.equal(w.isMovable(), false)
+ w.setMovable(true)
+ assert.equal(w.isMovable(), true)
+ })
+ })
- describe('minimizable state', function() {
- it('can be changed with minimizable option', function() {
- w.destroy();
- w = new BrowserWindow({show: false, minimizable: false});
- assert.equal(w.isMinimizable(), false);
- });
+ describe('minimizable state', function () {
+ it('can be changed with minimizable option', function () {
+ w.destroy()
+ w = new BrowserWindow({show: false, minimizable: false})
+ assert.equal(w.isMinimizable(), false)
+ })
- it('can be changed with setMinimizable method', function() {
- assert.equal(w.isMinimizable(), true);
- w.setMinimizable(false);
- assert.equal(w.isMinimizable(), false);
- w.setMinimizable(true);
- assert.equal(w.isMinimizable(), true);
- });
- });
+ it('can be changed with setMinimizable method', function () {
+ assert.equal(w.isMinimizable(), true)
+ w.setMinimizable(false)
+ assert.equal(w.isMinimizable(), false)
+ w.setMinimizable(true)
+ assert.equal(w.isMinimizable(), true)
+ })
+ })
- describe('maximizable state', function() {
- it('can be changed with maximizable option', function() {
- w.destroy();
- w = new BrowserWindow({show: false, maximizable: false});
- assert.equal(w.isMaximizable(), false);
- });
+ describe('maximizable state', function () {
+ it('can be changed with maximizable option', function () {
+ w.destroy()
+ w = new BrowserWindow({show: false, maximizable: false})
+ assert.equal(w.isMaximizable(), false)
+ })
- it('can be changed with setMaximizable method', function() {
- assert.equal(w.isMaximizable(), true);
- w.setMaximizable(false);
- assert.equal(w.isMaximizable(), false);
- w.setMaximizable(true);
- assert.equal(w.isMaximizable(), true);
- });
+ it('can be changed with setMaximizable method', function () {
+ assert.equal(w.isMaximizable(), true)
+ w.setMaximizable(false)
+ assert.equal(w.isMaximizable(), false)
+ w.setMaximizable(true)
+ assert.equal(w.isMaximizable(), true)
+ })
- it('is not affected when changing other states', function() {
- w.setMaximizable(false);
- assert.equal(w.isMaximizable(), false);
- w.setMinimizable(false);
- assert.equal(w.isMaximizable(), false);
- w.setClosable(false);
- assert.equal(w.isMaximizable(), false);
- });
- });
+ it('is not affected when changing other states', function () {
+ w.setMaximizable(false)
+ assert.equal(w.isMaximizable(), false)
+ w.setMinimizable(false)
+ assert.equal(w.isMaximizable(), false)
+ w.setClosable(false)
+ assert.equal(w.isMaximizable(), false)
+ })
+ })
- describe('fullscreenable state', function() {
+ describe('fullscreenable state', function () {
// Only implemented on OS X.
if (process.platform != 'darwin')
- return;
+ return
- it('can be changed with fullscreenable option', function() {
- w.destroy();
- w = new BrowserWindow({show: false, fullscreenable: false});
- assert.equal(w.isFullScreenable(), false);
- });
+ it('can be changed with fullscreenable option', function () {
+ w.destroy()
+ w = new BrowserWindow({show: false, fullscreenable: false})
+ assert.equal(w.isFullScreenable(), false)
+ })
- it('can be changed with setFullScreenable method', function() {
- assert.equal(w.isFullScreenable(), true);
- w.setFullScreenable(false);
- assert.equal(w.isFullScreenable(), false);
- w.setFullScreenable(true);
- assert.equal(w.isFullScreenable(), true);
- });
- });
+ it('can be changed with setFullScreenable method', function () {
+ assert.equal(w.isFullScreenable(), true)
+ w.setFullScreenable(false)
+ assert.equal(w.isFullScreenable(), false)
+ w.setFullScreenable(true)
+ assert.equal(w.isFullScreenable(), true)
+ })
+ })
- describe('closable state', function() {
- it('can be changed with closable option', function() {
- w.destroy();
- w = new BrowserWindow({show: false, closable: false});
- assert.equal(w.isClosable(), false);
- });
+ describe('closable state', function () {
+ it('can be changed with closable option', function () {
+ w.destroy()
+ w = new BrowserWindow({show: false, closable: false})
+ assert.equal(w.isClosable(), false)
+ })
- it('can be changed with setClosable method', function() {
- assert.equal(w.isClosable(), true);
- w.setClosable(false);
- assert.equal(w.isClosable(), false);
- w.setClosable(true);
- assert.equal(w.isClosable(), true);
- });
- });
+ it('can be changed with setClosable method', function () {
+ assert.equal(w.isClosable(), true)
+ w.setClosable(false)
+ assert.equal(w.isClosable(), false)
+ w.setClosable(true)
+ assert.equal(w.isClosable(), true)
+ })
+ })
- describe('hasShadow state', function() {
+ describe('hasShadow state', function () {
// On Window there is no shadow by default and it can not be changed
// dynamically.
- it('can be changed with hasShadow option', function() {
- w.destroy();
- let hasShadow = process.platform == 'darwin' ? false : true;
- w = new BrowserWindow({show: false, hasShadow: hasShadow});
- assert.equal(w.hasShadow(), hasShadow);
- });
+ it('can be changed with hasShadow option', function () {
+ w.destroy()
+ let hasShadow = process.platform == 'darwin' ? false : true
+ w = new BrowserWindow({show: false, hasShadow: hasShadow})
+ assert.equal(w.hasShadow(), hasShadow)
+ })
- it('can be changed with setHasShadow method', function() {
+ it('can be changed with setHasShadow method', function () {
if (process.platform != 'darwin')
- return;
+ return
- assert.equal(w.hasShadow(), true);
- w.setHasShadow(false);
- assert.equal(w.hasShadow(), false);
- w.setHasShadow(true);
- assert.equal(w.hasShadow(), true);
- });
- });
- });
+ assert.equal(w.hasShadow(), true)
+ w.setHasShadow(false)
+ assert.equal(w.hasShadow(), false)
+ w.setHasShadow(true)
+ assert.equal(w.hasShadow(), true)
+ })
+ })
+ })
- describe('window.webContents.send(channel, args...)', function() {
- it('throws an error when the channel is missing', function() {
- assert.throws(function() {
- w.webContents.send();
- }, 'Missing required channel argument');
+ describe('window.webContents.send(channel, args...)', function () {
+ it('throws an error when the channel is missing', function () {
+ assert.throws(function () {
+ w.webContents.send()
+ }, 'Missing required channel argument')
- assert.throws(function() {
- w.webContents.send(null);
- }, 'Missing required channel argument');
- });
- });
+ assert.throws(function () {
+ w.webContents.send(null)
+ }, 'Missing required channel argument')
+ })
+ })
describe('dev tool extensions', function () {
it('serializes the registered extensions on quit', function () {
- var extensionName = 'foo';
- var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName);
- var serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions');
+ var extensionName = 'foo'
+ var extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName)
+ var serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions')
- BrowserWindow.addDevToolsExtension(extensionPath);
- app.emit('will-quit');
- assert.deepEqual(JSON.parse(fs.readFileSync(serializedPath)), [extensionPath]);
+ BrowserWindow.addDevToolsExtension(extensionPath)
+ app.emit('will-quit')
+ assert.deepEqual(JSON.parse(fs.readFileSync(serializedPath)), [extensionPath])
- BrowserWindow.removeDevToolsExtension(extensionName);
- app.emit('will-quit');
- assert.equal(fs.existsSync(serializedPath), false);
- });
- });
+ BrowserWindow.removeDevToolsExtension(extensionName)
+ app.emit('will-quit')
+ assert.equal(fs.existsSync(serializedPath), false)
+ })
+ })
- describe('window.webContents.executeJavaScript', function() {
- var expected = 'hello, world!';
- var code = '(() => \"' + expected + '\")()';
+ describe('window.webContents.executeJavaScript', function () {
+ var expected = 'hello, world!'
+ var code = '(() => "' + expected + '")()'
- it('doesnt throw when no calback is provided', function() {
- const result = ipcRenderer.sendSync('executeJavaScript', code, false);
- assert.equal(result, 'success');
- });
+ it('doesnt throw when no calback is provided', function () {
+ const result = ipcRenderer.sendSync('executeJavaScript', code, false)
+ assert.equal(result, 'success')
+ })
- it('returns result when calback is provided', function(done) {
- ipcRenderer.send('executeJavaScript', code, true);
- ipcRenderer.once('executeJavaScript-response', function(event, result) {
- assert.equal(result, expected);
- done();
- });
- });
- });
+ it('returns result when calback is provided', function (done) {
+ ipcRenderer.send('executeJavaScript', code, true)
+ ipcRenderer.once('executeJavaScript-response', function (event, result) {
+ assert.equal(result, expected)
+ done()
+ })
+ })
+ })
- describe('deprecated options', function() {
- it('throws a deprecation error for option keys using hyphens instead of camel case', function() {
+ describe('deprecated options', function () {
+ it('throws a deprecation error for option keys using hyphens instead of camel case', function () {
assert.throws(function () {
- new BrowserWindow({'min-width': 500});
- }, 'min-width is deprecated. Use minWidth instead.');
- });
+ new BrowserWindow({'min-width': 500})
+ }, 'min-width is deprecated. Use minWidth instead.')
+ })
- it('throws a deprecation error for webPreference keys using hyphens instead of camel case', function() {
+ it('throws a deprecation error for webPreference keys using hyphens instead of camel case', function () {
assert.throws(function () {
- new BrowserWindow({webPreferences: {'node-integration': false}});
- }, 'node-integration is deprecated. Use nodeIntegration instead.');
- });
+ new BrowserWindow({webPreferences: {'node-integration': false}})
+ }, 'node-integration is deprecated. Use nodeIntegration instead.')
+ })
- it('throws a deprecation error for option keys that should be set on webPreferences', function() {
+ it('throws a deprecation error for option keys that should be set on webPreferences', function () {
assert.throws(function () {
- new BrowserWindow({zoomFactor: 1});
- }, 'options.zoomFactor is deprecated. Use options.webPreferences.zoomFactor instead.');
- });
- });
-});
+ new BrowserWindow({zoomFactor: 1})
+ }, 'options.zoomFactor is deprecated. Use options.webPreferences.zoomFactor instead.')
+ })
+ })
+})
diff --git a/spec/api-clipboard-spec.js b/spec/api-clipboard-spec.js
index 0b4a9f9521cf..63f1d907e8a9 100644
--- a/spec/api-clipboard-spec.js
+++ b/spec/api-clipboard-spec.js
@@ -1,63 +1,63 @@
-const assert = require('assert');
-const path = require('path');
+const assert = require('assert')
+const path = require('path')
-const clipboard = require('electron').clipboard;
-const nativeImage = require('electron').nativeImage;
+const clipboard = require('electron').clipboard
+const nativeImage = require('electron').nativeImage
-describe('clipboard module', function() {
- var fixtures = path.resolve(__dirname, 'fixtures');
+describe('clipboard module', function () {
+ var fixtures = path.resolve(__dirname, 'fixtures')
- describe('clipboard.readImage()', function() {
- it('returns NativeImage intance', function() {
- var p = path.join(fixtures, 'assets', 'logo.png');
- var i = nativeImage.createFromPath(p);
- clipboard.writeImage(p);
- assert.equal(clipboard.readImage().toDataURL(), i.toDataURL());
- });
- });
+ describe('clipboard.readImage()', function () {
+ it('returns NativeImage intance', function () {
+ var p = path.join(fixtures, 'assets', 'logo.png')
+ var i = nativeImage.createFromPath(p)
+ clipboard.writeImage(p)
+ assert.equal(clipboard.readImage().toDataURL(), i.toDataURL())
+ })
+ })
- describe('clipboard.readText()', function() {
- it('returns unicode string correctly', function() {
- var text = '千江有水千江月,万里无云万里天';
- clipboard.writeText(text);
- assert.equal(clipboard.readText(), text);
- });
- });
+ describe('clipboard.readText()', function () {
+ it('returns unicode string correctly', function () {
+ var text = '千江有水千江月,万里无云万里天'
+ clipboard.writeText(text)
+ assert.equal(clipboard.readText(), text)
+ })
+ })
- describe('clipboard.readHtml()', function() {
- it('returns markup correctly', function() {
- var text = 'Hi';
- var markup = process.platform === 'darwin' ? 'Hi' : process.platform === 'linux' ? 'Hi' : 'Hi';
- clipboard.writeHtml(text);
- assert.equal(clipboard.readHtml(), markup);
- });
- });
+ describe('clipboard.readHtml()', function () {
+ it('returns markup correctly', function () {
+ var text = 'Hi'
+ var markup = process.platform === 'darwin' ? "Hi" : process.platform === 'linux' ? 'Hi' : 'Hi'
+ clipboard.writeHtml(text)
+ assert.equal(clipboard.readHtml(), markup)
+ })
+ })
- describe('clipboard.readRtf', function() {
- it('returns rtf text correctly', function() {
- var rtf = "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}";
- clipboard.writeRtf(rtf);
- assert.equal(clipboard.readRtf(), rtf);
- });
- });
+ describe('clipboard.readRtf', function () {
+ it('returns rtf text correctly', function () {
+ var rtf = '{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\nThis is some {\\b bold} text.\\par\n}'
+ clipboard.writeRtf(rtf)
+ assert.equal(clipboard.readRtf(), rtf)
+ })
+ })
- describe('clipboard.write()', function() {
- it('returns data correctly', function() {
- var text = 'test';
- var rtf = '{\\rtf1\\utf8 text}';
- var p = path.join(fixtures, 'assets', 'logo.png');
- var i = nativeImage.createFromPath(p);
- var markup = process.platform === 'darwin' ? 'Hi' : process.platform === 'linux' ? 'Hi' : 'Hi';
+ describe('clipboard.write()', function () {
+ it('returns data correctly', function () {
+ var text = 'test'
+ var rtf = '{\\rtf1\\utf8 text}'
+ var p = path.join(fixtures, 'assets', 'logo.png')
+ var i = nativeImage.createFromPath(p)
+ var markup = process.platform === 'darwin' ? "Hi" : process.platform === 'linux' ? 'Hi' : 'Hi'
clipboard.write({
- text: "test",
+ text: 'test',
html: 'Hi',
rtf: '{\\rtf1\\utf8 text}',
image: p
- });
- assert.equal(clipboard.readText(), text);
- assert.equal(clipboard.readHtml(), markup);
- assert.equal(clipboard.readRtf(), rtf);
- assert.equal(clipboard.readImage().toDataURL(), i.toDataURL());
- });
- });
-});
+ })
+ assert.equal(clipboard.readText(), text)
+ assert.equal(clipboard.readHtml(), markup)
+ assert.equal(clipboard.readRtf(), rtf)
+ assert.equal(clipboard.readImage().toDataURL(), i.toDataURL())
+ })
+ })
+})
diff --git a/spec/api-crash-reporter-spec.js b/spec/api-crash-reporter-spec.js
index 68dc1375fc39..708daeab956f 100644
--- a/spec/api-crash-reporter-spec.js
+++ b/spec/api-crash-reporter-spec.js
@@ -1,93 +1,93 @@
-const assert = require('assert');
-const http = require('http');
-const multiparty = require('multiparty');
-const path = require('path');
-const url = require('url');
+const assert = require('assert')
+const http = require('http')
+const multiparty = require('multiparty')
+const path = require('path')
+const url = require('url')
-const remote = require('electron').remote;
-const app = remote.require('electron').app;
-const crashReporter = remote.require('electron').crashReporter;
-const BrowserWindow = remote.require('electron').BrowserWindow;
+const remote = require('electron').remote
+const app = remote.require('electron').app
+const crashReporter = remote.require('electron').crashReporter
+const BrowserWindow = remote.require('electron').BrowserWindow
-describe('crash-reporter module', function() {
- var fixtures = path.resolve(__dirname, 'fixtures');
- var w = null;
+describe('crash-reporter module', function () {
+ var fixtures = path.resolve(__dirname, 'fixtures')
+ var w = null
- beforeEach(function() {
+ beforeEach(function () {
w = new BrowserWindow({
show: false
- });
- });
+ })
+ })
- afterEach(function() {
- w.destroy();
- });
+ afterEach(function () {
+ w.destroy()
+ })
if (process.mas) {
- return;
+ return
}
- var isCI = remote.getGlobal('isCi');
+ var isCI = remote.getGlobal('isCi')
if (isCI) {
- return;
+ return
}
- it('should send minidump when renderer crashes', function(done) {
- this.timeout(120000);
+ it('should send minidump when renderer crashes', function (done) {
+ this.timeout(120000)
- var called = false;
- var server = http.createServer(function(req, res) {
- server.close();
- var form = new multiparty.Form();
- form.parse(req, function(error, fields) {
+ var called = false
+ var server = http.createServer(function (req, res) {
+ server.close()
+ var form = new multiparty.Form()
+ form.parse(req, function (error, fields) {
if (called) {
- return;
+ return
}
- called = true;
- assert.equal(fields['prod'], 'Electron');
- assert.equal(fields['ver'], process.versions['electron']);
- assert.equal(fields['process_type'], 'renderer');
- assert.equal(fields['platform'], process.platform);
- assert.equal(fields['extra1'], 'extra1');
- assert.equal(fields['extra2'], 'extra2');
- assert.equal(fields['_productName'], 'Zombies');
- assert.equal(fields['_companyName'], 'Umbrella Corporation');
- assert.equal(fields['_version'], app.getVersion());
- res.end('abc-123-def');
- done();
- });
- });
- var port = remote.process.port;
- server.listen(port, '127.0.0.1', function() {
- port = server.address().port;
- remote.process.port = port;
+ called = true
+ assert.equal(fields['prod'], 'Electron')
+ assert.equal(fields['ver'], process.versions['electron'])
+ assert.equal(fields['process_type'], 'renderer')
+ assert.equal(fields['platform'], process.platform)
+ assert.equal(fields['extra1'], 'extra1')
+ assert.equal(fields['extra2'], 'extra2')
+ assert.equal(fields['_productName'], 'Zombies')
+ assert.equal(fields['_companyName'], 'Umbrella Corporation')
+ assert.equal(fields['_version'], app.getVersion())
+ res.end('abc-123-def')
+ done()
+ })
+ })
+ var port = remote.process.port
+ server.listen(port, '127.0.0.1', function () {
+ port = server.address().port
+ remote.process.port = port
const crashUrl = url.format({
protocol: 'file',
pathname: path.join(fixtures, 'api', 'crash.html'),
- search: "?port=" + port
- });
+ search: '?port=' + port
+ })
if (process.platform === 'darwin') {
crashReporter.start({
companyName: 'Umbrella Corporation',
- submitURL: "http://127.0.0.1:" + port
- });
+ submitURL: 'http://127.0.0.1:' + port
+ })
}
- w.loadURL(crashUrl);
- });
- });
+ w.loadURL(crashUrl)
+ })
+ })
- describe(".start(options)", function() {
- it('requires that the companyName and submitURL options be specified', function() {
- assert.throws(function() {
+ describe('.start(options)', function () {
+ it('requires that the companyName and submitURL options be specified', function () {
+ assert.throws(function () {
crashReporter.start({
companyName: 'Missing submitURL'
- });
- });
- assert.throws(function() {
+ })
+ })
+ assert.throws(function () {
crashReporter.start({
submitURL: 'Missing companyName'
- });
- });
- });
- });
-});
+ })
+ })
+ })
+ })
+})
diff --git a/spec/api-debugger-spec.js b/spec/api-debugger-spec.js
index 56b642e76e43..1648ac1c3cd8 100644
--- a/spec/api-debugger-spec.js
+++ b/spec/api-debugger-spec.js
@@ -1,133 +1,133 @@
-const assert = require('assert');
-const path = require('path');
-const BrowserWindow = require('electron').remote.BrowserWindow;
+const assert = require('assert')
+const path = require('path')
+const BrowserWindow = require('electron').remote.BrowserWindow
-describe('debugger module', function() {
- var fixtures = path.resolve(__dirname, 'fixtures');
- var w = null;
+describe('debugger module', function () {
+ var fixtures = path.resolve(__dirname, 'fixtures')
+ var w = null
- beforeEach(function() {
+ beforeEach(function () {
if (w != null) {
- w.destroy();
+ w.destroy()
}
w = new BrowserWindow({
show: false,
width: 400,
height: 400
- });
- });
+ })
+ })
- afterEach(function() {
+ afterEach(function () {
if (w != null) {
- w.destroy();
+ w.destroy()
}
- w = null;
- });
+ w = null
+ })
- describe('debugger.attach', function() {
- it('fails when devtools is already open', function(done) {
- w.webContents.on('did-finish-load', function() {
- w.webContents.openDevTools();
+ describe('debugger.attach', function () {
+ it('fails when devtools is already open', function (done) {
+ w.webContents.on('did-finish-load', function () {
+ w.webContents.openDevTools()
try {
- w.webContents.debugger.attach();
+ w.webContents.debugger.attach()
} catch(err) {
- assert(w.webContents.debugger.isAttached());
- done();
+ assert(w.webContents.debugger.isAttached())
+ done()
}
- });
- w.webContents.loadURL('file://' + path.join(fixtures, 'pages', 'a.html'));
- });
+ })
+ w.webContents.loadURL('file://' + path.join(fixtures, 'pages', 'a.html'))
+ })
- it('fails when protocol version is not supported', function(done) {
+ it('fails when protocol version is not supported', function (done) {
try {
- w.webContents.debugger.attach("2.0");
+ w.webContents.debugger.attach('2.0')
} catch(err) {
- assert(!w.webContents.debugger.isAttached());
- done();
+ assert(!w.webContents.debugger.isAttached())
+ done()
}
- });
+ })
- it('attaches when no protocol version is specified', function(done) {
+ it('attaches when no protocol version is specified', function (done) {
try {
- w.webContents.debugger.attach();
+ w.webContents.debugger.attach()
} catch(err) {
- done('unexpected error : ' + err);
+ done('unexpected error : ' + err)
}
- assert(w.webContents.debugger.isAttached());
- done();
- });
- });
+ assert(w.webContents.debugger.isAttached())
+ done()
+ })
+ })
- describe('debugger.detach', function() {
- it('fires detach event', function(done) {
- w.webContents.debugger.on('detach', function(e, reason) {
- assert.equal(reason, 'target closed');
- assert(!w.webContents.debugger.isAttached());
- done();
- });
+ describe('debugger.detach', function () {
+ it('fires detach event', function (done) {
+ w.webContents.debugger.on('detach', function (e, reason) {
+ assert.equal(reason, 'target closed')
+ assert(!w.webContents.debugger.isAttached())
+ done()
+ })
try {
- w.webContents.debugger.attach();
+ w.webContents.debugger.attach()
} catch(err) {
- done('unexpected error : ' + err);
+ done('unexpected error : ' + err)
}
- w.webContents.debugger.detach();
- });
- });
+ w.webContents.debugger.detach()
+ })
+ })
- describe('debugger.sendCommand', function() {
- it('retuns response', function(done) {
- w.webContents.loadURL('about:blank');
+ describe('debugger.sendCommand', function () {
+ it('retuns response', function (done) {
+ w.webContents.loadURL('about:blank')
try {
- w.webContents.debugger.attach();
+ w.webContents.debugger.attach()
} catch(err) {
- done('unexpected error : ' + err);
+ done('unexpected error : ' + err)
+ }
+ var callback = function (err, res) {
+ assert(!res.wasThrown)
+ assert.equal(res.result.value, 6)
+ w.webContents.debugger.detach()
+ done()
}
- var callback = function(err, res) {
- assert(!res.wasThrown);
- assert.equal(res.result.value, 6);
- w.webContents.debugger.detach();
- done();
- };
const params = {
- "expression": "4+2",
- };
- w.webContents.debugger.sendCommand("Runtime.evaluate", params, callback);
- });
+ 'expression': '4+2',
+ }
+ w.webContents.debugger.sendCommand('Runtime.evaluate', params, callback)
+ })
- it('fires message event', function(done) {
+ it('fires message event', function (done) {
var url = process.platform != 'win32' ?
'file://' + path.join(fixtures, 'pages', 'a.html') :
- 'file:///' + path.join(fixtures, 'pages', 'a.html').replace(/\\/g, '/');
- w.webContents.loadURL(url);
+ 'file:///' + path.join(fixtures, 'pages', 'a.html').replace(/\\/g, '/')
+ w.webContents.loadURL(url)
try {
- w.webContents.debugger.attach();
+ w.webContents.debugger.attach()
} catch(err) {
- done('unexpected error : ' + err);
+ done('unexpected error : ' + err)
}
- w.webContents.debugger.on('message', function(e, method, params) {
- if(method == "Console.messageAdded") {
- assert.equal(params.message.type, 'log');
- assert.equal(params.message.url, url);
- assert.equal(params.message.text, 'a');
- w.webContents.debugger.detach();
- done();
+ w.webContents.debugger.on('message', function (e, method, params) {
+ if (method == 'Console.messageAdded') {
+ assert.equal(params.message.type, 'log')
+ assert.equal(params.message.url, url)
+ assert.equal(params.message.text, 'a')
+ w.webContents.debugger.detach()
+ done()
}
- });
- w.webContents.debugger.sendCommand("Console.enable");
- });
+ })
+ w.webContents.debugger.sendCommand('Console.enable')
+ })
- it('returns error message when command fails', function(done) {
- w.webContents.loadURL('about:blank');
+ it('returns error message when command fails', function (done) {
+ w.webContents.loadURL('about:blank')
try {
- w.webContents.debugger.attach();
+ w.webContents.debugger.attach()
} catch(err) {
- done('unexpected error : ' + err);
+ done('unexpected error : ' + err)
}
- w.webContents.debugger.sendCommand("Test", function(err) {
- assert.equal(err.message, '\'Test\' wasn\'t found');
- w.webContents.debugger.detach();
- done();
- });
- });
- });
-});
+ w.webContents.debugger.sendCommand('Test', function (err) {
+ assert.equal(err.message, "'Test' wasn't found")
+ w.webContents.debugger.detach()
+ done()
+ })
+ })
+ })
+})
diff --git a/spec/api-deprecations-spec.js b/spec/api-deprecations-spec.js
index 2f0100590598..375de5895fee 100644
--- a/spec/api-deprecations-spec.js
+++ b/spec/api-deprecations-spec.js
@@ -1,27 +1,27 @@
-const assert = require('assert');
-const deprecations = require('electron').deprecations;
+const assert = require('assert')
+const deprecations = require('electron').deprecations
-describe('deprecations', function() {
- beforeEach(function() {
- deprecations.setHandler(null);
- process.throwDeprecation = true;
- });
+describe('deprecations', function () {
+ beforeEach(function () {
+ deprecations.setHandler(null)
+ process.throwDeprecation = true
+ })
- it('allows a deprecation handler function to be specified', function() {
- var messages = [];
+ it('allows a deprecation handler function to be specified', function () {
+ var messages = []
deprecations.setHandler(function (message) {
- messages.push(message);
- });
+ messages.push(message)
+ })
- require('electron').webFrame.registerUrlSchemeAsSecure('some-scheme');
+ require('electron').webFrame.registerUrlSchemeAsSecure('some-scheme')
- assert.deepEqual(messages, ['registerUrlSchemeAsSecure is deprecated. Use registerURLSchemeAsSecure instead.']);
- });
+ assert.deepEqual(messages, ['registerUrlSchemeAsSecure is deprecated. Use registerURLSchemeAsSecure instead.'])
+ })
- it('throws an exception if no deprecation handler is specified', function() {
- assert.throws(function() {
- require('electron').webFrame.registerUrlSchemeAsPrivileged('some-scheme');
- }, "registerUrlSchemeAsPrivileged is deprecated. Use registerURLSchemeAsPrivileged instead.");
- });
-});
+ it('throws an exception if no deprecation handler is specified', function () {
+ assert.throws(function () {
+ require('electron').webFrame.registerUrlSchemeAsPrivileged('some-scheme')
+ }, 'registerUrlSchemeAsPrivileged is deprecated. Use registerURLSchemeAsPrivileged instead.')
+ })
+})
diff --git a/spec/api-desktop-capturer-spec.js b/spec/api-desktop-capturer-spec.js
index 02eda9003b89..9e85a48fbcc5 100644
--- a/spec/api-desktop-capturer-spec.js
+++ b/spec/api-desktop-capturer-spec.js
@@ -1,27 +1,27 @@
-const assert = require('assert');
-const desktopCapturer = require('electron').desktopCapturer;
+const assert = require('assert')
+const desktopCapturer = require('electron').desktopCapturer
-describe('desktopCapturer', function() {
- it('should return a non-empty array of sources', function(done) {
+describe('desktopCapturer', function () {
+ it('should return a non-empty array of sources', function (done) {
desktopCapturer.getSources({
types: ['window', 'screen']
- }, function(error, sources) {
- assert.equal(error, null);
- assert.notEqual(sources.length, 0);
- done();
- });
- });
+ }, function (error, sources) {
+ assert.equal(error, null)
+ assert.notEqual(sources.length, 0)
+ done()
+ })
+ })
- it('does not throw an error when called more than once (regression)', function(done) {
- var callCount = 0;
+ it('does not throw an error when called more than once (regression)', function (done) {
+ var callCount = 0
var callback = function (error, sources) {
- callCount++;
- assert.equal(error, null);
- assert.notEqual(sources.length, 0);
- if (callCount === 2) done();
- };
+ callCount++
+ 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);
- });
-});
+ desktopCapturer.getSources({types: ['window', 'screen']}, callback)
+ desktopCapturer.getSources({types: ['window', 'screen']}, callback)
+ })
+})
diff --git a/spec/api-ipc-spec.js b/spec/api-ipc-spec.js
index 641d89270cbc..862a6c99c176 100644
--- a/spec/api-ipc-spec.js
+++ b/spec/api-ipc-spec.js
@@ -1,210 +1,210 @@
-'use strict';
+'use strict'
-const assert = require('assert');
-const path = require('path');
+const assert = require('assert')
+const path = require('path')
-const ipcRenderer = require('electron').ipcRenderer;
-const remote = require('electron').remote;
+const ipcRenderer = require('electron').ipcRenderer
+const remote = require('electron').remote
-const ipcMain = remote.require('electron').ipcMain;
-const BrowserWindow = remote.require('electron').BrowserWindow;
+const ipcMain = remote.require('electron').ipcMain
+const BrowserWindow = remote.require('electron').BrowserWindow
-const comparePaths = function(path1, path2) {
+const comparePaths = function (path1, path2) {
if (process.platform === 'win32') {
- path1 = path1.toLowerCase();
- path2 = path2.toLowerCase();
+ path1 = path1.toLowerCase()
+ path2 = path2.toLowerCase()
}
- assert.equal(path1, path2);
-};
+ assert.equal(path1, path2)
+}
-describe('ipc module', function() {
- var fixtures = path.join(__dirname, 'fixtures');
+describe('ipc module', function () {
+ var fixtures = path.join(__dirname, 'fixtures')
- describe('remote.require', function() {
- it('should returns same object for the same module', function() {
- var dialog1 = remote.require('electron');
- var dialog2 = remote.require('electron');
- assert.equal(dialog1, dialog2);
- });
+ describe('remote.require', function () {
+ it('should returns same object for the same module', function () {
+ var dialog1 = remote.require('electron')
+ var dialog2 = remote.require('electron')
+ assert.equal(dialog1, dialog2)
+ })
- it('should work when object contains id property', function() {
- var a = remote.require(path.join(fixtures, 'module', 'id.js'));
- assert.equal(a.id, 1127);
- });
+ it('should work when object contains id property', function () {
+ var a = remote.require(path.join(fixtures, 'module', 'id.js'))
+ assert.equal(a.id, 1127)
+ })
- it('should search module from the user app', function() {
- comparePaths(path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js'));
- comparePaths(path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules'));
- });
- });
+ it('should search module from the user app', function () {
+ comparePaths(path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js'))
+ comparePaths(path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules'))
+ })
+ })
- describe('remote.createFunctionWithReturnValue', function() {
- it('should be called in browser synchronously', function() {
- var buf = new Buffer('test');
- var call = remote.require(path.join(fixtures, 'module', 'call.js'));
- var result = call.call(remote.createFunctionWithReturnValue(buf));
- assert.equal(result.constructor.name, 'Buffer');
- });
- });
+ describe('remote.createFunctionWithReturnValue', function () {
+ it('should be called in browser synchronously', function () {
+ var buf = new Buffer('test')
+ var call = remote.require(path.join(fixtures, 'module', 'call.js'))
+ var result = call.call(remote.createFunctionWithReturnValue(buf))
+ assert.equal(result.constructor.name, 'Buffer')
+ })
+ })
- describe('remote object in renderer', function() {
- it('can change its properties', function() {
- var property = remote.require(path.join(fixtures, 'module', 'property.js'));
- assert.equal(property.property, 1127);
- property.property = 1007;
- assert.equal(property.property, 1007);
- var property2 = remote.require(path.join(fixtures, 'module', 'property.js'));
- assert.equal(property2.property, 1007);
- property.property = 1127;
- });
+ describe('remote object in renderer', function () {
+ it('can change its properties', function () {
+ var property = remote.require(path.join(fixtures, 'module', 'property.js'))
+ assert.equal(property.property, 1127)
+ property.property = 1007
+ assert.equal(property.property, 1007)
+ var property2 = remote.require(path.join(fixtures, 'module', 'property.js'))
+ assert.equal(property2.property, 1007)
+ property.property = 1127
+ })
- it('can construct an object from its member', function() {
- var call = remote.require(path.join(fixtures, 'module', 'call.js'));
- var obj = new call.constructor;
- assert.equal(obj.test, 'test');
- });
+ it('can construct an object from its member', function () {
+ var call = remote.require(path.join(fixtures, 'module', 'call.js'))
+ var obj = new call.constructor
+ assert.equal(obj.test, 'test')
+ })
- it('can reassign and delete its member functions', function() {
- var remoteFunctions = remote.require(path.join(fixtures, 'module', 'function.js'));
- assert.equal(remoteFunctions.aFunction(), 1127);
+ it('can reassign and delete its member functions', function () {
+ var remoteFunctions = remote.require(path.join(fixtures, 'module', 'function.js'))
+ assert.equal(remoteFunctions.aFunction(), 1127)
- remoteFunctions.aFunction = function () { return 1234; };
- assert.equal(remoteFunctions.aFunction(), 1234);
+ remoteFunctions.aFunction = function () { return 1234; }
+ assert.equal(remoteFunctions.aFunction(), 1234)
- assert.equal(delete remoteFunctions.aFunction, true);
- });
- });
+ assert.equal(delete remoteFunctions.aFunction, true)
+ })
+ })
- describe('remote value in browser', function() {
- var print = path.join(fixtures, 'module', 'print_name.js');
+ describe('remote value in browser', function () {
+ var print = path.join(fixtures, 'module', 'print_name.js')
- it('keeps its constructor name for objects', function() {
- var buf = new Buffer('test');
- var print_name = remote.require(print);
- assert.equal(print_name.print(buf), 'Buffer');
- });
+ it('keeps its constructor name for objects', function () {
+ var buf = new Buffer('test')
+ var print_name = remote.require(print)
+ assert.equal(print_name.print(buf), 'Buffer')
+ })
- it('supports instanceof Date', function() {
- var now = new Date();
- var print_name = remote.require(print);
- assert.equal(print_name.print(now), 'Date');
- assert.deepEqual(print_name.echo(now), now);
- });
- });
+ it('supports instanceof Date', function () {
+ var now = new Date()
+ var print_name = remote.require(print)
+ assert.equal(print_name.print(now), 'Date')
+ assert.deepEqual(print_name.echo(now), now)
+ })
+ })
- describe('remote promise', function() {
- it('can be used as promise in each side', function(done) {
- var promise = remote.require(path.join(fixtures, 'module', 'promise.js'));
- promise.twicePromise(Promise.resolve(1234)).then(function(value) {
- assert.equal(value, 2468);
- done();
- });
- });
- });
+ describe('remote promise', function () {
+ it('can be used as promise in each side', function (done) {
+ var promise = remote.require(path.join(fixtures, 'module', 'promise.js'))
+ promise.twicePromise(Promise.resolve(1234)).then(function (value) {
+ assert.equal(value, 2468)
+ done()
+ })
+ })
+ })
- describe('remote webContents', function() {
- it('can return same object with different getters', function() {
- var contents1 = remote.getCurrentWindow().webContents;
- var contents2 = remote.getCurrentWebContents();
- assert(contents1 == contents2);
- });
- });
+ describe('remote webContents', function () {
+ it('can return same object with different getters', function () {
+ var contents1 = remote.getCurrentWindow().webContents
+ var contents2 = remote.getCurrentWebContents()
+ assert(contents1 == contents2)
+ })
+ })
- describe('remote class', function() {
- let cl = remote.require(path.join(fixtures, 'module', 'class.js'));
- let base = cl.base;
- let derived = cl.derived;
+ describe('remote class', function () {
+ let cl = remote.require(path.join(fixtures, 'module', 'class.js'))
+ let base = cl.base
+ let derived = cl.derived
- it('can get methods', function() {
- assert.equal(base.method(), 'method');
- });
+ it('can get methods', function () {
+ assert.equal(base.method(), 'method')
+ })
- it('can get properties', function() {
- assert.equal(base.readonly, 'readonly');
- });
+ it('can get properties', function () {
+ assert.equal(base.readonly, 'readonly')
+ })
- it('can change properties', function() {
- assert.equal(base.value, 'old');
- base.value = 'new';
- assert.equal(base.value, 'new');
- base.value = 'old';
- });
+ it('can change properties', function () {
+ assert.equal(base.value, 'old')
+ base.value = 'new'
+ assert.equal(base.value, 'new')
+ base.value = 'old'
+ })
- it('has unenumerable methods', function() {
- assert(!base.hasOwnProperty('method'));
- assert(Object.getPrototypeOf(base).hasOwnProperty('method'));
- });
+ it('has unenumerable methods', function () {
+ assert(!base.hasOwnProperty('method'))
+ assert(Object.getPrototypeOf(base).hasOwnProperty('method'))
+ })
- it('keeps prototype chain in derived class', function() {
- assert.equal(derived.method(), 'method');
- assert.equal(derived.readonly, 'readonly');
- assert(!derived.hasOwnProperty('method'));
- let proto = Object.getPrototypeOf(derived);
- assert(!proto.hasOwnProperty('method'));
- assert(Object.getPrototypeOf(proto).hasOwnProperty('method'));
- });
- });
+ it('keeps prototype chain in derived class', function () {
+ assert.equal(derived.method(), 'method')
+ assert.equal(derived.readonly, 'readonly')
+ assert(!derived.hasOwnProperty('method'))
+ let proto = Object.getPrototypeOf(derived)
+ assert(!proto.hasOwnProperty('method'))
+ assert(Object.getPrototypeOf(proto).hasOwnProperty('method'))
+ })
+ })
- describe('ipc.sender.send', function() {
- it('should work when sending an object containing id property', function(done) {
+ describe('ipc.sender.send', function () {
+ it('should work when sending an object containing id property', function (done) {
var obj = {
id: 1,
name: 'ly'
- };
- ipcRenderer.once('message', function(event, message) {
- assert.deepEqual(message, obj);
- done();
- });
- ipcRenderer.send('message', obj);
- });
+ }
+ ipcRenderer.once('message', function (event, message) {
+ assert.deepEqual(message, obj)
+ done()
+ })
+ ipcRenderer.send('message', obj)
+ })
- it('can send instance of Date', function(done) {
- const currentDate = new Date();
- ipcRenderer.once('message', function(event, value) {
- assert.equal(value, currentDate.toISOString());
- done();
- });
- ipcRenderer.send('message', currentDate);
- });
- });
+ it('can send instance of Date', function (done) {
+ const currentDate = new Date()
+ ipcRenderer.once('message', function (event, value) {
+ assert.equal(value, currentDate.toISOString())
+ done()
+ })
+ ipcRenderer.send('message', currentDate)
+ })
+ })
- describe('ipc.sendSync', function() {
- it('can be replied by setting event.returnValue', function() {
- var msg = ipcRenderer.sendSync('echo', 'test');
- assert.equal(msg, 'test');
- });
+ describe('ipc.sendSync', function () {
+ it('can be replied by setting event.returnValue', function () {
+ var msg = ipcRenderer.sendSync('echo', 'test')
+ assert.equal(msg, 'test')
+ })
- it('does not crash when reply is not sent and browser is destroyed', function(done) {
- this.timeout(10000);
+ it('does not crash when reply is not sent and browser is destroyed', function (done) {
+ this.timeout(10000)
var w = new BrowserWindow({
show: false
- });
- ipcMain.once('send-sync-message', function(event) {
- event.returnValue = null;
- w.destroy();
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'send-sync-message.html'));
- });
- });
+ })
+ ipcMain.once('send-sync-message', function (event) {
+ event.returnValue = null
+ w.destroy()
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'send-sync-message.html'))
+ })
+ })
- describe('remote listeners', function() {
- var w = null;
+ describe('remote listeners', function () {
+ var w = null
- afterEach(function() {
- w.destroy();
- });
+ afterEach(function () {
+ w.destroy()
+ })
- it('can be added and removed correctly', function() {
+ it('can be added and removed correctly', function () {
w = new BrowserWindow({
show: false
- });
- var listener = function() {};
- w.on('test', listener);
- assert.equal(w.listenerCount('test'), 1);
- w.removeListener('test', listener);
- assert.equal(w.listenerCount('test'), 0);
- });
- });
-});
+ })
+ var listener = function () {}
+ w.on('test', listener)
+ assert.equal(w.listenerCount('test'), 1)
+ w.removeListener('test', listener)
+ assert.equal(w.listenerCount('test'), 0)
+ })
+ })
+})
diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js
index bb8736e144f8..6866448e0fd1 100644
--- a/spec/api-menu-spec.js
+++ b/spec/api-menu-spec.js
@@ -1,25 +1,25 @@
-const assert = require('assert');
+const assert = require('assert')
-const remote = require('electron').remote;
-const ipcRenderer = require('electron').ipcRenderer;
+const remote = require('electron').remote
+const ipcRenderer = require('electron').ipcRenderer
-const Menu = remote.require('electron').Menu;
-const MenuItem = remote.require('electron').MenuItem;
+const Menu = remote.require('electron').Menu
+const MenuItem = remote.require('electron').MenuItem
-describe('menu module', function() {
- describe('Menu.buildFromTemplate', function() {
- it('should be able to attach extra fields', function() {
+describe('menu module', function () {
+ describe('Menu.buildFromTemplate', function () {
+ it('should be able to attach extra fields', function () {
var menu = Menu.buildFromTemplate([
{
label: 'text',
extra: 'field'
}
- ]);
- assert.equal(menu.items[0].extra, 'field');
- });
+ ])
+ assert.equal(menu.items[0].extra, 'field')
+ })
- it('does not modify the specified template', function() {
- var template = ipcRenderer.sendSync('eval', "var template = [{label: 'text', submenu: [{label: 'sub'}]}];\nrequire('electron').Menu.buildFromTemplate(template);\ntemplate;");
+ it('does not modify the specified template', function () {
+ var template = ipcRenderer.sendSync('eval', "var template = [{label: 'text', submenu: [{label: 'sub'}]}];\nrequire('electron').Menu.buildFromTemplate(template);\ntemplate;")
assert.deepStrictEqual(template, [
{
label: 'text',
@@ -29,11 +29,11 @@ describe('menu module', function() {
}
]
}
- ]);
- });
+ ])
+ })
- it('does not throw exceptions for undefined/null values', function() {
- assert.doesNotThrow(function() {
+ it('does not throw exceptions for undefined/null values', function () {
+ assert.doesNotThrow(function () {
Menu.buildFromTemplate([
{
label: 'text',
@@ -43,12 +43,12 @@ describe('menu module', function() {
label: 'text again',
accelerator: null
}
- ]);
- });
- });
+ ])
+ })
+ })
- describe('Menu.buildFromTemplate should reorder based on item position specifiers', function() {
- it('should position before existing item', function() {
+ describe('Menu.buildFromTemplate should reorder based on item position specifiers', function () {
+ it('should position before existing item', function () {
var menu = Menu.buildFromTemplate([
{
label: '2',
@@ -61,13 +61,13 @@ describe('menu module', function() {
id: '1',
position: 'before=2'
}
- ]);
- assert.equal(menu.items[0].label, '1');
- assert.equal(menu.items[1].label, '2');
- assert.equal(menu.items[2].label, '3');
- });
+ ])
+ assert.equal(menu.items[0].label, '1')
+ assert.equal(menu.items[1].label, '2')
+ assert.equal(menu.items[2].label, '3')
+ })
- it('should position after existing item', function() {
+ it('should position after existing item', function () {
var menu = Menu.buildFromTemplate([
{
label: '1',
@@ -80,13 +80,13 @@ describe('menu module', function() {
id: '2',
position: 'after=1'
}
- ]);
- assert.equal(menu.items[0].label, '1');
- assert.equal(menu.items[1].label, '2');
- assert.equal(menu.items[2].label, '3');
- });
+ ])
+ assert.equal(menu.items[0].label, '1')
+ assert.equal(menu.items[1].label, '2')
+ assert.equal(menu.items[2].label, '3')
+ })
- it('should position at endof existing separator groups', function() {
+ it('should position at endof existing separator groups', function () {
var menu = Menu.buildFromTemplate([
{
type: 'separator',
@@ -119,18 +119,18 @@ describe('menu module', function() {
id: '3',
position: 'endof=numbers'
}
- ]);
- assert.equal(menu.items[0].id, 'numbers');
- assert.equal(menu.items[1].label, '1');
- assert.equal(menu.items[2].label, '2');
- assert.equal(menu.items[3].label, '3');
- assert.equal(menu.items[4].id, 'letters');
- assert.equal(menu.items[5].label, 'a');
- assert.equal(menu.items[6].label, 'b');
- assert.equal(menu.items[7].label, 'c');
- });
+ ])
+ assert.equal(menu.items[0].id, 'numbers')
+ assert.equal(menu.items[1].label, '1')
+ assert.equal(menu.items[2].label, '2')
+ assert.equal(menu.items[3].label, '3')
+ assert.equal(menu.items[4].id, 'letters')
+ assert.equal(menu.items[5].label, 'a')
+ assert.equal(menu.items[6].label, 'b')
+ assert.equal(menu.items[7].label, 'c')
+ })
- it('should create separator group if endof does not reference existing separator group', function() {
+ it('should create separator group if endof does not reference existing separator group', function () {
var menu = Menu.buildFromTemplate([
{
label: 'a',
@@ -157,18 +157,18 @@ describe('menu module', function() {
id: '3',
position: 'endof=numbers'
}
- ]);
- assert.equal(menu.items[0].id, 'letters');
- assert.equal(menu.items[1].label, 'a');
- assert.equal(menu.items[2].label, 'b');
- assert.equal(menu.items[3].label, 'c');
- assert.equal(menu.items[4].id, 'numbers');
- assert.equal(menu.items[5].label, '1');
- assert.equal(menu.items[6].label, '2');
- assert.equal(menu.items[7].label, '3');
- });
+ ])
+ assert.equal(menu.items[0].id, 'letters')
+ assert.equal(menu.items[1].label, 'a')
+ assert.equal(menu.items[2].label, 'b')
+ assert.equal(menu.items[3].label, 'c')
+ assert.equal(menu.items[4].id, 'numbers')
+ assert.equal(menu.items[5].label, '1')
+ assert.equal(menu.items[6].label, '2')
+ assert.equal(menu.items[7].label, '3')
+ })
- it('should continue inserting items at next index when no specifier is present', function() {
+ it('should continue inserting items at next index when no specifier is present', function () {
var menu = Menu.buildFromTemplate([
{
label: '4',
@@ -187,18 +187,18 @@ describe('menu module', function() {
label: '3',
id: '3'
}
- ]);
- assert.equal(menu.items[0].label, '1');
- assert.equal(menu.items[1].label, '2');
- assert.equal(menu.items[2].label, '3');
- assert.equal(menu.items[3].label, '4');
- assert.equal(menu.items[4].label, '5');
- });
- });
- });
+ ])
+ assert.equal(menu.items[0].label, '1')
+ assert.equal(menu.items[1].label, '2')
+ assert.equal(menu.items[2].label, '3')
+ assert.equal(menu.items[3].label, '4')
+ assert.equal(menu.items[4].label, '5')
+ })
+ })
+ })
- describe('Menu.insert', function() {
- it('should store item in @items by its index', function() {
+ describe('Menu.insert', function () {
+ it('should store item in @items by its index', function () {
var menu = Menu.buildFromTemplate([
{
label: '1'
@@ -207,156 +207,156 @@ describe('menu module', function() {
}, {
label: '3'
}
- ]);
+ ])
var item = new MenuItem({
label: 'inserted'
- });
- menu.insert(1, item);
- assert.equal(menu.items[0].label, '1');
- assert.equal(menu.items[1].label, 'inserted');
- assert.equal(menu.items[2].label, '2');
- assert.equal(menu.items[3].label, '3');
- });
- });
+ })
+ menu.insert(1, item)
+ assert.equal(menu.items[0].label, '1')
+ assert.equal(menu.items[1].label, 'inserted')
+ assert.equal(menu.items[2].label, '2')
+ assert.equal(menu.items[3].label, '3')
+ })
+ })
- describe('MenuItem.click', function() {
- it('should be called with the item object passed', function(done) {
+ describe('MenuItem.click', function () {
+ it('should be called with the item object passed', function (done) {
var menu = Menu.buildFromTemplate([
{
label: 'text',
- click: function(item) {
- assert.equal(item.constructor.name, 'MenuItem');
- assert.equal(item.label, 'text');
- done();
+ click: function (item) {
+ assert.equal(item.constructor.name, 'MenuItem')
+ assert.equal(item.label, 'text')
+ done()
}
}
- ]);
- menu.delegate.executeCommand(menu.items[0].commandId);
- });
- });
+ ])
+ menu.delegate.executeCommand(menu.items[0].commandId)
+ })
+ })
- describe('MenuItem with checked property', function() {
- it('clicking an checkbox item should flip the checked property', function() {
+ describe('MenuItem with checked property', function () {
+ it('clicking an checkbox item should flip the checked property', function () {
var menu = Menu.buildFromTemplate([
{
label: 'text',
type: 'checkbox'
}
- ]);
- assert.equal(menu.items[0].checked, false);
- menu.delegate.executeCommand(menu.items[0].commandId);
- assert.equal(menu.items[0].checked, true);
- });
+ ])
+ assert.equal(menu.items[0].checked, false)
+ menu.delegate.executeCommand(menu.items[0].commandId)
+ assert.equal(menu.items[0].checked, true)
+ })
- it('clicking an radio item should always make checked property true', function() {
+ it('clicking an radio item should always make checked property true', function () {
var menu = Menu.buildFromTemplate([
{
label: 'text',
type: 'radio'
}
- ]);
- menu.delegate.executeCommand(menu.items[0].commandId);
- assert.equal(menu.items[0].checked, true);
- menu.delegate.executeCommand(menu.items[0].commandId);
- assert.equal(menu.items[0].checked, true);
- });
+ ])
+ menu.delegate.executeCommand(menu.items[0].commandId)
+ assert.equal(menu.items[0].checked, true)
+ menu.delegate.executeCommand(menu.items[0].commandId)
+ 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 = [];
+ it('at least have one item checked in each group', function () {
+ var i, j, k, menu, template
+ template = []
for (i = j = 0; j <= 10; i = ++j) {
template.push({
- label: "" + i,
+ label: '' + i,
type: 'radio'
- });
+ })
}
template.push({
type: 'separator'
- });
+ })
for (i = k = 12; k <= 20; i = ++k) {
template.push({
- label: "" + i,
+ label: '' + i,
type: 'radio'
- });
+ })
}
- menu = Menu.buildFromTemplate(template);
- menu.delegate.menuWillShow();
- assert.equal(menu.items[0].checked, true);
- assert.equal(menu.items[12].checked, true);
- });
+ menu = Menu.buildFromTemplate(template)
+ menu.delegate.menuWillShow()
+ assert.equal(menu.items[0].checked, true)
+ assert.equal(menu.items[12].checked, true)
+ })
- it('should assign groupId automatically', function() {
- var groupId, i, j, k, l, m, menu, template;
- template = [];
+ it('should assign groupId automatically', function () {
+ var groupId, i, j, k, l, m, menu, template
+ template = []
for (i = j = 0; j <= 10; i = ++j) {
template.push({
- label: "" + i,
+ label: '' + i,
type: 'radio'
- });
+ })
}
template.push({
type: 'separator'
- });
+ })
for (i = k = 12; k <= 20; i = ++k) {
template.push({
- label: "" + i,
+ label: '' + i,
type: 'radio'
- });
+ })
}
- menu = Menu.buildFromTemplate(template);
- groupId = menu.items[0].groupId;
+ menu = Menu.buildFromTemplate(template)
+ groupId = menu.items[0].groupId
for (i = l = 0; l <= 10; i = ++l) {
- assert.equal(menu.items[i].groupId, groupId);
+ assert.equal(menu.items[i].groupId, groupId)
}
for (i = m = 12; m <= 20; i = ++m) {
- assert.equal(menu.items[i].groupId, groupId + 1);
+ assert.equal(menu.items[i].groupId, groupId + 1)
}
- });
+ })
- it("setting 'checked' should flip other items' 'checked' property", function() {
- var i, j, k, l, m, menu, n, o, p, q, template;
- template = [];
+ it("setting 'checked' should flip other items' 'checked' property", function () {
+ var i, j, k, l, m, menu, n, o, p, q, template
+ template = []
for (i = j = 0; j <= 10; i = ++j) {
template.push({
- label: "" + i,
+ label: '' + i,
type: 'radio'
- });
+ })
}
template.push({
type: 'separator'
- });
+ })
for (i = k = 12; k <= 20; i = ++k) {
template.push({
- label: "" + i,
+ label: '' + i,
type: 'radio'
- });
+ })
}
- menu = Menu.buildFromTemplate(template);
+ menu = Menu.buildFromTemplate(template)
for (i = l = 0; l <= 10; i = ++l) {
- assert.equal(menu.items[i].checked, false);
+ assert.equal(menu.items[i].checked, false)
}
- menu.items[0].checked = true;
- assert.equal(menu.items[0].checked, true);
+ menu.items[0].checked = true
+ assert.equal(menu.items[0].checked, true)
for (i = m = 1; m <= 10; i = ++m) {
- assert.equal(menu.items[i].checked, false);
+ assert.equal(menu.items[i].checked, false)
}
- menu.items[10].checked = true;
- assert.equal(menu.items[10].checked, true);
+ menu.items[10].checked = true
+ assert.equal(menu.items[10].checked, true)
for (i = n = 0; n <= 9; i = ++n) {
- assert.equal(menu.items[i].checked, false);
+ assert.equal(menu.items[i].checked, false)
}
for (i = o = 12; o <= 20; i = ++o) {
- assert.equal(menu.items[i].checked, false);
+ assert.equal(menu.items[i].checked, false)
}
- menu.items[12].checked = true;
- assert.equal(menu.items[10].checked, true);
+ menu.items[12].checked = true
+ assert.equal(menu.items[10].checked, true)
for (i = p = 0; p <= 9; i = ++p) {
- assert.equal(menu.items[i].checked, false);
+ assert.equal(menu.items[i].checked, false)
}
- assert.equal(menu.items[12].checked, true);
+ assert.equal(menu.items[12].checked, true)
for (i = q = 13; q <= 20; i = ++q) {
- assert.equal(menu.items[i].checked, false);
+ assert.equal(menu.items[i].checked, false)
}
- });
- });
-});
+ })
+ })
+})
diff --git a/spec/api-native-image-spec.js b/spec/api-native-image-spec.js
index a7ee8be007ed..6c5092cf7c3c 100644
--- a/spec/api-native-image-spec.js
+++ b/spec/api-native-image-spec.js
@@ -1,51 +1,51 @@
-'use strict';
+'use strict'
-const assert = require('assert');
-const nativeImage = require('electron').nativeImage;
-const path = require('path');
+const assert = require('assert')
+const nativeImage = require('electron').nativeImage
+const path = require('path')
describe('nativeImage module', () => {
describe('createFromPath(path)', () => {
it('returns an empty image for invalid paths', () => {
- assert(nativeImage.createFromPath('').isEmpty());
- assert(nativeImage.createFromPath('does-not-exist.png').isEmpty());
- });
+ assert(nativeImage.createFromPath('').isEmpty())
+ assert(nativeImage.createFromPath('does-not-exist.png').isEmpty())
+ })
it('loads images from paths relative to the current working directory', () => {
- const imagePath = `.${path.sep}${path.join('spec', 'fixtures', 'assets', 'logo.png')}`;
- const image = nativeImage.createFromPath(imagePath);
- assert(!image.isEmpty());
- assert.equal(image.getSize().height, 190);
- assert.equal(image.getSize().width, 538);
- });
+ const imagePath = `.${path.sep}${path.join('spec', 'fixtures', 'assets', 'logo.png')}`
+ const image = nativeImage.createFromPath(imagePath)
+ assert(!image.isEmpty())
+ assert.equal(image.getSize().height, 190)
+ assert.equal(image.getSize().width, 538)
+ })
it('loads images from paths with `.` segments', () => {
- const imagePath = `${path.join(__dirname, 'fixtures')}${path.sep}.${path.sep}${path.join('assets', 'logo.png')}`;
- const image = nativeImage.createFromPath(imagePath);
- assert(!image.isEmpty());
- assert.equal(image.getSize().height, 190);
- assert.equal(image.getSize().width, 538);
- });
+ const imagePath = `${path.join(__dirname, 'fixtures')}${path.sep}.${path.sep}${path.join('assets', 'logo.png')}`
+ const image = nativeImage.createFromPath(imagePath)
+ assert(!image.isEmpty())
+ assert.equal(image.getSize().height, 190)
+ assert.equal(image.getSize().width, 538)
+ })
it('loads images from paths with `..` segments', () => {
- const imagePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}`;
- const image = nativeImage.createFromPath(imagePath);
- assert(!image.isEmpty());
- assert.equal(image.getSize().height, 190);
- assert.equal(image.getSize().width, 538);
- });
+ const imagePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}`
+ const image = nativeImage.createFromPath(imagePath)
+ assert(!image.isEmpty())
+ assert.equal(image.getSize().height, 190)
+ assert.equal(image.getSize().width, 538)
+ })
it('Gets an NSImage pointer on OS X', () => {
- if (process.platform !== 'darwin') return;
+ if (process.platform !== 'darwin') return
- const imagePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}`;
- const image = nativeImage.createFromPath(imagePath);
- const nsimage = image.getNativeHandle();
+ const imagePath = `${path.join(__dirname, 'fixtures', 'api')}${path.sep}..${path.sep}${path.join('assets', 'logo.png')}`
+ const image = nativeImage.createFromPath(imagePath)
+ const nsimage = image.getNativeHandle()
- assert.equal(nsimage.length, 8);
+ assert.equal(nsimage.length, 8)
// If all bytes are null, that's Bad
- assert.equal(nsimage.reduce((acc,x) => acc || (x != 0), false), true);
- });
- });
-});
+ assert.equal(nsimage.reduce((acc, x) => acc || (x != 0), false), true)
+ })
+ })
+})
diff --git a/spec/api-protocol-spec.js b/spec/api-protocol-spec.js
index 215868bfdc8a..001359d3850c 100644
--- a/spec/api-protocol-spec.js
+++ b/spec/api-protocol-spec.js
@@ -1,772 +1,772 @@
-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;
+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 protocolName = 'sp';
- var text = 'valar morghulis';
+describe('protocol module', function () {
+ var protocolName = 'sp'
+ var text = 'valar morghulis'
var postData = {
name: 'post test',
type: 'string'
- };
+ }
- afterEach(function(done) {
- protocol.unregisterProtocol(protocolName, function() {
- protocol.uninterceptProtocol('http', function() {
- done();
- });
- });
- });
+ afterEach(function (done) {
+ protocol.unregisterProtocol(protocolName, function () {
+ protocol.uninterceptProtocol('http', function () {
+ done()
+ })
+ })
+ })
- describe('protocol.register(Any)Protocol', function() {
- var emptyHandler = function(request, callback) {
- callback();
- };
+ describe('protocol.register(Any)Protocol', function () {
+ var emptyHandler = function (request, callback) {
+ callback()
+ }
- it('throws error when scheme is already registered', function(done) {
- protocol.registerStringProtocol(protocolName, emptyHandler, function(error) {
- assert.equal(error, null);
- protocol.registerBufferProtocol(protocolName, emptyHandler, function(error) {
- assert.notEqual(error, null);
- done();
- });
- });
- });
+ it('throws error when scheme is already registered', function (done) {
+ protocol.registerStringProtocol(protocolName, emptyHandler, function (error) {
+ assert.equal(error, null)
+ protocol.registerBufferProtocol(protocolName, emptyHandler, function (error) {
+ assert.notEqual(error, null)
+ done()
+ })
+ })
+ })
- it('does not crash when handler is called twice', function(done) {
- var doubleHandler = function(request, callback) {
+ it('does not crash when handler is called twice', function (done) {
+ var doubleHandler = function (request, callback) {
try {
- callback(text);
- callback();
+ callback(text)
+ callback()
} catch (error) {
// Ignore error
}
- };
- protocol.registerStringProtocol(protocolName, doubleHandler, function(error) {
+ }
+ protocol.registerStringProtocol(protocolName, doubleHandler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('sends error when callback is called with nothing', function(done) {
- protocol.registerBufferProtocol(protocolName, emptyHandler, function(error) {
+ it('sends error when callback is called with nothing', function (done) {
+ protocol.registerBufferProtocol(protocolName, emptyHandler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- return done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ return done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- return done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ return done()
}
- });
- });
- });
+ })
+ })
+ })
- it('does not crash when callback is called in next tick', function(done) {
- var handler = function(request, callback) {
- setImmediate(function() {
- callback(text);
- });
- };
- protocol.registerStringProtocol(protocolName, handler, function(error) {
+ it('does not crash when callback is called in next tick', function (done) {
+ var handler = function (request, callback) {
+ setImmediate(function () {
+ callback(text)
+ })
+ }
+ protocol.registerStringProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
- });
+ })
+ })
+ })
+ })
- describe('protocol.unregisterProtocol', function() {
- it('returns error when scheme does not exist', function(done) {
- protocol.unregisterProtocol('not-exist', function(error) {
- assert.notEqual(error, null);
- done();
- });
- });
- });
+ describe('protocol.unregisterProtocol', function () {
+ it('returns error when scheme does not exist', function (done) {
+ protocol.unregisterProtocol('not-exist', function (error) {
+ assert.notEqual(error, null)
+ done()
+ })
+ })
+ })
- describe('protocol.registerStringProtocol', function() {
- it('sends string as response', function(done) {
- var handler = function(request, callback) {
- callback(text);
- };
- protocol.registerStringProtocol(protocolName, handler, function(error) {
+ describe('protocol.registerStringProtocol', function () {
+ it('sends string as response', function (done) {
+ var handler = function (request, callback) {
+ callback(text)
+ }
+ protocol.registerStringProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('sets Access-Control-Allow-Origin', function(done) {
- var handler = function(request, callback) {
- callback(text);
- };
- protocol.registerStringProtocol(protocolName, handler, function(error) {
+ it('sets Access-Control-Allow-Origin', function (done) {
+ var handler = function (request, callback) {
+ callback(text)
+ }
+ protocol.registerStringProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data, status, request) {
- assert.equal(data, text);
- assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*');
- done();
+ url: protocolName + '://fake-host',
+ success: function (data, status, request) {
+ assert.equal(data, text)
+ assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('sends object as response', function(done) {
- var handler = function(request, callback) {
+ it('sends object as response', function (done) {
+ var handler = function (request, callback) {
callback({
data: text,
mimeType: 'text/html'
- });
- };
- protocol.registerStringProtocol(protocolName, handler, function(error) {
+ })
+ }
+ protocol.registerStringProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('fails when sending object other than string', function(done) {
- var handler = function(request, callback) {
- callback(new Date);
- };
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ it('fails when sending object other than string', function (done) {
+ var handler = function (request, callback) {
+ callback(new Date)
+ }
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
- });
+ })
+ })
+ })
+ })
- describe('protocol.registerBufferProtocol', function() {
- var buffer = new Buffer(text);
+ describe('protocol.registerBufferProtocol', function () {
+ var buffer = new Buffer(text)
- it('sends Buffer as response', function(done) {
- var handler = function(request, callback) {
- callback(buffer);
- };
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ it('sends Buffer as response', function (done) {
+ var handler = function (request, callback) {
+ callback(buffer)
+ }
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('sets Access-Control-Allow-Origin', function(done) {
- var handler = function(request, callback) {
- callback(buffer);
- };
+ it('sets Access-Control-Allow-Origin', function (done) {
+ var handler = function (request, callback) {
+ callback(buffer)
+ }
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data, status, request) {
- assert.equal(data, text);
- assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*');
- done();
+ url: protocolName + '://fake-host',
+ success: function (data, status, request) {
+ assert.equal(data, text)
+ assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('sends object as response', function(done) {
- var handler = function(request, callback) {
+ it('sends object as response', function (done) {
+ var handler = function (request, callback) {
callback({
data: buffer,
mimeType: 'text/html'
- });
- };
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ })
+ }
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('fails when sending string', function(done) {
- var handler = function(request, callback) {
- callback(text);
- };
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ it('fails when sending string', function (done) {
+ var handler = function (request, callback) {
+ callback(text)
+ }
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
- });
+ })
+ })
+ })
+ })
- describe('protocol.registerFileProtocol', function() {
- 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);
+ describe('protocol.registerFileProtocol', function () {
+ 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 = function(request, callback) {
- callback(filePath);
- };
- protocol.registerFileProtocol(protocolName, handler, function(error) {
+ it('sends file path as response', function (done) {
+ var handler = function (request, callback) {
+ callback(filePath)
+ }
+ protocol.registerFileProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, String(fileContent));
- return done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, String(fileContent))
+ return done()
},
- error: function(xhr, errorType, error) {
- return done(error);
+ error: function (xhr, errorType, error) {
+ return done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('sets Access-Control-Allow-Origin', function(done) {
- var handler = function(request, callback) {
- callback(filePath);
- };
- protocol.registerFileProtocol(protocolName, handler, function(error) {
+ it('sets Access-Control-Allow-Origin', function (done) {
+ var handler = function (request, callback) {
+ callback(filePath)
+ }
+ protocol.registerFileProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data, status, request) {
- assert.equal(data, String(fileContent));
- assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*');
- done();
+ url: protocolName + '://fake-host',
+ success: function (data, status, request) {
+ assert.equal(data, String(fileContent))
+ assert.equal(request.getResponseHeader('Access-Control-Allow-Origin'), '*')
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
- it('sends object as response', function(done) {
- var handler = function(request, callback) {
+ })
+ })
+ })
+ it('sends object as response', function (done) {
+ var handler = function (request, callback) {
callback({
path: filePath
- });
- };
- protocol.registerFileProtocol(protocolName, handler, function(error) {
+ })
+ }
+ protocol.registerFileProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, String(fileContent));
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, String(fileContent))
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('can send normal file', function(done) {
- var handler = function(request, callback) {
- callback(normalPath);
- };
+ it('can send normal file', function (done) {
+ var handler = function (request, callback) {
+ callback(normalPath)
+ }
- protocol.registerFileProtocol(protocolName, handler, function(error) {
+ protocol.registerFileProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, String(normalContent));
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, String(normalContent))
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('fails when sending unexist-file', function(done) {
- var fakeFilePath = path.join(__dirname, 'fixtures', 'asar', 'a.asar', 'not-exist');
- var handler = function(request, callback) {
- callback(fakeFilePath);
- };
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ it('fails when sending unexist-file', function (done) {
+ var fakeFilePath = path.join(__dirname, 'fixtures', 'asar', 'a.asar', 'not-exist')
+ var handler = function (request, callback) {
+ callback(fakeFilePath)
+ }
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
+ })
+ })
+ })
- it('fails when sending unsupported content', function(done) {
- var handler = function(request, callback) {
- callback(new Date);
- };
- protocol.registerBufferProtocol(protocolName, handler, function(error) {
+ it('fails when sending unsupported content', function (done) {
+ var handler = function (request, callback) {
+ callback(new Date)
+ }
+ protocol.registerBufferProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
- });
+ })
+ })
+ })
+ })
- describe('protocol.registerHttpProtocol', function() {
- it('sends url as response', function(done) {
- var server = http.createServer(function(req, res) {
- assert.notEqual(req.headers.accept, '');
- res.end(text);
- server.close();
- });
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- var url = "http://127.0.0.1:" + port;
- var handler = function(request, callback) {
+ describe('protocol.registerHttpProtocol', function () {
+ it('sends url as response', function (done) {
+ var server = http.createServer(function (req, res) {
+ assert.notEqual(req.headers.accept, '')
+ res.end(text)
+ server.close()
+ })
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ var url = 'http://127.0.0.1:' + port
+ var handler = function (request, callback) {
callback({
url: url
- });
- };
- protocol.registerHttpProtocol(protocolName, handler, function(error) {
+ })
+ }
+ protocol.registerHttpProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function(data) {
- assert.equal(data, text);
- done();
+ url: protocolName + '://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
- });
+ })
+ })
+ })
+ })
- it('fails when sending invalid url', function(done) {
- var handler = function(request, callback) {
+ it('fails when sending invalid url', function (done) {
+ var handler = function (request, callback) {
callback({
url: 'url'
- });
- };
- protocol.registerHttpProtocol(protocolName, handler, function(error) {
+ })
+ }
+ protocol.registerHttpProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
+ })
+ })
+ })
- it('fails when sending unsupported content', function(done) {
- var handler = function(request, callback) {
- callback(new Date);
- };
- protocol.registerHttpProtocol(protocolName, handler, function(error) {
+ it('fails when sending unsupported content', function (done) {
+ var handler = function (request, callback) {
+ callback(new Date)
+ }
+ protocol.registerHttpProtocol(protocolName, handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: protocolName + "://fake-host",
- success: function() {
- done('request succeeded but it should not');
+ url: protocolName + '://fake-host',
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
- });
+ })
+ })
+ })
+ })
- describe('protocol.isProtocolHandled', function() {
- it('returns true for file:', function(done) {
- protocol.isProtocolHandled('file', function(result) {
- assert.equal(result, true);
- done();
- });
- });
+ describe('protocol.isProtocolHandled', function () {
+ it('returns true for file:', function (done) {
+ protocol.isProtocolHandled('file', function (result) {
+ assert.equal(result, true)
+ done()
+ })
+ })
- it('returns true for http:', function(done) {
- protocol.isProtocolHandled('http', function(result) {
- assert.equal(result, true);
- done();
- });
- });
+ it('returns true for http:', function (done) {
+ protocol.isProtocolHandled('http', function (result) {
+ assert.equal(result, true)
+ done()
+ })
+ })
- it('returns true for https:', function(done) {
- protocol.isProtocolHandled('https', function(result) {
- assert.equal(result, true);
- done();
- });
- });
+ it('returns true for https:', function (done) {
+ protocol.isProtocolHandled('https', function (result) {
+ assert.equal(result, true)
+ done()
+ })
+ })
- it('returns false when scheme is not registred', function(done) {
- protocol.isProtocolHandled('no-exist', function(result) {
- assert.equal(result, false);
- done();
- });
- });
+ it('returns false when scheme is not registred', function (done) {
+ protocol.isProtocolHandled('no-exist', function (result) {
+ assert.equal(result, false)
+ done()
+ })
+ })
- it('returns true for custom protocol', function(done) {
- var emptyHandler = function(request, callback) {
- callback();
- };
- protocol.registerStringProtocol(protocolName, emptyHandler, function(error) {
- assert.equal(error, null);
- protocol.isProtocolHandled(protocolName, function(result) {
- assert.equal(result, true);
- done();
- });
- });
- });
+ it('returns true for custom protocol', function (done) {
+ var emptyHandler = function (request, callback) {
+ callback()
+ }
+ protocol.registerStringProtocol(protocolName, emptyHandler, function (error) {
+ assert.equal(error, null)
+ protocol.isProtocolHandled(protocolName, function (result) {
+ assert.equal(result, true)
+ done()
+ })
+ })
+ })
- it('returns true for intercepted protocol', function(done) {
- var emptyHandler = function(request, callback) {
- callback();
- };
- protocol.interceptStringProtocol('http', emptyHandler, function(error) {
- assert.equal(error, null);
- protocol.isProtocolHandled('http', function(result) {
- assert.equal(result, true);
- done();
- });
- });
- });
- });
+ it('returns true for intercepted protocol', function (done) {
+ var emptyHandler = function (request, callback) {
+ callback()
+ }
+ protocol.interceptStringProtocol('http', emptyHandler, function (error) {
+ assert.equal(error, null)
+ protocol.isProtocolHandled('http', function (result) {
+ assert.equal(result, true)
+ done()
+ })
+ })
+ })
+ })
- describe('protocol.intercept(Any)Protocol', function() {
- var emptyHandler = function(request, callback) {
- callback();
- };
+ describe('protocol.intercept(Any)Protocol', function () {
+ var emptyHandler = function (request, callback) {
+ callback()
+ }
- it('throws error when scheme is already intercepted', function(done) {
- protocol.interceptStringProtocol('http', emptyHandler, function(error) {
- assert.equal(error, null);
- protocol.interceptBufferProtocol('http', emptyHandler, function(error) {
- assert.notEqual(error, null);
- done();
- });
- });
- });
+ it('throws error when scheme is already intercepted', function (done) {
+ protocol.interceptStringProtocol('http', emptyHandler, function (error) {
+ assert.equal(error, null)
+ protocol.interceptBufferProtocol('http', emptyHandler, function (error) {
+ assert.notEqual(error, null)
+ done()
+ })
+ })
+ })
- it('does not crash when handler is called twice', function(done) {
- var doubleHandler = function(request, callback) {
+ it('does not crash when handler is called twice', function (done) {
+ var doubleHandler = function (request, callback) {
try {
- callback(text);
- callback();
+ callback(text)
+ callback()
} catch (error) {
// Ignore error
}
- };
- protocol.interceptStringProtocol('http', doubleHandler, function(error) {
- if (error) {
- return done(error);
- }
- $.ajax({
- url: 'http://fake-host',
- success: function(data) {
- assert.equal(data, text);
- done();
- },
- error: function(xhr, errorType, error) {
- done(error);
- }
- });
- });
- });
-
- it('sends error when callback is called with nothing', function(done) {
- if (process.env.TRAVIS === 'true') {
- return done();
}
- protocol.interceptBufferProtocol('http', emptyHandler, function(error) {
+ protocol.interceptStringProtocol('http', doubleHandler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
url: 'http://fake-host',
- success: function() {
- done('request succeeded but it should not');
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType) {
- assert.equal(errorType, 'error');
- done();
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
- });
+ })
+ })
+ })
- describe('protocol.interceptStringProtocol', function() {
- it('can intercept http protocol', function(done) {
- var handler = function(request, callback) {
- callback(text);
- };
- protocol.interceptStringProtocol('http', handler, function(error) {
+ it('sends error when callback is called with nothing', function (done) {
+ if (process.env.TRAVIS === 'true') {
+ return done()
+ }
+ protocol.interceptBufferProtocol('http', emptyHandler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
url: 'http://fake-host',
- success: function(data) {
- assert.equal(data, text);
- done();
+ success: function () {
+ done('request succeeded but it should not')
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType) {
+ assert.equal(errorType, 'error')
+ done()
}
- });
- });
- });
+ })
+ })
+ })
+ })
- it('can set content-type', function(done) {
- var handler = function(request, callback) {
+ describe('protocol.interceptStringProtocol', function () {
+ it('can intercept http protocol', function (done) {
+ var handler = function (request, callback) {
+ callback(text)
+ }
+ protocol.interceptStringProtocol('http', handler, function (error) {
+ if (error) {
+ return done(error)
+ }
+ $.ajax({
+ url: 'http://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
+ },
+ error: function (xhr, errorType, error) {
+ done(error)
+ }
+ })
+ })
+ })
+
+ it('can set content-type', function (done) {
+ var handler = function (request, callback) {
callback({
mimeType: 'application/json',
data: '{"value": 1}'
- });
- };
- protocol.interceptStringProtocol('http', handler, function(error) {
+ })
+ }
+ protocol.interceptStringProtocol('http', handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
url: 'http://fake-host',
- success: function(data) {
- assert.equal(typeof data, 'object');
- assert.equal(data.value, 1);
- done();
+ success: function (data) {
+ assert.equal(typeof data, 'object')
+ assert.equal(data.value, 1)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
- it('can receive post data', function(done) {
- var handler = function(request, callback) {
- var uploadData = request.uploadData[0].bytes.toString();
+ it('can receive post data', function (done) {
+ var handler = function (request, callback) {
+ var uploadData = request.uploadData[0].bytes.toString()
callback({
data: uploadData
- });
- };
- protocol.interceptStringProtocol('http', handler, function(error) {
+ })
+ }
+ protocol.interceptStringProtocol('http', handler, function (error) {
if (error) {
- return done(error);
- }
- $.ajax({
- url: "http://fake-host",
- type: "POST",
- data: postData,
- success: function(data) {
- assert.deepEqual(qs.parse(data), postData);
- done();
- },
- error: function(xhr, errorType, error) {
- done(error);
- }
- });
- });
- });
- });
-
- describe('protocol.interceptBufferProtocol', function() {
- it('can intercept http protocol', function(done) {
- var handler = function(request, callback) {
- callback(new Buffer(text));
- };
- protocol.interceptBufferProtocol('http', handler, function(error) {
- if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
url: 'http://fake-host',
- success: function(data) {
- assert.equal(data, text);
- done();
+ type: 'POST',
+ data: postData,
+ success: function (data) {
+ assert.deepEqual(qs.parse(data), postData)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
+ })
+ })
+ })
+ })
- it('can receive post data', function(done) {
- var handler = function(request, callback) {
- var uploadData = request.uploadData[0].bytes;
- callback(uploadData);
- };
- protocol.interceptBufferProtocol('http', handler, function(error) {
+ describe('protocol.interceptBufferProtocol', function () {
+ it('can intercept http protocol', function (done) {
+ var handler = function (request, callback) {
+ callback(new Buffer(text))
+ }
+ protocol.interceptBufferProtocol('http', handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: "http://fake-host",
- type: "POST",
- data: postData,
- success: function(data) {
- assert.equal(data, $.param(postData));
- done();
+ url: 'http://fake-host',
+ success: function (data) {
+ assert.equal(data, text)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
- });
+ })
+ })
+ })
- describe('protocol.interceptHttpProtocol', function() {
- it('can send POST request', function(done) {
- var server = http.createServer(function(req, res) {
- var body = '';
- req.on('data', function(chunk) {
- body += chunk;
- });
- req.on('end', function() {
- res.end(body);
- });
- server.close();
- });
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- var url = "http://127.0.0.1:" + port;
- var handler = function(request, callback) {
+ it('can receive post data', function (done) {
+ var handler = function (request, callback) {
+ var uploadData = request.uploadData[0].bytes
+ callback(uploadData)
+ }
+ protocol.interceptBufferProtocol('http', handler, function (error) {
+ if (error) {
+ return done(error)
+ }
+ $.ajax({
+ url: 'http://fake-host',
+ type: 'POST',
+ data: postData,
+ success: function (data) {
+ assert.equal(data, $.param(postData))
+ done()
+ },
+ error: function (xhr, errorType, error) {
+ done(error)
+ }
+ })
+ })
+ })
+ })
+
+ describe('protocol.interceptHttpProtocol', function () {
+ it('can send POST request', function (done) {
+ var server = http.createServer(function (req, res) {
+ var body = ''
+ req.on('data', function (chunk) {
+ body += chunk
+ })
+ req.on('end', function () {
+ res.end(body)
+ })
+ server.close()
+ })
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ var url = 'http://127.0.0.1:' + port
+ var handler = function (request, callback) {
var data = {
url: url,
method: 'POST',
@@ -775,43 +775,43 @@ describe('protocol module', function() {
data: request.uploadData[0].bytes.toString()
},
session: null
- };
- callback(data);
- };
- protocol.interceptHttpProtocol('http', handler, function(error) {
+ }
+ callback(data)
+ }
+ protocol.interceptHttpProtocol('http', handler, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
$.ajax({
- url: "http://fake-host",
- type: "POST",
+ url: 'http://fake-host',
+ type: 'POST',
data: postData,
- success: function(data) {
- assert.deepEqual(qs.parse(data), postData);
- done();
+ success: function (data) {
+ assert.deepEqual(qs.parse(data), postData)
+ done()
},
- error: function(xhr, errorType, error) {
- done(error);
+ error: function (xhr, errorType, error) {
+ done(error)
}
- });
- });
- });
- });
- });
+ })
+ })
+ })
+ })
+ })
- describe('protocol.uninterceptProtocol', function() {
- it('returns error when scheme does not exist', function(done) {
- protocol.uninterceptProtocol('not-exist', function(error) {
- assert.notEqual(error, null);
- done();
- });
- });
+ describe('protocol.uninterceptProtocol', function () {
+ it('returns error when scheme does not exist', function (done) {
+ protocol.uninterceptProtocol('not-exist', function (error) {
+ assert.notEqual(error, null)
+ done()
+ })
+ })
- it('returns error when scheme is not intercepted', function(done) {
- protocol.uninterceptProtocol('http', function(error) {
- assert.notEqual(error, null);
- done();
- });
- });
- });
-});
+ it('returns error when scheme is not intercepted', function (done) {
+ protocol.uninterceptProtocol('http', function (error) {
+ assert.notEqual(error, null)
+ done()
+ })
+ })
+ })
+})
diff --git a/spec/api-screen-spec.js b/spec/api-screen-spec.js
index 34828e863e82..8c4f4305baff 100644
--- a/spec/api-screen-spec.js
+++ b/spec/api-screen-spec.js
@@ -1,21 +1,21 @@
-const assert = require('assert');
-const screen = require('electron').screen;
+const assert = require('assert')
+const screen = require('electron').screen
-describe('screen module', function() {
- describe('screen.getCursorScreenPoint()', function() {
- it('returns a point object', function() {
- var point = screen.getCursorScreenPoint();
- assert.equal(typeof point.x, 'number');
- assert.equal(typeof point.y, 'number');
- });
- });
+describe('screen module', function () {
+ describe('screen.getCursorScreenPoint()', function () {
+ it('returns a point object', function () {
+ var point = screen.getCursorScreenPoint()
+ assert.equal(typeof point.x, 'number')
+ assert.equal(typeof point.y, 'number')
+ })
+ })
- describe('screen.getPrimaryDisplay()', function() {
- it('returns a display object', function() {
- var display = screen.getPrimaryDisplay();
- assert.equal(typeof display.scaleFactor, 'number');
- assert(display.size.width > 0);
- assert(display.size.height > 0);
- });
- });
-});
+ describe('screen.getPrimaryDisplay()', function () {
+ it('returns a display object', function () {
+ var display = screen.getPrimaryDisplay()
+ assert.equal(typeof display.scaleFactor, 'number')
+ assert(display.size.width > 0)
+ assert(display.size.height > 0)
+ })
+ })
+})
diff --git a/spec/api-session-spec.js b/spec/api-session-spec.js
index 9fedcc29e779..2f4a50f69e5d 100644
--- a/spec/api-session-spec.js
+++ b/spec/api-session-spec.js
@@ -1,265 +1,265 @@
-const assert = require('assert');
-const http = require('http');
-const path = require('path');
-const fs = require('fs');
+const assert = require('assert')
+const http = require('http')
+const path = require('path')
+const fs = require('fs')
-const ipcRenderer = require('electron').ipcRenderer;
-const remote = require('electron').remote;
+const ipcRenderer = require('electron').ipcRenderer
+const remote = require('electron').remote
-const ipcMain = remote.ipcMain;
-const session = remote.session;
-const BrowserWindow = remote.BrowserWindow;
+const ipcMain = remote.ipcMain
+const session = remote.session
+const BrowserWindow = remote.BrowserWindow
-describe('session module', function() {
- this.timeout(10000);
+describe('session module', function () {
+ this.timeout(10000)
- var fixtures = path.resolve(__dirname, 'fixtures');
- var w = null;
- var url = "http://127.0.0.1";
+ var fixtures = path.resolve(__dirname, 'fixtures')
+ var w = null
+ var url = 'http://127.0.0.1'
- beforeEach(function() {
+ beforeEach(function () {
w = new BrowserWindow({
show: false,
width: 400,
height: 400
- });
- });
+ })
+ })
- afterEach(function() {
- w.destroy();
- });
+ afterEach(function () {
+ w.destroy()
+ })
- describe('session.cookies', function() {
- it('should get cookies', function(done) {
- var server = http.createServer(function(req, res) {
- res.setHeader('Set-Cookie', ['0=0']);
- res.end('finished');
- server.close();
- });
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- w.loadURL(url + ":" + port);
- w.webContents.on('did-finish-load', function() {
+ describe('session.cookies', function () {
+ it('should get cookies', function (done) {
+ var server = http.createServer(function (req, res) {
+ res.setHeader('Set-Cookie', ['0=0'])
+ res.end('finished')
+ server.close()
+ })
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ w.loadURL(url + ':' + port)
+ w.webContents.on('did-finish-load', function () {
w.webContents.session.cookies.get({
url: url
- }, function(error, list) {
- var cookie, i, len;
+ }, function (error, list) {
+ var cookie, i, len
if (error) {
- return done(error);
+ return done(error)
}
for (i = 0, len = list.length; i < len; i++) {
- cookie = list[i];
+ cookie = list[i]
if (cookie.name === '0') {
if (cookie.value === '0') {
- return done();
+ return done()
} else {
- return done("cookie value is " + cookie.value + " while expecting 0");
+ return done('cookie value is ' + cookie.value + ' while expecting 0')
}
}
}
- done('Can not find cookie');
- });
- });
- });
- });
+ done('Can not find cookie')
+ })
+ })
+ })
+ })
- it('should over-write the existent cookie', function(done) {
+ it('should over-write the existent cookie', function (done) {
session.defaultSession.cookies.set({
url: url,
name: '1',
value: '1'
- }, function(error) {
+ }, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
session.defaultSession.cookies.get({
url: url
- }, function(error, list) {
- var cookie, i, len;
+ }, function (error, list) {
+ var cookie, i, len
if (error) {
- return done(error);
+ return done(error)
}
for (i = 0, len = list.length; i < len; i++) {
- cookie = list[i];
+ cookie = list[i]
if (cookie.name === '1') {
if (cookie.value === '1') {
- return done();
+ return done()
} else {
- return done("cookie value is " + cookie.value + " while expecting 1");
+ return done('cookie value is ' + cookie.value + ' while expecting 1')
}
}
}
- done('Can not find cookie');
- });
- });
- });
+ done('Can not find cookie')
+ })
+ })
+ })
- it('should remove cookies', function(done) {
+ it('should remove cookies', function (done) {
session.defaultSession.cookies.set({
url: url,
name: '2',
value: '2'
- }, function(error) {
+ }, function (error) {
if (error) {
- return done(error);
+ return done(error)
}
- session.defaultSession.cookies.remove(url, '2', function() {
+ session.defaultSession.cookies.remove(url, '2', function () {
session.defaultSession.cookies.get({
url: url
- }, function(error, list) {
- var cookie, i, len;
+ }, function (error, list) {
+ var cookie, i, len
if (error) {
- return done(error);
+ return done(error)
}
for (i = 0, len = list.length; i < len; i++) {
- cookie = list[i];
+ cookie = list[i]
if (cookie.name === '2') {
- return done('Cookie not deleted');
+ return done('Cookie not deleted')
}
}
- done();
- });
- });
- });
- });
- });
+ done()
+ })
+ })
+ })
+ })
+ })
- describe('session.clearStorageData(options)', function() {
- fixtures = path.resolve(__dirname, 'fixtures');
- it('clears localstorage data', function(done) {
- ipcMain.on('count', function(event, count) {
- ipcMain.removeAllListeners('count');
- assert(!count);
- done();
- });
- w.loadURL('file://' + path.join(fixtures, 'api', 'localstorage.html'));
- w.webContents.on('did-finish-load', function() {
+ describe('session.clearStorageData(options)', function () {
+ fixtures = path.resolve(__dirname, 'fixtures')
+ it('clears localstorage data', function (done) {
+ ipcMain.on('count', function (event, count) {
+ ipcMain.removeAllListeners('count')
+ assert(!count)
+ done()
+ })
+ w.loadURL('file://' + path.join(fixtures, 'api', 'localstorage.html'))
+ w.webContents.on('did-finish-load', function () {
var options = {
- origin: "file://",
+ origin: 'file://',
storages: ['localstorage'],
quotas: ['persistent']
- };
- w.webContents.session.clearStorageData(options, function() {
- w.webContents.send('getcount');
- });
- });
- });
- });
+ }
+ w.webContents.session.clearStorageData(options, function () {
+ w.webContents.send('getcount')
+ })
+ })
+ })
+ })
- describe('session will-download event', function() {
- var w = null;
+ describe('session will-download event', function () {
+ var w = null
- beforeEach(function() {
+ beforeEach(function () {
w = new BrowserWindow({
show: false,
width: 400,
height: 400
- });
- });
+ })
+ })
- afterEach(function() {
- w.destroy();
- });
+ afterEach(function () {
+ w.destroy()
+ })
- it('can cancel default download behavior', function(done) {
- const mockFile = new Buffer(1024);
- const contentDisposition = 'inline; filename="mockFile.txt"';
- const downloadServer = http.createServer(function(req, res) {
+ it('can cancel default download behavior', function (done) {
+ const mockFile = new Buffer(1024)
+ const contentDisposition = 'inline; filename="mockFile.txt"'
+ const downloadServer = http.createServer(function (req, res) {
res.writeHead(200, {
'Content-Length': mockFile.length,
'Content-Type': 'application/plain',
'Content-Disposition': contentDisposition
- });
- res.end(mockFile);
- downloadServer.close();
- });
+ })
+ res.end(mockFile)
+ downloadServer.close()
+ })
- downloadServer.listen(0, '127.0.0.1', function() {
- const port = downloadServer.address().port;
- const url = "http://127.0.0.1:" + port + '/';
+ downloadServer.listen(0, '127.0.0.1', function () {
+ const port = downloadServer.address().port
+ const url = 'http://127.0.0.1:' + port + '/'
- ipcRenderer.sendSync('set-download-option', false, true);
- w.loadURL(url);
- ipcRenderer.once('download-error', function(event, downloadUrl, filename, error) {
- assert.equal(downloadUrl, url);
- assert.equal(filename, 'mockFile.txt');
- assert.equal(error, 'Object has been destroyed');
- done();
- });
- });
- });
- });
+ ipcRenderer.sendSync('set-download-option', false, true)
+ w.loadURL(url)
+ ipcRenderer.once('download-error', function (event, downloadUrl, filename, error) {
+ assert.equal(downloadUrl, url)
+ assert.equal(filename, 'mockFile.txt')
+ assert.equal(error, 'Object has been destroyed')
+ done()
+ })
+ })
+ })
+ })
- describe('DownloadItem', function() {
- var mockPDF = new Buffer(1024 * 1024 * 5);
- var contentDisposition = 'inline; filename="mock.pdf"';
- var downloadFilePath = path.join(fixtures, 'mock.pdf');
- var downloadServer = http.createServer(function(req, res) {
+ describe('DownloadItem', function () {
+ var mockPDF = new Buffer(1024 * 1024 * 5)
+ var contentDisposition = 'inline; filename="mock.pdf"'
+ var downloadFilePath = path.join(fixtures, 'mock.pdf')
+ var downloadServer = http.createServer(function (req, res) {
res.writeHead(200, {
'Content-Length': mockPDF.length,
'Content-Type': 'application/pdf',
'Content-Disposition': contentDisposition
- });
- res.end(mockPDF);
- downloadServer.close();
- });
- var assertDownload = function(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port) {
- assert.equal(state, 'completed');
- assert.equal(filename, 'mock.pdf');
- assert.equal(url, "http://127.0.0.1:" + port + "/");
- assert.equal(mimeType, 'application/pdf');
- assert.equal(receivedBytes, mockPDF.length);
- assert.equal(totalBytes, mockPDF.length);
- assert.equal(disposition, contentDisposition);
- assert(fs.existsSync(downloadFilePath));
- fs.unlinkSync(downloadFilePath);
- };
+ })
+ res.end(mockPDF)
+ downloadServer.close()
+ })
+ var assertDownload = function (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port) {
+ assert.equal(state, 'completed')
+ assert.equal(filename, 'mock.pdf')
+ assert.equal(url, 'http://127.0.0.1:' + port + '/')
+ assert.equal(mimeType, 'application/pdf')
+ assert.equal(receivedBytes, mockPDF.length)
+ assert.equal(totalBytes, mockPDF.length)
+ assert.equal(disposition, contentDisposition)
+ assert(fs.existsSync(downloadFilePath))
+ fs.unlinkSync(downloadFilePath)
+ }
- it('can download using BrowserWindow.loadURL', function(done) {
- downloadServer.listen(0, '127.0.0.1', function() {
- var port = downloadServer.address().port;
- ipcRenderer.sendSync('set-download-option', false, false);
- w.loadURL(url + ":" + port);
- ipcRenderer.once('download-done', function(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
- assertDownload(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port);
- done();
- });
- });
- });
+ it('can download using BrowserWindow.loadURL', function (done) {
+ downloadServer.listen(0, '127.0.0.1', function () {
+ var port = downloadServer.address().port
+ ipcRenderer.sendSync('set-download-option', false, false)
+ w.loadURL(url + ':' + port)
+ ipcRenderer.once('download-done', function (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
+ assertDownload(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port)
+ done()
+ })
+ })
+ })
- it('can download using WebView.downloadURL', function(done) {
- downloadServer.listen(0, '127.0.0.1', function() {
- var port = downloadServer.address().port;
- ipcRenderer.sendSync('set-download-option', false, false);
- var webview = new WebView;
- webview.src = "file://" + fixtures + "/api/blank.html";
- webview.addEventListener('did-finish-load', function() {
- webview.downloadURL(url + ":" + port + "/");
- });
- ipcRenderer.once('download-done', function(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
- assertDownload(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port);
- document.body.removeChild(webview);
- done();
- });
- document.body.appendChild(webview);
- });
- });
+ it('can download using WebView.downloadURL', function (done) {
+ downloadServer.listen(0, '127.0.0.1', function () {
+ var port = downloadServer.address().port
+ ipcRenderer.sendSync('set-download-option', false, false)
+ var webview = new WebView
+ webview.src = 'file://' + fixtures + '/api/blank.html'
+ webview.addEventListener('did-finish-load', function () {
+ webview.downloadURL(url + ':' + port + '/')
+ })
+ ipcRenderer.once('download-done', function (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
+ assertDownload(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename, port)
+ document.body.removeChild(webview)
+ done()
+ })
+ document.body.appendChild(webview)
+ })
+ })
- it('can cancel download', function(done) {
- downloadServer.listen(0, '127.0.0.1', function() {
- var port = downloadServer.address().port;
- ipcRenderer.sendSync('set-download-option', true, false);
- w.loadURL(url + ":" + port + "/");
- ipcRenderer.once('download-done', function(event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
- assert.equal(state, 'cancelled');
- assert.equal(filename, 'mock.pdf');
- assert.equal(mimeType, 'application/pdf');
- assert.equal(receivedBytes, 0);
- assert.equal(totalBytes, mockPDF.length);
- assert.equal(disposition, contentDisposition);
- done();
- });
- });
- });
- });
-});
+ it('can cancel download', function (done) {
+ downloadServer.listen(0, '127.0.0.1', function () {
+ var port = downloadServer.address().port
+ ipcRenderer.sendSync('set-download-option', true, false)
+ w.loadURL(url + ':' + port + '/')
+ ipcRenderer.once('download-done', function (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
+ assert.equal(state, 'cancelled')
+ assert.equal(filename, 'mock.pdf')
+ assert.equal(mimeType, 'application/pdf')
+ assert.equal(receivedBytes, 0)
+ assert.equal(totalBytes, mockPDF.length)
+ assert.equal(disposition, contentDisposition)
+ done()
+ })
+ })
+ })
+ })
+})
diff --git a/spec/api-web-frame-spec.js b/spec/api-web-frame-spec.js
index 15f31aa8f095..519966c8cea8 100644
--- a/spec/api-web-frame-spec.js
+++ b/spec/api-web-frame-spec.js
@@ -1,19 +1,19 @@
-const assert = require('assert');
-const path = require('path');
-const webFrame = require('electron').webFrame;
+const assert = require('assert')
+const path = require('path')
+const webFrame = require('electron').webFrame
-describe('webFrame module', function() {
- var fixtures = path.resolve(__dirname, 'fixtures');
- describe('webFrame.registerURLSchemeAsPrivileged', function() {
- it('supports fetch api', function(done) {
- webFrame.registerURLSchemeAsPrivileged('file');
- var url = "file://" + fixtures + "/assets/logo.png";
- fetch(url).then(function(response) {
- assert(response.ok);
- done();
- }).catch(function(err) {
- done('unexpected error : ' + err);
- });
- });
- });
-});
+describe('webFrame module', function () {
+ var fixtures = path.resolve(__dirname, 'fixtures')
+ describe('webFrame.registerURLSchemeAsPrivileged', function () {
+ it('supports fetch api', function (done) {
+ webFrame.registerURLSchemeAsPrivileged('file')
+ var url = 'file://' + fixtures + '/assets/logo.png'
+ fetch(url).then(function (response) {
+ assert(response.ok)
+ done()
+ }).catch(function (err) {
+ done('unexpected error : ' + err)
+ })
+ })
+ })
+})
diff --git a/spec/api-web-request-spec.js b/spec/api-web-request-spec.js
index 77f160a20041..abc4f9568cd3 100644
--- a/spec/api-web-request-spec.js
+++ b/spec/api-web-request-spec.js
@@ -1,413 +1,412 @@
-const assert = require('assert');
-const http = require('http');
-const qs = require('querystring');
-const remote = require('electron').remote;
-const session = remote.session;
+const assert = require('assert')
+const http = require('http')
+const qs = require('querystring')
+const remote = require('electron').remote
+const session = remote.session
-describe('webRequest module', function() {
- var ses = session.defaultSession;
- var server = http.createServer(function(req, res) {
- res.setHeader('Custom', ['Header']);
- var content = req.url;
+describe('webRequest module', function () {
+ var ses = session.defaultSession
+ var server = http.createServer(function (req, res) {
+ res.setHeader('Custom', ['Header'])
+ var content = req.url
if (req.headers.accept === '*/*;test/header') {
- content += 'header/received';
+ content += 'header/received'
}
- res.end(content);
- });
- var defaultURL = null;
+ res.end(content)
+ })
+ var defaultURL = null
- before(function(done) {
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- defaultURL = "http://127.0.0.1:" + port + "/";
- done();
- });
- });
+ before(function (done) {
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ defaultURL = 'http://127.0.0.1:' + port + '/'
+ done()
+ })
+ })
- after(function() {
- server.close();
- });
+ after(function () {
+ server.close()
+ })
- describe('webRequest.onBeforeRequest', function() {
- afterEach(function() {
- ses.webRequest.onBeforeRequest(null);
- });
+ describe('webRequest.onBeforeRequest', function () {
+ afterEach(function () {
+ ses.webRequest.onBeforeRequest(null)
+ })
- it('can cancel the request', function(done) {
- ses.webRequest.onBeforeRequest(function(details, callback) {
+ it('can cancel the request', function (done) {
+ ses.webRequest.onBeforeRequest(function (details, callback) {
callback({
cancel: true
- });
- });
+ })
+ })
$.ajax({
url: defaultURL,
- success: function() {
- done('unexpected success');
+ success: function () {
+ done('unexpected success')
},
- error: function() {
- done();
+ error: function () {
+ done()
}
- });
- });
+ })
+ })
- it('can filter URLs', function(done) {
+ it('can filter URLs', function (done) {
var filter = {
- urls: [defaultURL + "filter/*"]
- };
- ses.webRequest.onBeforeRequest(filter, function(details, callback) {
+ urls: [defaultURL + 'filter/*']
+ }
+ ses.webRequest.onBeforeRequest(filter, function (details, callback) {
callback({
cancel: true
- });
- });
+ })
+ })
$.ajax({
- url: defaultURL + "nofilter/test",
- success: function(data) {
- assert.equal(data, '/nofilter/test');
+ url: defaultURL + 'nofilter/test',
+ success: function (data) {
+ assert.equal(data, '/nofilter/test')
$.ajax({
- url: defaultURL + "filter/test",
- success: function() {
- done('unexpected success');
+ url: defaultURL + 'filter/test',
+ success: function () {
+ done('unexpected success')
},
- error: function() {
- done();
+ error: function () {
+ done()
}
- });
+ })
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
+ })
+ })
- it('receives details object', function(done) {
- ses.webRequest.onBeforeRequest(function(details, callback) {
- assert.equal(typeof details.id, 'number');
- assert.equal(typeof details.timestamp, 'number');
- assert.equal(details.url, defaultURL);
- assert.equal(details.method, 'GET');
- assert.equal(details.resourceType, 'xhr');
- assert(!details.uploadData);
- callback({});
- });
+ it('receives details object', function (done) {
+ ses.webRequest.onBeforeRequest(function (details, callback) {
+ assert.equal(typeof details.id, 'number')
+ assert.equal(typeof details.timestamp, 'number')
+ assert.equal(details.url, defaultURL)
+ assert.equal(details.method, 'GET')
+ assert.equal(details.resourceType, 'xhr')
+ assert(!details.uploadData)
+ callback({})
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/');
- done();
+ success: function (data) {
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
+ })
+ })
- it('receives post data in details object', function(done) {
+ it('receives post data in details object', function (done) {
var postData = {
name: 'post test',
type: 'string'
- };
- ses.webRequest.onBeforeRequest(function(details, callback) {
- assert.equal(details.url, defaultURL);
- assert.equal(details.method, 'POST');
- assert.equal(details.uploadData.length, 1);
- var data = qs.parse(details.uploadData[0].bytes.toString());
- assert.deepEqual(data, postData);
+ }
+ ses.webRequest.onBeforeRequest(function (details, callback) {
+ assert.equal(details.url, defaultURL)
+ assert.equal(details.method, 'POST')
+ assert.equal(details.uploadData.length, 1)
+ var data = qs.parse(details.uploadData[0].bytes.toString())
+ assert.deepEqual(data, postData)
callback({
cancel: true
- });
- });
+ })
+ })
$.ajax({
url: defaultURL,
type: 'POST',
data: postData,
- success: function() {
- },
- error: function() {
- done();
+ success: function () {},
+ error: function () {
+ done()
}
- });
- });
+ })
+ })
- it('can redirect the request', function(done) {
- ses.webRequest.onBeforeRequest(function(details, callback) {
+ it('can redirect the request', function (done) {
+ ses.webRequest.onBeforeRequest(function (details, callback) {
if (details.url === defaultURL) {
callback({
- redirectURL: defaultURL + "redirect"
- });
+ redirectURL: defaultURL + 'redirect'
+ })
} else {
- callback({});
+ callback({})
}
- });
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/redirect');
- done();
+ success: function (data) {
+ assert.equal(data, '/redirect')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onBeforeSendHeaders', function() {
- afterEach(function() {
- ses.webRequest.onBeforeSendHeaders(null);
- });
+ describe('webRequest.onBeforeSendHeaders', function () {
+ afterEach(function () {
+ ses.webRequest.onBeforeSendHeaders(null)
+ })
- it('receives details object', function(done) {
- ses.webRequest.onBeforeSendHeaders(function(details, callback) {
- assert.equal(typeof details.requestHeaders, 'object');
- callback({});
- });
+ it('receives details object', function (done) {
+ ses.webRequest.onBeforeSendHeaders(function (details, callback) {
+ assert.equal(typeof details.requestHeaders, 'object')
+ callback({})
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/');
- done();
+ success: function (data) {
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
+ })
+ })
- it('can change the request headers', function(done) {
- ses.webRequest.onBeforeSendHeaders(function(details, callback) {
- var requestHeaders = details.requestHeaders;
- requestHeaders.Accept = '*/*;test/header';
+ it('can change the request headers', function (done) {
+ ses.webRequest.onBeforeSendHeaders(function (details, callback) {
+ var requestHeaders = details.requestHeaders
+ requestHeaders.Accept = '*/*;test/header'
callback({
requestHeaders: requestHeaders
- });
- });
+ })
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/header/received');
- done();
+ success: function (data) {
+ assert.equal(data, '/header/received')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
+ })
+ })
- it('resets the whole headers', function(done) {
+ it('resets the whole headers', function (done) {
var requestHeaders = {
Test: 'header'
- };
- ses.webRequest.onBeforeSendHeaders(function(details, callback) {
+ }
+ ses.webRequest.onBeforeSendHeaders(function (details, callback) {
callback({
requestHeaders: requestHeaders
- });
- });
- ses.webRequest.onSendHeaders(function(details) {
- assert.deepEqual(details.requestHeaders, requestHeaders);
- done();
- });
+ })
+ })
+ ses.webRequest.onSendHeaders(function (details) {
+ assert.deepEqual(details.requestHeaders, requestHeaders)
+ done()
+ })
$.ajax({
url: defaultURL,
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onSendHeaders', function() {
- afterEach(function() {
- ses.webRequest.onSendHeaders(null);
- });
+ describe('webRequest.onSendHeaders', function () {
+ afterEach(function () {
+ ses.webRequest.onSendHeaders(null)
+ })
- it('receives details object', function(done) {
- ses.webRequest.onSendHeaders(function(details) {
- assert.equal(typeof details.requestHeaders, 'object');
- });
+ it('receives details object', function (done) {
+ ses.webRequest.onSendHeaders(function (details) {
+ assert.equal(typeof details.requestHeaders, 'object')
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/');
- done();
+ success: function (data) {
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onHeadersReceived', function() {
- afterEach(function() {
- ses.webRequest.onHeadersReceived(null);
- });
+ describe('webRequest.onHeadersReceived', function () {
+ afterEach(function () {
+ 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');
- assert.equal(details.statusCode, 200);
- assert.equal(details.responseHeaders['Custom'], 'Header');
- callback({});
- });
+ it('receives details object', function (done) {
+ ses.webRequest.onHeadersReceived(function (details, callback) {
+ assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
+ assert.equal(details.statusCode, 200)
+ assert.equal(details.responseHeaders['Custom'], 'Header')
+ callback({})
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/');
- done();
+ success: function (data) {
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
+ })
+ })
- it('can change the response header', function(done) {
- ses.webRequest.onHeadersReceived(function(details, callback) {
- var responseHeaders = details.responseHeaders;
- responseHeaders['Custom'] = ['Changed'];
+ it('can change the response header', function (done) {
+ ses.webRequest.onHeadersReceived(function (details, callback) {
+ var responseHeaders = details.responseHeaders
+ responseHeaders['Custom'] = ['Changed']
callback({
responseHeaders: responseHeaders
- });
- });
+ })
+ })
$.ajax({
url: defaultURL,
- success: function(data, status, xhr) {
- assert.equal(xhr.getResponseHeader('Custom'), 'Changed');
- assert.equal(data, '/');
- done();
+ success: function (data, status, xhr) {
+ assert.equal(xhr.getResponseHeader('Custom'), 'Changed')
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
+ })
+ })
- it('does not change header by default', function(done) {
- ses.webRequest.onHeadersReceived(function(details, callback) {
- callback({});
- });
+ it('does not change header by default', function (done) {
+ ses.webRequest.onHeadersReceived(function (details, callback) {
+ callback({})
+ })
$.ajax({
url: defaultURL,
- success: function(data, status, xhr) {
- assert.equal(xhr.getResponseHeader('Custom'), 'Header');
- assert.equal(data, '/');
- done();
+ success: function (data, status, xhr) {
+ assert.equal(xhr.getResponseHeader('Custom'), 'Header')
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onResponseStarted', function() {
- afterEach(function() {
- ses.webRequest.onResponseStarted(null);
- });
+ describe('webRequest.onResponseStarted', function () {
+ afterEach(function () {
+ ses.webRequest.onResponseStarted(null)
+ })
- it('receives details object', function(done) {
- ses.webRequest.onResponseStarted(function(details) {
- assert.equal(typeof details.fromCache, 'boolean');
- assert.equal(details.statusLine, 'HTTP/1.1 200 OK');
- assert.equal(details.statusCode, 200);
- assert.equal(details.responseHeaders['Custom'], 'Header');
- });
+ it('receives details object', function (done) {
+ ses.webRequest.onResponseStarted(function (details) {
+ assert.equal(typeof details.fromCache, 'boolean')
+ assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
+ assert.equal(details.statusCode, 200)
+ assert.equal(details.responseHeaders['Custom'], 'Header')
+ })
$.ajax({
url: defaultURL,
- success: function(data, status, xhr) {
- assert.equal(xhr.getResponseHeader('Custom'), 'Header');
- assert.equal(data, '/');
- done();
+ success: function (data, status, xhr) {
+ assert.equal(xhr.getResponseHeader('Custom'), 'Header')
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onBeforeRedirect', function() {
- afterEach(function() {
- ses.webRequest.onBeforeRedirect(null);
- ses.webRequest.onBeforeRequest(null);
- });
+ describe('webRequest.onBeforeRedirect', function () {
+ afterEach(function () {
+ ses.webRequest.onBeforeRedirect(null)
+ ses.webRequest.onBeforeRequest(null)
+ })
- it('receives details object', function(done) {
- var redirectURL = defaultURL + "redirect";
- ses.webRequest.onBeforeRequest(function(details, callback) {
+ it('receives details object', function (done) {
+ var redirectURL = defaultURL + 'redirect'
+ ses.webRequest.onBeforeRequest(function (details, callback) {
if (details.url === defaultURL) {
callback({
redirectURL: redirectURL
- });
+ })
} else {
- callback({});
+ callback({})
}
- });
- ses.webRequest.onBeforeRedirect(function(details) {
- assert.equal(typeof details.fromCache, 'boolean');
- assert.equal(details.statusLine, 'HTTP/1.1 307 Internal Redirect');
- assert.equal(details.statusCode, 307);
- assert.equal(details.redirectURL, redirectURL);
- });
+ })
+ ses.webRequest.onBeforeRedirect(function (details) {
+ assert.equal(typeof details.fromCache, 'boolean')
+ assert.equal(details.statusLine, 'HTTP/1.1 307 Internal Redirect')
+ assert.equal(details.statusCode, 307)
+ assert.equal(details.redirectURL, redirectURL)
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/redirect');
- done();
+ success: function (data) {
+ assert.equal(data, '/redirect')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onCompleted', function() {
- afterEach(function() {
- ses.webRequest.onCompleted(null);
- });
+ describe('webRequest.onCompleted', function () {
+ afterEach(function () {
+ ses.webRequest.onCompleted(null)
+ })
- it('receives details object', function(done) {
- ses.webRequest.onCompleted(function(details) {
- assert.equal(typeof details.fromCache, 'boolean');
- assert.equal(details.statusLine, 'HTTP/1.1 200 OK');
- assert.equal(details.statusCode, 200);
- });
+ it('receives details object', function (done) {
+ ses.webRequest.onCompleted(function (details) {
+ assert.equal(typeof details.fromCache, 'boolean')
+ assert.equal(details.statusLine, 'HTTP/1.1 200 OK')
+ assert.equal(details.statusCode, 200)
+ })
$.ajax({
url: defaultURL,
- success: function(data) {
- assert.equal(data, '/');
- done();
+ success: function (data) {
+ assert.equal(data, '/')
+ done()
},
- error: function(xhr, errorType) {
- done(errorType);
+ error: function (xhr, errorType) {
+ done(errorType)
}
- });
- });
- });
+ })
+ })
+ })
- describe('webRequest.onErrorOccurred', function() {
- afterEach(function() {
- ses.webRequest.onErrorOccurred(null);
- ses.webRequest.onBeforeRequest(null);
- });
+ describe('webRequest.onErrorOccurred', function () {
+ afterEach(function () {
+ ses.webRequest.onErrorOccurred(null)
+ ses.webRequest.onBeforeRequest(null)
+ })
- it('receives details object', function(done) {
- ses.webRequest.onBeforeRequest(function(details, callback) {
+ it('receives details object', function (done) {
+ ses.webRequest.onBeforeRequest(function (details, callback) {
callback({
cancel: true
- });
- });
- ses.webRequest.onErrorOccurred(function(details) {
- assert.equal(details.error, 'net::ERR_BLOCKED_BY_CLIENT');
- done();
- });
+ })
+ })
+ ses.webRequest.onErrorOccurred(function (details) {
+ assert.equal(details.error, 'net::ERR_BLOCKED_BY_CLIENT')
+ done()
+ })
$.ajax({
url: defaultURL,
- success: function() {
- done('unexpected success');
+ success: function () {
+ done('unexpected success')
}
- });
- });
- });
-});
+ })
+ })
+ })
+})
diff --git a/spec/asar-spec.js b/spec/asar-spec.js
index 0e0a7f89f178..050d8d7dedad 100644
--- a/spec/asar-spec.js
+++ b/spec/asar-spec.js
@@ -1,813 +1,813 @@
-const assert = require('assert');
-const child_process = require('child_process');
-const fs = require('fs');
-const path = require('path');
+const assert = require('assert')
+const child_process = require('child_process')
+const fs = require('fs')
+const path = require('path')
-const nativeImage = require('electron').nativeImage;
-const remote = require('electron').remote;
+const nativeImage = require('electron').nativeImage
+const remote = require('electron').remote
-const ipcMain = remote.require('electron').ipcMain;
-const BrowserWindow = remote.require('electron').BrowserWindow;
+const ipcMain = remote.require('electron').ipcMain
+const BrowserWindow = remote.require('electron').BrowserWindow
-describe('asar package', function() {
- var fixtures = path.join(__dirname, 'fixtures');
+describe('asar package', function () {
+ var fixtures = path.join(__dirname, 'fixtures')
- describe('node api', function() {
- describe('fs.readFileSync', function() {
- it('does not leak fd', function() {
- var readCalls = 1;
+ describe('node api', function () {
+ describe('fs.readFileSync', function () {
+ it('does not leak fd', function () {
+ var readCalls = 1
while(readCalls <= 10000) {
- fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'ipc.js'));
- readCalls++;
+ fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'ipc.js'))
+ readCalls++
}
- });
+ })
- it('reads a normal file', function() {
- var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1');
- assert.equal(fs.readFileSync(file1).toString().trim(), 'file1');
- var file2 = path.join(fixtures, 'asar', 'a.asar', 'file2');
- assert.equal(fs.readFileSync(file2).toString().trim(), 'file2');
- var file3 = path.join(fixtures, 'asar', 'a.asar', 'file3');
- assert.equal(fs.readFileSync(file3).toString().trim(), 'file3');
- });
+ it('reads a normal file', function () {
+ var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1')
+ assert.equal(fs.readFileSync(file1).toString().trim(), 'file1')
+ var file2 = path.join(fixtures, 'asar', 'a.asar', 'file2')
+ assert.equal(fs.readFileSync(file2).toString().trim(), 'file2')
+ var file3 = path.join(fixtures, 'asar', 'a.asar', 'file3')
+ assert.equal(fs.readFileSync(file3).toString().trim(), 'file3')
+ })
- it('reads from a empty file', function() {
- var file = path.join(fixtures, 'asar', 'empty.asar', 'file1');
- var buffer = fs.readFileSync(file);
- assert.equal(buffer.length, 0);
- assert.equal(buffer.toString(), '');
- });
+ it('reads from a empty file', function () {
+ var file = path.join(fixtures, 'asar', 'empty.asar', 'file1')
+ var buffer = fs.readFileSync(file)
+ assert.equal(buffer.length, 0)
+ assert.equal(buffer.toString(), '')
+ })
- it('reads a linked file', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link1');
- assert.equal(fs.readFileSync(p).toString().trim(), 'file1');
- });
+ it('reads a linked file', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
+ assert.equal(fs.readFileSync(p).toString().trim(), 'file1')
+ })
- it('reads a file from linked directory', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1');
- assert.equal(fs.readFileSync(p).toString().trim(), 'file1');
- p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
- assert.equal(fs.readFileSync(p).toString().trim(), 'file1');
- });
+ it('reads a file from linked directory', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'file1')
+ assert.equal(fs.readFileSync(p).toString().trim(), 'file1')
+ p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
+ assert.equal(fs.readFileSync(p).toString().trim(), 'file1')
+ })
- it('throws ENOENT error when can not find file', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- var throws = function() {
- fs.readFileSync(p);
- };
- assert.throws(throws, /ENOENT/);
- });
+ it('throws ENOENT error when can not find file', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ var throws = function () {
+ fs.readFileSync(p)
+ }
+ assert.throws(throws, /ENOENT/)
+ })
- it('passes ENOENT error to callback when can not find file', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- var async = false;
- fs.readFile(p, function(e) {
- assert(async);
- assert(/ENOENT/.test(e));
- });
- async = true;
- });
+ it('passes ENOENT error to callback when can not find file', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ var async = false
+ fs.readFile(p, function (e) {
+ assert(async)
+ assert(/ENOENT/.test(e))
+ })
+ async = true
+ })
- it('reads a normal file with unpacked files', function() {
- var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt');
- assert.equal(fs.readFileSync(p).toString().trim(), 'a');
- });
- });
+ it('reads a normal file with unpacked files', function () {
+ var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
+ assert.equal(fs.readFileSync(p).toString().trim(), 'a')
+ })
+ })
- describe('fs.readFile', function() {
- it('reads a normal file', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'file1');
- fs.readFile(p, function(err, content) {
- assert.equal(err, null);
- assert.equal(String(content).trim(), 'file1');
- done();
- });
- });
+ describe('fs.readFile', function () {
+ it('reads a normal file', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
+ fs.readFile(p, function (err, content) {
+ assert.equal(err, null)
+ assert.equal(String(content).trim(), 'file1')
+ done()
+ })
+ })
- it('reads from a empty file', function(done) {
- var p = path.join(fixtures, 'asar', 'empty.asar', 'file1');
- fs.readFile(p, function(err, content) {
- assert.equal(err, null);
- assert.equal(String(content), '');
- done();
- });
- });
+ it('reads from a empty file', function (done) {
+ var p = path.join(fixtures, 'asar', 'empty.asar', 'file1')
+ fs.readFile(p, function (err, content) {
+ assert.equal(err, null)
+ assert.equal(String(content), '')
+ done()
+ })
+ })
- it('reads a linked file', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link1');
- fs.readFile(p, function(err, content) {
- assert.equal(err, null);
- assert.equal(String(content).trim(), 'file1');
- done();
- });
- });
+ it('reads a linked file', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
+ fs.readFile(p, function (err, content) {
+ assert.equal(err, null)
+ assert.equal(String(content).trim(), 'file1')
+ done()
+ })
+ })
- it('reads a file from linked directory', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
- fs.readFile(p, function(err, content) {
- assert.equal(err, null);
- assert.equal(String(content).trim(), 'file1');
- done();
- });
- });
+ it('reads a file from linked directory', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
+ fs.readFile(p, function (err, content) {
+ assert.equal(err, null)
+ assert.equal(String(content).trim(), 'file1')
+ done()
+ })
+ })
- it('throws ENOENT error when can not find file', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- fs.readFile(p, function(err) {
- assert.equal(err.code, 'ENOENT');
- done();
- });
- });
- });
+ it('throws ENOENT error when can not find file', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ fs.readFile(p, function (err) {
+ assert.equal(err.code, 'ENOENT')
+ done()
+ })
+ })
+ })
- describe('fs.lstatSync', function() {
- it('handles path with trailing slash correctly', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
- fs.lstatSync(p);
- fs.lstatSync(p + '/');
- });
+ describe('fs.lstatSync', function () {
+ it('handles path with trailing slash correctly', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
+ fs.lstatSync(p)
+ fs.lstatSync(p + '/')
+ })
- it('returns information of root', function() {
- var p = path.join(fixtures, 'asar', 'a.asar');
- var stats = fs.lstatSync(p);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), true);
- assert.equal(stats.isSymbolicLink(), false);
- assert.equal(stats.size, 0);
- });
+ it('returns information of root', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar')
+ var stats = fs.lstatSync(p)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), true)
+ assert.equal(stats.isSymbolicLink(), false)
+ assert.equal(stats.size, 0)
+ })
- it('returns information of a normal file', function() {
- var file, j, len, p, ref2, stats;
- ref2 = ['file1', 'file2', 'file3', path.join('dir1', 'file1'), path.join('link2', 'file1')];
+ it('returns information of a normal file', function () {
+ var file, j, len, p, ref2, stats
+ ref2 = ['file1', 'file2', 'file3', path.join('dir1', 'file1'), path.join('link2', 'file1')]
for (j = 0, len = ref2.length; j < len; j++) {
- file = ref2[j];
- p = path.join(fixtures, 'asar', 'a.asar', file);
- stats = fs.lstatSync(p);
- assert.equal(stats.isFile(), true);
- assert.equal(stats.isDirectory(), false);
- assert.equal(stats.isSymbolicLink(), false);
- assert.equal(stats.size, 6);
+ file = ref2[j]
+ p = path.join(fixtures, 'asar', 'a.asar', file)
+ stats = fs.lstatSync(p)
+ assert.equal(stats.isFile(), true)
+ assert.equal(stats.isDirectory(), false)
+ assert.equal(stats.isSymbolicLink(), false)
+ assert.equal(stats.size, 6)
}
- });
+ })
- it('returns information of a normal directory', function() {
- var file, j, len, p, ref2, stats;
- ref2 = ['dir1', 'dir2', 'dir3'];
+ it('returns information of a normal directory', function () {
+ var file, j, len, p, ref2, stats
+ ref2 = ['dir1', 'dir2', 'dir3']
for (j = 0, len = ref2.length; j < len; j++) {
- file = ref2[j];
- p = path.join(fixtures, 'asar', 'a.asar', file);
- stats = fs.lstatSync(p);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), true);
- assert.equal(stats.isSymbolicLink(), false);
- assert.equal(stats.size, 0);
+ file = ref2[j]
+ p = path.join(fixtures, 'asar', 'a.asar', file)
+ stats = fs.lstatSync(p)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), true)
+ assert.equal(stats.isSymbolicLink(), false)
+ assert.equal(stats.size, 0)
}
- });
+ })
- it('returns information of a linked file', function() {
- var file, j, len, p, ref2, stats;
- ref2 = ['link1', path.join('dir1', 'link1'), path.join('link2', 'link2')];
+ it('returns information of a linked file', function () {
+ var file, j, len, p, ref2, stats
+ ref2 = ['link1', path.join('dir1', 'link1'), path.join('link2', 'link2')]
for (j = 0, len = ref2.length; j < len; j++) {
- file = ref2[j];
- p = path.join(fixtures, 'asar', 'a.asar', file);
- stats = fs.lstatSync(p);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), false);
- assert.equal(stats.isSymbolicLink(), true);
- assert.equal(stats.size, 0);
+ file = ref2[j]
+ p = path.join(fixtures, 'asar', 'a.asar', file)
+ stats = fs.lstatSync(p)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), false)
+ assert.equal(stats.isSymbolicLink(), true)
+ assert.equal(stats.size, 0)
}
- });
+ })
- it('returns information of a linked directory', function() {
- var file, j, len, p, ref2, stats;
- ref2 = ['link2', path.join('dir1', 'link2'), path.join('link2', 'link2')];
+ it('returns information of a linked directory', function () {
+ var file, j, len, p, ref2, stats
+ ref2 = ['link2', path.join('dir1', 'link2'), path.join('link2', 'link2')]
for (j = 0, len = ref2.length; j < len; j++) {
- file = ref2[j];
- p = path.join(fixtures, 'asar', 'a.asar', file);
- stats = fs.lstatSync(p);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), false);
- assert.equal(stats.isSymbolicLink(), true);
- assert.equal(stats.size, 0);
+ file = ref2[j]
+ p = path.join(fixtures, 'asar', 'a.asar', file)
+ stats = fs.lstatSync(p)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), false)
+ assert.equal(stats.isSymbolicLink(), true)
+ assert.equal(stats.size, 0)
}
- });
+ })
- it('throws ENOENT error when can not find file', function() {
- var file, j, len, p, ref2, throws;
- ref2 = ['file4', 'file5', path.join('dir1', 'file4')];
+ it('throws ENOENT error when can not find file', function () {
+ var file, j, len, p, ref2, throws
+ ref2 = ['file4', 'file5', path.join('dir1', 'file4')]
for (j = 0, len = ref2.length; j < len; j++) {
- file = ref2[j];
- p = path.join(fixtures, 'asar', 'a.asar', file);
- throws = function() {
- fs.lstatSync(p);
- };
- assert.throws(throws, /ENOENT/);
+ file = ref2[j]
+ p = path.join(fixtures, 'asar', 'a.asar', file)
+ throws = function () {
+ fs.lstatSync(p)
+ }
+ assert.throws(throws, /ENOENT/)
}
- });
- });
+ })
+ })
- describe('fs.lstat', function() {
- it('handles path with trailing slash correctly', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1');
- fs.lstat(p + '/', done);
- });
+ describe('fs.lstat', function () {
+ it('handles path with trailing slash correctly', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1')
+ 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) {
- assert.equal(err, null);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), true);
- assert.equal(stats.isSymbolicLink(), false);
- assert.equal(stats.size, 0);
- done();
- });
- });
+ it('returns information of root', function (done) {
+ 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)
+ assert.equal(stats.isSymbolicLink(), false)
+ assert.equal(stats.size, 0)
+ 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) {
- assert.equal(err, null);
- assert.equal(stats.isFile(), true);
- assert.equal(stats.isDirectory(), false);
- assert.equal(stats.isSymbolicLink(), false);
- assert.equal(stats.size, 6);
- 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) {
+ assert.equal(err, null)
+ assert.equal(stats.isFile(), true)
+ assert.equal(stats.isDirectory(), false)
+ assert.equal(stats.isSymbolicLink(), false)
+ assert.equal(stats.size, 6)
+ 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) {
- assert.equal(err, null);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), true);
- assert.equal(stats.isSymbolicLink(), false);
- assert.equal(stats.size, 0);
- 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) {
+ assert.equal(err, null)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), true)
+ assert.equal(stats.isSymbolicLink(), false)
+ assert.equal(stats.size, 0)
+ 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) {
- assert.equal(err, null);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), false);
- assert.equal(stats.isSymbolicLink(), true);
- assert.equal(stats.size, 0);
- 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) {
+ assert.equal(err, null)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), false)
+ assert.equal(stats.isSymbolicLink(), true)
+ assert.equal(stats.size, 0)
+ 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) {
- assert.equal(err, null);
- assert.equal(stats.isFile(), false);
- assert.equal(stats.isDirectory(), false);
- assert.equal(stats.isSymbolicLink(), true);
- assert.equal(stats.size, 0);
- 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) {
+ assert.equal(err, null)
+ assert.equal(stats.isFile(), false)
+ assert.equal(stats.isDirectory(), false)
+ assert.equal(stats.isSymbolicLink(), true)
+ assert.equal(stats.size, 0)
+ done()
+ })
+ })
- 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) {
- assert.equal(err.code, 'ENOENT');
- done();
- });
- });
- });
+ 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) {
+ assert.equal(err.code, 'ENOENT')
+ done()
+ })
+ })
+ })
- describe('fs.realpathSync', function() {
- it('returns real path root', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = 'a.asar';
- var r = fs.realpathSync(path.join(parent, p));
- assert.equal(r, path.join(parent, p));
- });
+ describe('fs.realpathSync', function () {
+ it('returns real path root', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = 'a.asar'
+ var r = fs.realpathSync(path.join(parent, p))
+ assert.equal(r, path.join(parent, p))
+ })
- it('returns real path of a normal file', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'file1');
- var r = fs.realpathSync(path.join(parent, p));
- assert.equal(r, path.join(parent, p));
- });
+ it('returns real path of a normal file', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'file1')
+ var r = fs.realpathSync(path.join(parent, p))
+ assert.equal(r, path.join(parent, p))
+ })
- it('returns real path of a normal directory', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'dir1');
- var r = fs.realpathSync(path.join(parent, p));
- assert.equal(r, path.join(parent, p));
- });
+ it('returns real path of a normal directory', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'dir1')
+ var r = fs.realpathSync(path.join(parent, p))
+ assert.equal(r, path.join(parent, p))
+ })
- it('returns real path of a linked file', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'link2', 'link1');
- var r = fs.realpathSync(path.join(parent, p));
- assert.equal(r, path.join(parent, 'a.asar', 'file1'));
- });
+ it('returns real path of a linked file', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'link2', 'link1')
+ var r = fs.realpathSync(path.join(parent, p))
+ assert.equal(r, path.join(parent, 'a.asar', 'file1'))
+ })
- it('returns real path of a linked directory', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'link2', 'link2');
- var r = fs.realpathSync(path.join(parent, p));
- assert.equal(r, path.join(parent, 'a.asar', 'dir1'));
- });
+ it('returns real path of a linked directory', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'link2', 'link2')
+ var r = fs.realpathSync(path.join(parent, p))
+ assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
+ })
- it('returns real path of an unpacked file', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('unpack.asar', 'a.txt');
- var r = fs.realpathSync(path.join(parent, p));
- assert.equal(r, path.join(parent, p));
- });
+ it('returns real path of an unpacked file', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('unpack.asar', 'a.txt')
+ var r = fs.realpathSync(path.join(parent, p))
+ assert.equal(r, path.join(parent, p))
+ })
- it('throws ENOENT error when can not find file', function() {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'not-exist');
- var throws = function() {
- fs.realpathSync(path.join(parent, p));
- };
- assert.throws(throws, /ENOENT/);
- });
- });
+ it('throws ENOENT error when can not find file', function () {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'not-exist')
+ var throws = function () {
+ fs.realpathSync(path.join(parent, p))
+ }
+ assert.throws(throws, /ENOENT/)
+ })
+ })
- describe('fs.realpath', function() {
- it('returns real path root', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = 'a.asar';
- fs.realpath(path.join(parent, p), function(err, r) {
- assert.equal(err, null);
- assert.equal(r, path.join(parent, p));
- done();
- });
- });
+ describe('fs.realpath', function () {
+ it('returns real path root', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = 'a.asar'
+ fs.realpath(path.join(parent, p), function (err, r) {
+ assert.equal(err, null)
+ assert.equal(r, path.join(parent, p))
+ done()
+ })
+ })
- it('returns real path of a normal file', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'file1');
- fs.realpath(path.join(parent, p), function(err, r) {
- assert.equal(err, null);
- assert.equal(r, path.join(parent, p));
- done();
- });
- });
+ it('returns real path of a normal file', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'file1')
+ fs.realpath(path.join(parent, p), function (err, r) {
+ assert.equal(err, null)
+ assert.equal(r, path.join(parent, p))
+ done()
+ })
+ })
- it('returns real path of a normal directory', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'dir1');
- fs.realpath(path.join(parent, p), function(err, r) {
- assert.equal(err, null);
- assert.equal(r, path.join(parent, p));
- done();
- });
- });
+ it('returns real path of a normal directory', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'dir1')
+ fs.realpath(path.join(parent, p), function (err, r) {
+ assert.equal(err, null)
+ assert.equal(r, path.join(parent, p))
+ done()
+ })
+ })
- it('returns real path of a linked file', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'link2', 'link1');
- fs.realpath(path.join(parent, p), function(err, r) {
- assert.equal(err, null);
- assert.equal(r, path.join(parent, 'a.asar', 'file1'));
- done();
- });
- });
+ it('returns real path of a linked file', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'link2', 'link1')
+ fs.realpath(path.join(parent, p), function (err, r) {
+ assert.equal(err, null)
+ assert.equal(r, path.join(parent, 'a.asar', 'file1'))
+ done()
+ })
+ })
- it('returns real path of a linked directory', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'link2', 'link2');
- fs.realpath(path.join(parent, p), function(err, r) {
- assert.equal(err, null);
- assert.equal(r, path.join(parent, 'a.asar', 'dir1'));
- done();
- });
- });
+ it('returns real path of a linked directory', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'link2', 'link2')
+ fs.realpath(path.join(parent, p), function (err, r) {
+ assert.equal(err, null)
+ assert.equal(r, path.join(parent, 'a.asar', 'dir1'))
+ done()
+ })
+ })
- it('returns real path of an unpacked file', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('unpack.asar', 'a.txt');
- fs.realpath(path.join(parent, p), function(err, r) {
- assert.equal(err, null);
- assert.equal(r, path.join(parent, p));
- done();
- });
- });
+ it('returns real path of an unpacked file', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('unpack.asar', 'a.txt')
+ fs.realpath(path.join(parent, p), function (err, r) {
+ assert.equal(err, null)
+ assert.equal(r, path.join(parent, p))
+ done()
+ })
+ })
- it('throws ENOENT error when can not find file', function(done) {
- var parent = fs.realpathSync(path.join(fixtures, 'asar'));
- var p = path.join('a.asar', 'not-exist');
- fs.realpath(path.join(parent, p), function(err) {
- assert.equal(err.code, 'ENOENT');
- done();
- });
- });
- });
- describe('fs.readdirSync', function() {
- it('reads dirs from root', function() {
- var p = path.join(fixtures, 'asar', 'a.asar');
- var dirs = fs.readdirSync(p);
- assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js']);
- });
+ it('throws ENOENT error when can not find file', function (done) {
+ var parent = fs.realpathSync(path.join(fixtures, 'asar'))
+ var p = path.join('a.asar', 'not-exist')
+ fs.realpath(path.join(parent, p), function (err) {
+ assert.equal(err.code, 'ENOENT')
+ done()
+ })
+ })
+ })
+ describe('fs.readdirSync', function () {
+ it('reads dirs from root', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar')
+ var dirs = fs.readdirSync(p)
+ assert.deepEqual(dirs, ['dir1', 'dir2', 'dir3', 'file1', 'file2', 'file3', 'link1', 'link2', 'ping.js'])
+ })
- it('reads dirs from a normal dir', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'dir1');
- var dirs = fs.readdirSync(p);
- assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
- });
+ it('reads dirs from a normal dir', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'dir1')
+ var dirs = fs.readdirSync(p)
+ assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
+ })
- it('reads dirs from a linked dir', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2');
- var dirs = fs.readdirSync(p);
- assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
- });
+ it('reads dirs from a linked dir', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link2', 'link2')
+ var dirs = fs.readdirSync(p)
+ assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
+ })
- it('throws ENOENT error when can not find file', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- var throws = function() {
- fs.readdirSync(p);
- };
- assert.throws(throws, /ENOENT/);
- });
- });
+ it('throws ENOENT error when can not find file', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ var throws = function () {
+ fs.readdirSync(p)
+ }
+ assert.throws(throws, /ENOENT/)
+ })
+ })
- describe('fs.readdir', function() {
- it('reads dirs from root', function(done) {
- 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']);
- done();
- });
- });
+ describe('fs.readdir', function () {
+ it('reads dirs from root', function (done) {
+ 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'])
+ 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) {
- assert.equal(err, null);
- assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2']);
- done();
- });
- });
- it('reads dirs from a linked dir', function(done) {
- 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']);
- 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) {
+ assert.equal(err, null)
+ assert.deepEqual(dirs, ['file1', 'file2', 'file3', 'link1', 'link2'])
+ done()
+ })
+ })
+ it('reads dirs from a linked dir', function (done) {
+ 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'])
+ done()
+ })
+ })
- it('throws ENOENT error when can not find file', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- fs.readdir(p, function(err) {
- assert.equal(err.code, 'ENOENT');
- done();
- });
- });
- });
+ it('throws ENOENT error when can not find file', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ fs.readdir(p, function (err) {
+ assert.equal(err.code, 'ENOENT')
+ done()
+ })
+ })
+ })
- describe('fs.openSync', function() {
- it('opens a normal/linked/under-linked-directory file', function() {
- var buffer, fd, file, j, len, p, ref2;
- ref2 = ['file1', 'link1', path.join('link2', 'file1')];
+ describe('fs.openSync', function () {
+ it('opens a normal/linked/under-linked-directory file', function () {
+ var buffer, fd, file, j, len, p, ref2
+ ref2 = ['file1', 'link1', path.join('link2', 'file1')]
for (j = 0, len = ref2.length; j < len; j++) {
- file = ref2[j];
- p = path.join(fixtures, 'asar', 'a.asar', file);
- fd = fs.openSync(p, 'r');
- buffer = new Buffer(6);
- fs.readSync(fd, buffer, 0, 6, 0);
- assert.equal(String(buffer).trim(), 'file1');
- fs.closeSync(fd);
+ file = ref2[j]
+ p = path.join(fixtures, 'asar', 'a.asar', file)
+ fd = fs.openSync(p, 'r')
+ buffer = new Buffer(6)
+ fs.readSync(fd, buffer, 0, 6, 0)
+ assert.equal(String(buffer).trim(), 'file1')
+ fs.closeSync(fd)
}
- });
+ })
- it('throws ENOENT error when can not find file', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- var throws = function() {
- fs.openSync(p);
- };
- assert.throws(throws, /ENOENT/);
- });
- });
+ it('throws ENOENT error when can not find file', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ var throws = function () {
+ fs.openSync(p)
+ }
+ assert.throws(throws, /ENOENT/)
+ })
+ })
- describe('fs.open', function() {
- it('opens a normal file', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'file1');
- fs.open(p, 'r', function(err, fd) {
- assert.equal(err, null);
- var buffer = new Buffer(6);
- fs.read(fd, buffer, 0, 6, 0, function(err) {
- assert.equal(err, null);
- assert.equal(String(buffer).trim(), 'file1');
- fs.close(fd, done);
- });
- });
- });
+ describe('fs.open', function () {
+ it('opens a normal file', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'file1')
+ fs.open(p, 'r', function (err, fd) {
+ assert.equal(err, null)
+ var buffer = new Buffer(6)
+ fs.read(fd, buffer, 0, 6, 0, function (err) {
+ assert.equal(err, null)
+ assert.equal(String(buffer).trim(), 'file1')
+ fs.close(fd, done)
+ })
+ })
+ })
- it('throws ENOENT error when can not find file', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- fs.open(p, 'r', function(err) {
- assert.equal(err.code, 'ENOENT');
- done();
- });
- });
- });
+ it('throws ENOENT error when can not find file', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ fs.open(p, 'r', function (err) {
+ assert.equal(err.code, 'ENOENT')
+ done()
+ })
+ })
+ })
- describe('fs.mkdir', function() {
- it('throws error when calling inside asar archive', function(done) {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- fs.mkdir(p, function(err) {
- assert.equal(err.code, 'ENOTDIR');
- done();
- });
- });
- });
+ describe('fs.mkdir', function () {
+ it('throws error when calling inside asar archive', function (done) {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ fs.mkdir(p, function (err) {
+ assert.equal(err.code, 'ENOTDIR')
+ done()
+ })
+ })
+ })
- describe('fs.mkdirSync', function() {
- it('throws error when calling inside asar archive', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- assert.throws((function() {
- fs.mkdirSync(p);
- }), new RegExp('ENOTDIR'));
- });
- });
+ describe('fs.mkdirSync', function () {
+ it('throws error when calling inside asar archive', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ assert.throws((function () {
+ fs.mkdirSync(p)
+ }), new RegExp('ENOTDIR'))
+ })
+ })
- describe('child_process.fork', function() {
- it('opens a normal js file', function(done) {
- var child = child_process.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'));
- child.on('message', function(msg) {
- assert.equal(msg, 'message');
- done();
- });
- child.send('message');
- });
+ describe('child_process.fork', function () {
+ it('opens a normal js file', function (done) {
+ var child = child_process.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'))
+ child.on('message', function (msg) {
+ assert.equal(msg, 'message')
+ done()
+ })
+ child.send('message')
+ })
- it('supports asar in the forked js', function(done) {
- 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());
- done();
- });
- child.send(file);
- });
- });
+ it('supports asar in the forked js', function (done) {
+ 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())
+ done()
+ })
+ child.send(file)
+ })
+ })
- describe('child_process.execFile', function() {
- var echo, execFile, execFileSync, ref2;
+ describe('child_process.execFile', function () {
+ var echo, execFile, execFileSync, ref2
if (process.platform !== 'darwin') {
- return;
+ return
}
- ref2 = require('child_process'), execFile = ref2.execFile, execFileSync = ref2.execFileSync;
- echo = path.join(fixtures, 'asar', 'echo.asar', 'echo');
+ 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);
- assert.equal(stdout, 'test\n');
- done();
- });
- });
+ it('executes binaries', function (done) {
+ execFile(echo, ['test'], function (error, stdout) {
+ assert.equal(error, null)
+ assert.equal(stdout, 'test\n')
+ done()
+ })
+ })
- xit('execFileSync executes binaries', function() {
- var output = execFileSync(echo, ['test']);
- assert.equal(String(output), 'test\n');
- });
- });
+ xit('execFileSync executes binaries', function () {
+ var output = execFileSync(echo, ['test'])
+ assert.equal(String(output), 'test\n')
+ })
+ })
- describe('internalModuleReadFile', function() {
- var internalModuleReadFile = process.binding('fs').internalModuleReadFile;
+ describe('internalModuleReadFile', function () {
+ var internalModuleReadFile = process.binding('fs').internalModuleReadFile
- it('read a normal file', function() {
- var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1');
- assert.equal(internalModuleReadFile(file1).toString().trim(), 'file1');
- var file2 = path.join(fixtures, 'asar', 'a.asar', 'file2');
- assert.equal(internalModuleReadFile(file2).toString().trim(), 'file2');
- var file3 = path.join(fixtures, 'asar', 'a.asar', 'file3');
- assert.equal(internalModuleReadFile(file3).toString().trim(), 'file3');
- });
+ it('read a normal file', function () {
+ var file1 = path.join(fixtures, 'asar', 'a.asar', 'file1')
+ assert.equal(internalModuleReadFile(file1).toString().trim(), 'file1')
+ var file2 = path.join(fixtures, 'asar', 'a.asar', 'file2')
+ assert.equal(internalModuleReadFile(file2).toString().trim(), 'file2')
+ var file3 = path.join(fixtures, 'asar', 'a.asar', 'file3')
+ assert.equal(internalModuleReadFile(file3).toString().trim(), 'file3')
+ })
- it('reads a normal file with unpacked files', function() {
- var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt');
- assert.equal(internalModuleReadFile(p).toString().trim(), 'a');
- });
- });
+ it('reads a normal file with unpacked files', function () {
+ var p = path.join(fixtures, 'asar', 'unpack.asar', 'a.txt')
+ assert.equal(internalModuleReadFile(p).toString().trim(), 'a')
+ })
+ })
- describe('process.noAsar', function() {
- var errorName = process.platform === 'win32' ? 'ENOENT' : 'ENOTDIR';
+ describe('process.noAsar', function () {
+ var errorName = process.platform === 'win32' ? 'ENOENT' : 'ENOTDIR'
- beforeEach(function() {
- process.noAsar = true;
- });
+ beforeEach(function () {
+ process.noAsar = true
+ })
- afterEach(function() {
- process.noAsar = false;
- });
+ afterEach(function () {
+ process.noAsar = false
+ })
- it('disables asar support in sync API', function() {
- var file = path.join(fixtures, 'asar', 'a.asar', 'file1');
- var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1');
- assert.throws((function() {
- fs.readFileSync(file);
- }), new RegExp(errorName));
- assert.throws((function() {
- fs.lstatSync(file);
- }), new RegExp(errorName));
- assert.throws((function() {
- fs.realpathSync(file);
- }), new RegExp(errorName));
- assert.throws((function() {
- fs.readdirSync(dir);
- }), new RegExp(errorName));
- });
+ it('disables asar support in sync API', function () {
+ var file = path.join(fixtures, 'asar', 'a.asar', 'file1')
+ var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1')
+ assert.throws((function () {
+ fs.readFileSync(file)
+ }), new RegExp(errorName))
+ assert.throws((function () {
+ fs.lstatSync(file)
+ }), new RegExp(errorName))
+ assert.throws((function () {
+ fs.realpathSync(file)
+ }), new RegExp(errorName))
+ assert.throws((function () {
+ fs.readdirSync(dir)
+ }), new RegExp(errorName))
+ })
- it('disables asar support in async API', function(done) {
- var file = path.join(fixtures, 'asar', 'a.asar', 'file1');
- var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1');
- fs.readFile(file, function(error) {
- assert.equal(error.code, errorName);
- fs.lstat(file, function(error) {
- assert.equal(error.code, errorName);
- fs.realpath(file, function(error) {
- assert.equal(error.code, errorName);
- fs.readdir(dir, function(error) {
- assert.equal(error.code, errorName);
- done();
- });
- });
- });
- });
- });
+ it('disables asar support in async API', function (done) {
+ var file = path.join(fixtures, 'asar', 'a.asar', 'file1')
+ var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1')
+ fs.readFile(file, function (error) {
+ assert.equal(error.code, errorName)
+ fs.lstat(file, function (error) {
+ assert.equal(error.code, errorName)
+ fs.realpath(file, function (error) {
+ assert.equal(error.code, errorName)
+ fs.readdir(dir, function (error) {
+ assert.equal(error.code, errorName)
+ done()
+ })
+ })
+ })
+ })
+ })
- it('treats *.asar as normal file', function() {
- var originalFs = require('original-fs');
- var asar = path.join(fixtures, 'asar', 'a.asar');
- var content1 = fs.readFileSync(asar);
- var content2 = originalFs.readFileSync(asar);
- assert.equal(content1.compare(content2), 0);
- assert.throws((function() {
- fs.readdirSync(asar);
- }), /ENOTDIR/);
- });
- });
- });
+ it('treats *.asar as normal file', function () {
+ var originalFs = require('original-fs')
+ var asar = path.join(fixtures, 'asar', 'a.asar')
+ var content1 = fs.readFileSync(asar)
+ var content2 = originalFs.readFileSync(asar)
+ assert.equal(content1.compare(content2), 0)
+ assert.throws((function () {
+ fs.readdirSync(asar)
+ }), /ENOTDIR/)
+ })
+ })
+ })
- describe('asar protocol', function() {
- var url = require('url');
+ describe('asar protocol', function () {
+ var url = require('url')
- it('can request a file in package', function(done) {
- var p = path.resolve(fixtures, 'asar', 'a.asar', 'file1');
- $.get("file://" + p, function(data) {
- assert.equal(data.trim(), 'file1');
- done();
- });
- });
+ it('can request a file in package', function (done) {
+ var p = path.resolve(fixtures, 'asar', 'a.asar', 'file1')
+ $.get('file://' + p, function (data) {
+ assert.equal(data.trim(), 'file1')
+ done()
+ })
+ })
- it('can request a file in package with unpacked files', function(done) {
- var p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt');
- $.get("file://" + p, function(data) {
- assert.equal(data.trim(), 'a');
- done();
- });
- });
+ it('can request a file in package with unpacked files', function (done) {
+ var p = path.resolve(fixtures, 'asar', 'unpack.asar', 'a.txt')
+ $.get('file://' + p, function (data) {
+ assert.equal(data.trim(), 'a')
+ done()
+ })
+ })
- it('can request a linked file in package', function(done) {
- var p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1');
- $.get("file://" + p, function(data) {
- assert.equal(data.trim(), 'file1');
- done();
- });
- });
+ it('can request a linked file in package', function (done) {
+ var p = path.resolve(fixtures, 'asar', 'a.asar', 'link2', 'link1')
+ $.get('file://' + p, function (data) {
+ assert.equal(data.trim(), 'file1')
+ done()
+ })
+ })
- it('can request a file in filesystem', function(done) {
- var p = path.resolve(fixtures, 'asar', 'file');
- $.get("file://" + p, function(data) {
- assert.equal(data.trim(), 'file');
- done();
- });
- });
+ it('can request a file in filesystem', function (done) {
+ var p = path.resolve(fixtures, 'asar', 'file')
+ $.get('file://' + p, function (data) {
+ assert.equal(data.trim(), 'file')
+ done()
+ })
+ })
- it('gets 404 when file is not found', function(done) {
- var p = path.resolve(fixtures, 'asar', 'a.asar', 'no-exist');
+ it('gets 404 when file is not found', function (done) {
+ var p = path.resolve(fixtures, 'asar', 'a.asar', 'no-exist')
$.ajax({
- url: "file://" + p,
- error: function(err) {
- assert.equal(err.status, 404);
- done();
+ url: 'file://' + p,
+ error: function (err) {
+ assert.equal(err.status, 404)
+ done()
}
- });
- });
+ })
+ })
- it('sets __dirname correctly', function(done) {
- after(function() {
- w.destroy();
- ipcMain.removeAllListeners('dirname');
- });
+ it('sets __dirname correctly', function (done) {
+ after(function () {
+ w.destroy()
+ ipcMain.removeAllListeners('dirname')
+ })
var w = new BrowserWindow({
show: false,
width: 400,
height: 400
- });
- var p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html');
+ })
+ var p = path.resolve(fixtures, 'asar', 'web.asar', 'index.html')
var u = url.format({
protocol: 'file',
slashed: true,
pathname: p
- });
- ipcMain.once('dirname', function(event, dirname) {
- assert.equal(dirname, path.dirname(p));
- done();
- });
- w.loadURL(u);
- });
+ })
+ ipcMain.once('dirname', function (event, dirname) {
+ assert.equal(dirname, path.dirname(p))
+ done()
+ })
+ w.loadURL(u)
+ })
- it('loads script tag in html', function(done) {
- after(function() {
- w.destroy();
- ipcMain.removeAllListeners('ping');
- });
+ it('loads script tag in html', function (done) {
+ after(function () {
+ w.destroy()
+ ipcMain.removeAllListeners('ping')
+ })
var w = new BrowserWindow({
show: false,
width: 400,
height: 400
- });
- var p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html');
+ })
+ var p = path.resolve(fixtures, 'asar', 'script.asar', 'index.html')
var u = url.format({
protocol: 'file',
slashed: true,
pathname: p
- });
- w.loadURL(u);
- ipcMain.once('ping', function(event, message) {
- assert.equal(message, 'pong');
- done();
- });
- });
- });
+ })
+ w.loadURL(u)
+ ipcMain.once('ping', function (event, message) {
+ assert.equal(message, 'pong')
+ done()
+ })
+ })
+ })
- describe('original-fs module', function() {
- var originalFs = require('original-fs');
+ describe('original-fs module', function () {
+ var originalFs = require('original-fs')
- it('treats .asar as file', function() {
- var file = path.join(fixtures, 'asar', 'a.asar');
- var stats = originalFs.statSync(file);
- assert(stats.isFile());
- });
+ it('treats .asar as file', function () {
+ var file = path.join(fixtures, 'asar', 'a.asar')
+ var stats = originalFs.statSync(file)
+ assert(stats.isFile())
+ })
- it('is available in forked scripts', function(done) {
- var child = child_process.fork(path.join(fixtures, 'module', 'original-fs.js'));
- child.on('message', function(msg) {
- assert.equal(msg, 'object');
- done();
- });
- child.send('message');
- });
- });
+ it('is available in forked scripts', function (done) {
+ var child = child_process.fork(path.join(fixtures, 'module', 'original-fs.js'))
+ child.on('message', function (msg) {
+ assert.equal(msg, 'object')
+ done()
+ })
+ child.send('message')
+ })
+ })
- describe('graceful-fs module', function() {
- var gfs = require('graceful-fs');
+ describe('graceful-fs module', function () {
+ var gfs = require('graceful-fs')
- it('recognize asar archvies', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'link1');
- assert.equal(gfs.readFileSync(p).toString().trim(), 'file1');
- });
- it('does not touch global fs object', function() {
- assert.notEqual(fs.readdir, gfs.readdir);
- });
- });
+ it('recognize asar archvies', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'link1')
+ assert.equal(gfs.readFileSync(p).toString().trim(), 'file1')
+ })
+ it('does not touch global fs object', function () {
+ assert.notEqual(fs.readdir, gfs.readdir)
+ })
+ })
- describe('mkdirp module', function() {
- var mkdirp = require('mkdirp');
+ describe('mkdirp module', function () {
+ var mkdirp = require('mkdirp')
- it('throws error when calling inside asar archive', function() {
- var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist');
- assert.throws((function() {
- mkdirp.sync(p);
- }), new RegExp('ENOTDIR'));
- });
- });
+ it('throws error when calling inside asar archive', function () {
+ var p = path.join(fixtures, 'asar', 'a.asar', 'not-exist')
+ assert.throws((function () {
+ mkdirp.sync(p)
+ }), new RegExp('ENOTDIR'))
+ })
+ })
- describe('native-image', function() {
- it('reads image from asar archive', function() {
- var p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png');
- var logo = nativeImage.createFromPath(p);
+ describe('native-image', function () {
+ it('reads image from asar archive', function () {
+ var p = path.join(fixtures, 'asar', 'logo.asar', 'logo.png')
+ var logo = nativeImage.createFromPath(p)
assert.deepEqual(logo.getSize(), {
width: 55,
height: 55
- });
- });
+ })
+ })
- it('reads image from asar archive with unpacked files', function() {
- var p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png');
- var logo = nativeImage.createFromPath(p);
+ it('reads image from asar archive with unpacked files', function () {
+ var p = path.join(fixtures, 'asar', 'unpack.asar', 'atom.png')
+ var logo = nativeImage.createFromPath(p)
assert.deepEqual(logo.getSize(), {
width: 1024,
height: 1024
- });
- });
- });
-});
+ })
+ })
+ })
+})
diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js
index ac9403a7ecd4..40e46dcb5eaf 100644
--- a/spec/chromium-spec.js
+++ b/spec/chromium-spec.js
@@ -1,432 +1,432 @@
-const assert = require('assert');
-const http = require('http');
-const path = require('path');
-const ws = require('ws');
-const remote = require('electron').remote;
+const assert = require('assert')
+const http = require('http')
+const path = require('path')
+const ws = require('ws')
+const remote = require('electron').remote
-const BrowserWindow = remote.require('electron').BrowserWindow;
-const session = remote.require('electron').session;
+const BrowserWindow = remote.require('electron').BrowserWindow
+const session = remote.require('electron').session
-const isCI = remote.getGlobal('isCi');
+const isCI = remote.getGlobal('isCi')
-describe('chromium feature', function() {
- var fixtures = path.resolve(__dirname, 'fixtures');
- var listener = null;
+describe('chromium feature', function () {
+ var fixtures = path.resolve(__dirname, 'fixtures')
+ var listener = null
- afterEach(function() {
+ afterEach(function () {
if (listener != null) {
- window.removeEventListener('message', listener);
+ window.removeEventListener('message', listener)
}
- listener = null;
- });
+ listener = null
+ })
- xdescribe('heap snapshot', function() {
- it('does not crash', function() {
- process.atomBinding('v8_util').takeHeapSnapshot();
- });
- });
+ xdescribe('heap snapshot', function () {
+ it('does not crash', function () {
+ process.atomBinding('v8_util').takeHeapSnapshot()
+ })
+ })
- describe('sending request of http protocol urls', function() {
- it('does not crash', function(done) {
- this.timeout(5000);
+ describe('sending request of http protocol urls', function () {
+ it('does not crash', function (done) {
+ this.timeout(5000)
- var server = http.createServer(function(req, res) {
- res.end();
- server.close();
- done();
- });
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- $.get("http://127.0.0.1:" + port);
- });
- });
- });
+ var server = http.createServer(function (req, res) {
+ res.end()
+ server.close()
+ done()
+ })
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ $.get('http://127.0.0.1:' + port)
+ })
+ })
+ })
- describe('document.hidden', function() {
- var url = "file://" + fixtures + "/pages/document-hidden.html";
- var w = null;
+ describe('document.hidden', function () {
+ var url = 'file://' + fixtures + '/pages/document-hidden.html'
+ var w = null
- afterEach(function() {
- w != null ? w.destroy() : void 0;
- });
+ afterEach(function () {
+ w != null ? w.destroy() : void 0
+ })
- it('is set correctly when window is not shown', function(done) {
+ it('is set correctly when window is not shown', function (done) {
w = new BrowserWindow({
show: false
- });
- w.webContents.on('ipc-message', function(event, args) {
- assert.deepEqual(args, ['hidden', true]);
- done();
- });
- w.loadURL(url);
- });
+ })
+ w.webContents.on('ipc-message', function (event, args) {
+ assert.deepEqual(args, ['hidden', true])
+ done()
+ })
+ w.loadURL(url)
+ })
- it('is set correctly when window is inactive', function(done) {
+ it('is set correctly when window is inactive', function (done) {
w = new BrowserWindow({
show: false
- });
- w.webContents.on('ipc-message', function(event, args) {
- assert.deepEqual(args, ['hidden', false]);
- done();
- });
- w.showInactive();
- w.loadURL(url);
- });
- });
+ })
+ w.webContents.on('ipc-message', function (event, args) {
+ assert.deepEqual(args, ['hidden', false])
+ done()
+ })
+ w.showInactive()
+ w.loadURL(url)
+ })
+ })
- xdescribe('navigator.webkitGetUserMedia', function() {
- it('calls its callbacks', function(done) {
- this.timeout(5000);
+ xdescribe('navigator.webkitGetUserMedia', function () {
+ it('calls its callbacks', function (done) {
+ this.timeout(5000)
navigator.webkitGetUserMedia({
audio: true,
video: false
- }, function() {
- done();
- }, function() {
- done();
- });
- });
- });
+ }, function () {
+ done()
+ }, function () {
+ done()
+ })
+ })
+ })
- describe('navigator.mediaDevices', function() {
+ describe('navigator.mediaDevices', function () {
if (process.env.TRAVIS === 'true') {
- return;
+ return
}
if (isCI && process.platform === 'linux') {
- return;
+ return
}
- it('can return labels of enumerated devices', function(done) {
+ it('can return labels of enumerated devices', function (done) {
navigator.mediaDevices.enumerateDevices().then((devices) => {
- const labels = devices.map((device) => device.label);
- const labelFound = labels.some((label) => !!label);
+ const labels = devices.map((device) => device.label)
+ const labelFound = labels.some((label) => !!label)
if (labelFound)
- done();
+ done()
else
- done('No device labels found: ' + JSON.stringify(labels));
- }).catch(done);
- });
- });
+ done('No device labels found: ' + JSON.stringify(labels))
+ }).catch(done)
+ })
+ })
- describe('navigator.language', function() {
- it('should not be empty', function() {
- assert.notEqual(navigator.language, '');
- });
- });
+ describe('navigator.language', function () {
+ it('should not be empty', function () {
+ assert.notEqual(navigator.language, '')
+ })
+ })
- describe('navigator.serviceWorker', function() {
- var url = "file://" + fixtures + "/pages/service-worker/index.html";
- var w = null;
+ describe('navigator.serviceWorker', function () {
+ var url = 'file://' + fixtures + '/pages/service-worker/index.html'
+ var w = null
- afterEach(function() {
- w != null ? w.destroy() : void 0;
- });
+ afterEach(function () {
+ w != null ? w.destroy() : void 0
+ })
- it('should register for file scheme', function(done) {
+ it('should register for file scheme', function (done) {
w = new BrowserWindow({
show: false
- });
- w.webContents.on('ipc-message', function(event, args) {
+ })
+ w.webContents.on('ipc-message', function (event, args) {
if (args[0] === 'reload') {
- w.webContents.reload();
+ w.webContents.reload()
} else if (args[0] === 'error') {
- done('unexpected error : ' + args[1]);
+ done('unexpected error : ' + args[1])
} else if (args[0] === 'response') {
- assert.equal(args[1], 'Hello from serviceWorker!');
+ assert.equal(args[1], 'Hello from serviceWorker!')
session.defaultSession.clearStorageData({
storages: ['serviceworkers']
- }, function() {
- done();
- });
+ }, function () {
+ done()
+ })
}
- });
- w.loadURL(url);
- });
- });
+ })
+ w.loadURL(url)
+ })
+ })
- describe('window.open', function() {
- this.timeout(20000);
+ describe('window.open', function () {
+ this.timeout(20000)
- it('returns a BrowserWindowProxy object', function() {
- var b = window.open('about:blank', '', 'show=no');
- assert.equal(b.closed, false);
- assert.equal(b.constructor.name, 'BrowserWindowProxy');
- b.close();
- });
+ it('returns a BrowserWindowProxy object', function () {
+ var b = window.open('about:blank', '', 'show=no')
+ assert.equal(b.closed, false)
+ assert.equal(b.constructor.name, 'BrowserWindowProxy')
+ b.close()
+ })
- it('accepts "nodeIntegration" as feature', function(done) {
- var b;
- listener = function(event) {
- assert.equal(event.data, 'undefined');
- b.close();
- done();
- };
- window.addEventListener('message', listener);
- b = window.open("file://" + fixtures + "/pages/window-opener-node.html", '', 'nodeIntegration=no,show=no');
- });
+ it('accepts "nodeIntegration" as feature', function (done) {
+ var b
+ listener = function (event) {
+ assert.equal(event.data, 'undefined')
+ b.close()
+ done()
+ }
+ window.addEventListener('message', listener)
+ 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) {
- var height, ref1, width;
- ref1 = remote.getCurrentWindow().getSize(), width = ref1[0], height = ref1[1];
- assert.equal(event.data, "size: " + width + " " + height);
- b.close();
- done();
- };
- window.addEventListener('message', listener);
- b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', 'show=no');
- });
+ it('inherit options of parent window', function (done) {
+ var b
+ listener = function (event) {
+ var height, ref1, width
+ ref1 = remote.getCurrentWindow().getSize(), width = ref1[0], height = ref1[1]
+ assert.equal(event.data, 'size: ' + width + ' ' + height)
+ b.close()
+ done()
+ }
+ window.addEventListener('message', listener)
+ b = window.open('file://' + fixtures + '/pages/window-open-size.html', '', 'show=no')
+ })
- it('does not override child options', function(done) {
- var b, size;
+ it('does not override child options', function (done) {
+ var b, size
size = {
width: 350,
height: 450
- };
- listener = function(event) {
- assert.equal(event.data, "size: " + size.width + " " + size.height);
- b.close();
- done();
- };
- window.addEventListener('message', listener);
- b = window.open("file://" + fixtures + "/pages/window-open-size.html", '', "show=no,width=" + size.width + ",height=" + size.height);
- });
+ }
+ listener = function (event) {
+ assert.equal(event.data, 'size: ' + size.width + ' ' + size.height)
+ b.close()
+ done()
+ }
+ window.addEventListener('message', listener)
+ b = window.open('file://' + fixtures + '/pages/window-open-size.html', '', 'show=no,width=' + size.width + ',height=' + size.height)
+ })
- it('defines a window.location getter', function(done) {
- var b, targetURL;
- targetURL = "file://" + fixtures + "/pages/base-page.html";
- b = window.open(targetURL);
- BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() {
- assert.equal(b.location, targetURL);
- b.close();
- done();
- });
- });
+ it('defines a window.location getter', function (done) {
+ var b, targetURL
+ targetURL = 'file://' + fixtures + '/pages/base-page.html'
+ b = window.open(targetURL)
+ BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
+ assert.equal(b.location, targetURL)
+ b.close()
+ done()
+ })
+ })
- it('defines a window.location setter', function(done) {
+ it('defines a window.location setter', function (done) {
// Load a page that definitely won't redirect
- var b;
- b = window.open("about:blank");
- BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() {
+ var b
+ b = window.open('about:blank')
+ BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
// When it loads, redirect
- b.location = "file://" + fixtures + "/pages/base-page.html";
- BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() {
+ b.location = 'file://' + fixtures + '/pages/base-page.html'
+ BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
// After our second redirect, cleanup and callback
- b.close();
- done();
- });
- });
- });
- });
+ b.close()
+ done()
+ })
+ })
+ })
+ })
- describe('window.opener', function() {
- this.timeout(10000);
+ describe('window.opener', function () {
+ this.timeout(10000)
- var url = "file://" + fixtures + "/pages/window-opener.html";
- var w = null;
+ var url = 'file://' + fixtures + '/pages/window-opener.html'
+ var w = null
- afterEach(function() {
- w != null ? w.destroy() : void 0;
- });
+ afterEach(function () {
+ w != null ? w.destroy() : void 0
+ })
- it('is null for main window', function(done) {
+ it('is null for main window', function (done) {
w = new BrowserWindow({
show: false
- });
- w.webContents.on('ipc-message', function(event, args) {
- assert.deepEqual(args, ['opener', null]);
- done();
- });
- w.loadURL(url);
- });
+ })
+ w.webContents.on('ipc-message', function (event, args) {
+ assert.deepEqual(args, ['opener', null])
+ done()
+ })
+ w.loadURL(url)
+ })
- it('is not null for window opened by window.open', function(done) {
- var b;
- listener = function(event) {
- assert.equal(event.data, 'object');
- b.close();
- done();
- };
- window.addEventListener('message', listener);
- b = window.open(url, '', 'show=no');
- });
- });
-
- describe('window.postMessage', function() {
- it('sets the source and origin correctly', function(done) {
- var b, sourceId;
- sourceId = remote.getCurrentWindow().id;
- listener = function(event) {
- window.removeEventListener('message', listener);
- b.close();
- var message = JSON.parse(event.data);
- assert.equal(message.data, 'testing');
- assert.equal(message.origin, 'file://');
- assert.equal(message.sourceEqualsOpener, true);
- assert.equal(message.sourceId, sourceId);
- assert.equal(event.origin, 'file://');
- done();
- };
- window.addEventListener('message', listener);
- b = window.open("file://" + fixtures + "/pages/window-open-postMessage.html", '', 'show=no');
- BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function() {
- b.postMessage('testing', '*');
- });
- });
- });
-
- describe('window.opener.postMessage', function() {
- it('sets source and origin correctly', function(done) {
- var b;
- listener = function(event) {
- window.removeEventListener('message', listener);
- b.close();
- assert.equal(event.source, b);
- assert.equal(event.origin, 'file://');
- done();
- };
- window.addEventListener('message', listener);
- b = window.open("file://" + fixtures + "/pages/window-opener-postMessage.html", '', 'show=no');
- });
- });
-
- describe('creating a Uint8Array under browser side', function() {
- it('does not crash', function() {
- var RUint8Array = remote.getGlobal('Uint8Array');
- new RUint8Array;
- });
- });
-
- describe('webgl', function() {
- it('can be get as context in canvas', function() {
- if (process.platform === 'linux') {
- return;
+ it('is not null for window opened by window.open', function (done) {
+ var b
+ listener = function (event) {
+ assert.equal(event.data, 'object')
+ b.close()
+ done()
}
- var webgl = document.createElement('canvas').getContext('webgl');
- assert.notEqual(webgl, null);
- });
- });
+ window.addEventListener('message', listener)
+ b = window.open(url, '', 'show=no')
+ })
+ })
- describe('web workers', function() {
- it('Worker can work', function(done) {
- var worker = new Worker('../fixtures/workers/worker.js');
- var message = 'ping';
- worker.onmessage = function(event) {
- assert.equal(event.data, message);
- worker.terminate();
- done();
- };
- worker.postMessage(message);
- });
+ describe('window.postMessage', function () {
+ it('sets the source and origin correctly', function (done) {
+ var b, sourceId
+ sourceId = remote.getCurrentWindow().id
+ listener = function (event) {
+ window.removeEventListener('message', listener)
+ b.close()
+ var message = JSON.parse(event.data)
+ assert.equal(message.data, 'testing')
+ assert.equal(message.origin, 'file://')
+ assert.equal(message.sourceEqualsOpener, true)
+ assert.equal(message.sourceId, sourceId)
+ assert.equal(event.origin, 'file://')
+ done()
+ }
+ window.addEventListener('message', listener)
+ b = window.open('file://' + fixtures + '/pages/window-open-postMessage.html', '', 'show=no')
+ BrowserWindow.fromId(b.guestId).webContents.once('did-finish-load', function () {
+ b.postMessage('testing', '*')
+ })
+ })
+ })
- it('SharedWorker can work', function(done) {
- var worker = new SharedWorker('../fixtures/workers/shared_worker.js');
- var message = 'ping';
- worker.port.onmessage = function(event) {
- assert.equal(event.data, message);
- done();
- };
- worker.port.postMessage(message);
- });
- });
+ describe('window.opener.postMessage', function () {
+ it('sets source and origin correctly', function (done) {
+ var b
+ listener = function (event) {
+ window.removeEventListener('message', listener)
+ b.close()
+ assert.equal(event.source, b)
+ assert.equal(event.origin, 'file://')
+ done()
+ }
+ window.addEventListener('message', listener)
+ b = window.open('file://' + fixtures + '/pages/window-opener-postMessage.html', '', 'show=no')
+ })
+ })
- describe('iframe', function() {
- var iframe = null;
+ describe('creating a Uint8Array under browser side', function () {
+ it('does not crash', function () {
+ var RUint8Array = remote.getGlobal('Uint8Array')
+ new RUint8Array
+ })
+ })
- beforeEach(function() {
- iframe = document.createElement('iframe');
- });
+ describe('webgl', function () {
+ it('can be get as context in canvas', function () {
+ if (process.platform === 'linux') {
+ return
+ }
+ var webgl = document.createElement('canvas').getContext('webgl')
+ assert.notEqual(webgl, null)
+ })
+ })
- afterEach(function() {
- document.body.removeChild(iframe);
- });
+ describe('web workers', function () {
+ it('Worker can work', function (done) {
+ var worker = new Worker('../fixtures/workers/worker.js')
+ var message = 'ping'
+ worker.onmessage = function (event) {
+ assert.equal(event.data, message)
+ worker.terminate()
+ done()
+ }
+ worker.postMessage(message)
+ })
- it('does not have node integration', function(done) {
- iframe.src = "file://" + fixtures + "/pages/set-global.html";
- document.body.appendChild(iframe);
- iframe.onload = function() {
- assert.equal(iframe.contentWindow.test, 'undefined undefined undefined');
- done();
- };
- });
- });
+ it('SharedWorker can work', function (done) {
+ var worker = new SharedWorker('../fixtures/workers/shared_worker.js')
+ var message = 'ping'
+ worker.port.onmessage = function (event) {
+ assert.equal(event.data, message)
+ done()
+ }
+ worker.port.postMessage(message)
+ })
+ })
- describe('storage', function() {
- it('requesting persitent quota works', function(done) {
- navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function(grantedBytes) {
- assert.equal(grantedBytes, 1048576);
- done();
- });
- });
- });
+ describe('iframe', function () {
+ var iframe = null
- describe('websockets', function() {
- var wss = null;
- var server = null;
- var WebSocketServer = ws.Server;
+ beforeEach(function () {
+ iframe = document.createElement('iframe')
+ })
- afterEach(function() {
- wss.close();
- server.close();
- });
+ afterEach(function () {
+ document.body.removeChild(iframe)
+ })
- it('has user agent', function(done) {
- server = http.createServer();
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
+ it('does not have node integration', function (done) {
+ iframe.src = 'file://' + fixtures + '/pages/set-global.html'
+ document.body.appendChild(iframe)
+ iframe.onload = function () {
+ assert.equal(iframe.contentWindow.test, 'undefined undefined undefined')
+ done()
+ }
+ })
+ })
+
+ describe('storage', function () {
+ it('requesting persitent quota works', function (done) {
+ navigator.webkitPersistentStorage.requestQuota(1024 * 1024, function (grantedBytes) {
+ assert.equal(grantedBytes, 1048576)
+ done()
+ })
+ })
+ })
+
+ describe('websockets', function () {
+ var wss = null
+ var server = null
+ var WebSocketServer = ws.Server
+
+ afterEach(function () {
+ wss.close()
+ server.close()
+ })
+
+ it('has user agent', function (done) {
+ server = http.createServer()
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
wss = new WebSocketServer({
server: server
- });
- wss.on('error', done);
- wss.on('connection', function(ws) {
+ })
+ wss.on('error', done)
+ wss.on('connection', function (ws) {
if (ws.upgradeReq.headers['user-agent']) {
- done();
+ done()
} else {
- done('user agent is empty');
+ done('user agent is empty')
}
- });
- new WebSocket("ws://127.0.0.1:" + port);
- });
- });
- });
+ })
+ new WebSocket('ws://127.0.0.1:' + port)
+ })
+ })
+ })
- describe('Promise', function() {
- it('resolves correctly in Node.js calls', function(done) {
+ describe('Promise', function () {
+ it('resolves correctly in Node.js calls', function (done) {
document.registerElement('x-element', {
prototype: Object.create(HTMLElement.prototype, {
createdCallback: {
- value: function() {}
+ value: function () {}
}
})
- });
- setImmediate(function() {
- var called = false;
- Promise.resolve().then(function() {
- done(called ? void 0 : new Error('wrong sequence'));
- });
- document.createElement('x-element');
- called = true;
- });
- });
+ })
+ setImmediate(function () {
+ var called = false
+ Promise.resolve().then(function () {
+ done(called ? void 0 : new Error('wrong sequence'))
+ })
+ document.createElement('x-element')
+ called = true
+ })
+ })
- it('resolves correctly in Electron calls', function(done) {
+ it('resolves correctly in Electron calls', function (done) {
document.registerElement('y-element', {
prototype: Object.create(HTMLElement.prototype, {
createdCallback: {
- value: function() {}
+ value: function () {}
}
})
- });
- remote.getGlobal('setImmediate')(function() {
- var called = false;
- Promise.resolve().then(function() {
- done(called ? void 0 : new Error('wrong sequence'));
- });
- document.createElement('y-element');
- called = true;
- });
- });
- });
-});
+ })
+ remote.getGlobal('setImmediate')(function () {
+ var called = false
+ Promise.resolve().then(function () {
+ done(called ? void 0 : new Error('wrong sequence'))
+ })
+ document.createElement('y-element')
+ called = true
+ })
+ })
+ })
+})
diff --git a/spec/fixtures/api/quit-app/main.js b/spec/fixtures/api/quit-app/main.js
index 114e830076a0..e2f97affe6de 100644
--- a/spec/fixtures/api/quit-app/main.js
+++ b/spec/fixtures/api/quit-app/main.js
@@ -1,12 +1,12 @@
-var app = require('electron').app;
+var app = require('electron').app
app.on('ready', function () {
// This setImmediate call gets the spec passing on Linux
setImmediate(function () {
- app.exit(123);
- });
-});
+ app.exit(123)
+ })
+})
process.on('exit', function (code) {
- console.log('Exit event with code: ' + code);
-});
+ console.log('Exit event with code: ' + code)
+})
diff --git a/spec/fixtures/module/asar.js b/spec/fixtures/module/asar.js
index 1fb8750878a3..e01b64a2eca8 100644
--- a/spec/fixtures/module/asar.js
+++ b/spec/fixtures/module/asar.js
@@ -1,4 +1,4 @@
-var fs = require('fs');
-process.on('message', function(file) {
- process.send(fs.readFileSync(file).toString());
-});
+var fs = require('fs')
+process.on('message', function (file) {
+ process.send(fs.readFileSync(file).toString())
+})
diff --git a/spec/fixtures/module/call.js b/spec/fixtures/module/call.js
index ce0eb6324df4..d09d677199b1 100644
--- a/spec/fixtures/module/call.js
+++ b/spec/fixtures/module/call.js
@@ -1,7 +1,7 @@
-exports.call = function(func) {
- return func();
-};
+exports.call = function (func) {
+ return func()
+}
-exports.constructor = function() {
- this.test = 'test';
-};
+exports.constructor = function () {
+ this.test = 'test'
+}
diff --git a/spec/fixtures/module/class.js b/spec/fixtures/module/class.js
index f25eb2593ff3..c961dd8040c1 100644
--- a/spec/fixtures/module/class.js
+++ b/spec/fixtures/module/class.js
@@ -1,22 +1,22 @@
-'use strict';
+'use strict'
-let value = 'old';
+let value = 'old'
class BaseClass {
- method() {
- return 'method';
+ method () {
+ return 'method'
}
- get readonly() {
- return 'readonly';
+ get readonly () {
+ return 'readonly'
}
- get value() {
- return value;
+ get value () {
+ return value
}
- set value(val) {
- value = val;
+ set value (val) {
+ value = val
}
}
diff --git a/spec/fixtures/module/create_socket.js b/spec/fixtures/module/create_socket.js
index 2a8b475c5192..2528b993d655 100644
--- a/spec/fixtures/module/create_socket.js
+++ b/spec/fixtures/module/create_socket.js
@@ -1,4 +1,4 @@
-var net = require('net');
-var server = net.createServer(function() {});
-server.listen(process.argv[2]);
-process.exit(0);
+var net = require('net')
+var server = net.createServer(function () {})
+server.listen(process.argv[2])
+process.exit(0)
diff --git a/spec/fixtures/module/fork_ping.js b/spec/fixtures/module/fork_ping.js
index a43f7d8dce7d..76bf1b0e3688 100644
--- a/spec/fixtures/module/fork_ping.js
+++ b/spec/fixtures/module/fork_ping.js
@@ -1,14 +1,14 @@
-process.on('uncaughtException', function(error) {
- process.send(error.stack);
-});
+process.on('uncaughtException', function (error) {
+ process.send(error.stack)
+})
-var child = require('child_process').fork(__dirname + '/ping.js');
-process.on('message', function(msg) {
- child.send(msg);
-});
+var child = require('child_process').fork(__dirname + '/ping.js')
+process.on('message', function (msg) {
+ child.send(msg)
+})
child.on('message', function (msg) {
- process.send(msg);
-});
-child.on('exit', function(code) {
- process.exit(code);
-});
+ process.send(msg)
+})
+child.on('exit', function (code) {
+ process.exit(code)
+})
diff --git a/spec/fixtures/module/function.js b/spec/fixtures/module/function.js
index 803a2838d372..526daf76fa8f 100644
--- a/spec/fixtures/module/function.js
+++ b/spec/fixtures/module/function.js
@@ -1 +1 @@
-exports.aFunction = function() { return 1127; };
+exports.aFunction = function () { return 1127; }
diff --git a/spec/fixtures/module/id.js b/spec/fixtures/module/id.js
index 5bfae457fe0b..2faec9d38321 100644
--- a/spec/fixtures/module/id.js
+++ b/spec/fixtures/module/id.js
@@ -1 +1 @@
-exports.id = 1127;
+exports.id = 1127
diff --git a/spec/fixtures/module/locale-compare.js b/spec/fixtures/module/locale-compare.js
index 32dfb309926b..3446e2f443dd 100644
--- a/spec/fixtures/module/locale-compare.js
+++ b/spec/fixtures/module/locale-compare.js
@@ -3,5 +3,5 @@ process.on('message', function () {
'a'.localeCompare('a'),
'ä'.localeCompare('z', 'de'),
'ä'.localeCompare('a', 'sv', { sensitivity: 'base' }),
- ]);
-});
+ ])
+})
diff --git a/spec/fixtures/module/original-fs.js b/spec/fixtures/module/original-fs.js
index 7a527c633585..341dcb2e0de8 100644
--- a/spec/fixtures/module/original-fs.js
+++ b/spec/fixtures/module/original-fs.js
@@ -1,3 +1,3 @@
process.on('message', function () {
- process.send(typeof require('original-fs'));
-});
+ process.send(typeof require('original-fs'))
+})
diff --git a/spec/fixtures/module/ping.js b/spec/fixtures/module/ping.js
index fdb9d1ec4ce7..90b3d1fb20a1 100644
--- a/spec/fixtures/module/ping.js
+++ b/spec/fixtures/module/ping.js
@@ -1,4 +1,4 @@
-process.on('message', function(msg) {
- process.send(msg);
- process.exit(0);
-});
+process.on('message', function (msg) {
+ process.send(msg)
+ process.exit(0)
+})
diff --git a/spec/fixtures/module/preload-ipc.js b/spec/fixtures/module/preload-ipc.js
index ed95055c1249..3f7e5ea35ce6 100644
--- a/spec/fixtures/module/preload-ipc.js
+++ b/spec/fixtures/module/preload-ipc.js
@@ -1,4 +1,4 @@
-var ipcRenderer = require('electron').ipcRenderer;
-ipcRenderer.on('ping', function(event, message) {
- ipcRenderer.sendToHost('pong', message);
-});
+var ipcRenderer = require('electron').ipcRenderer
+ipcRenderer.on('ping', function (event, message) {
+ ipcRenderer.sendToHost('pong', message)
+})
diff --git a/spec/fixtures/module/preload-node-off.js b/spec/fixtures/module/preload-node-off.js
index 9020f4513a10..54fe343a9ca0 100644
--- a/spec/fixtures/module/preload-node-off.js
+++ b/spec/fixtures/module/preload-node-off.js
@@ -1,7 +1,7 @@
-setImmediate(function() {
+setImmediate(function () {
try {
- console.log([typeof process, typeof setImmediate, typeof global].join(' '));
+ console.log([typeof process, typeof setImmediate, typeof global].join(' '))
} catch (e) {
- console.log(e.message);
+ console.log(e.message)
}
-});
+})
diff --git a/spec/fixtures/module/preload.js b/spec/fixtures/module/preload.js
index 205a077ddb10..39c8b11fbe38 100644
--- a/spec/fixtures/module/preload.js
+++ b/spec/fixtures/module/preload.js
@@ -1 +1 @@
-console.log([typeof require, typeof module, typeof process].join(' '));
+console.log([typeof require, typeof module, typeof process].join(' '))
diff --git a/spec/fixtures/module/print_name.js b/spec/fixtures/module/print_name.js
index 96ac2d6f3cb5..db4f71d407b6 100644
--- a/spec/fixtures/module/print_name.js
+++ b/spec/fixtures/module/print_name.js
@@ -1,7 +1,7 @@
-exports.print = function(obj) {
- return obj.constructor.name;
-};
+exports.print = function (obj) {
+ return obj.constructor.name
+}
-exports.echo = function(obj) {
- return obj;
-};
+exports.echo = function (obj) {
+ return obj
+}
diff --git a/spec/fixtures/module/process_args.js b/spec/fixtures/module/process_args.js
index bba351154f6d..56e3906c5534 100644
--- a/spec/fixtures/module/process_args.js
+++ b/spec/fixtures/module/process_args.js
@@ -1,4 +1,4 @@
-process.on('message', function() {
- process.send(process.argv);
- process.exit(0);
-});
+process.on('message', function () {
+ process.send(process.argv)
+ process.exit(0)
+})
diff --git a/spec/fixtures/module/promise.js b/spec/fixtures/module/promise.js
index b9b568855e30..d34058cc8033 100644
--- a/spec/fixtures/module/promise.js
+++ b/spec/fixtures/module/promise.js
@@ -1,5 +1,5 @@
exports.twicePromise = function (promise) {
return promise.then(function (value) {
- return value * 2;
- });
-};
+ return value * 2
+ })
+}
diff --git a/spec/fixtures/module/property.js b/spec/fixtures/module/property.js
index 36286d800e16..88e596f73083 100644
--- a/spec/fixtures/module/property.js
+++ b/spec/fixtures/module/property.js
@@ -1 +1 @@
-exports.property = 1127;
+exports.property = 1127
diff --git a/spec/fixtures/module/runas.js b/spec/fixtures/module/runas.js
index c4845e026f23..6422fce052a8 100644
--- a/spec/fixtures/module/runas.js
+++ b/spec/fixtures/module/runas.js
@@ -1,6 +1,6 @@
-process.on('uncaughtException', function(err) {
- process.send(err.message);
-});
+process.on('uncaughtException', function (err) {
+ process.send(err.message)
+})
-require('runas');
-process.send('ok');
+require('runas')
+process.send('ok')
diff --git a/spec/fixtures/module/send-later.js b/spec/fixtures/module/send-later.js
index 704f47d328df..8eb16f72f8cc 100644
--- a/spec/fixtures/module/send-later.js
+++ b/spec/fixtures/module/send-later.js
@@ -1,4 +1,4 @@
-var ipcRenderer = require('electron').ipcRenderer;
-window.onload = function() {
- ipcRenderer.send('answer', typeof window.process);
-};
+var ipcRenderer = require('electron').ipcRenderer
+window.onload = function () {
+ ipcRenderer.send('answer', typeof window.process)
+}
diff --git a/spec/fixtures/module/set-global.js b/spec/fixtures/module/set-global.js
index f39919ff9d8f..ba4f30d155b7 100644
--- a/spec/fixtures/module/set-global.js
+++ b/spec/fixtures/module/set-global.js
@@ -1 +1 @@
-window.test = 'preload';
+window.test = 'preload'
diff --git a/spec/fixtures/module/set-immediate.js b/spec/fixtures/module/set-immediate.js
index d36355ee23b4..69563fd0a832 100644
--- a/spec/fixtures/module/set-immediate.js
+++ b/spec/fixtures/module/set-immediate.js
@@ -1,11 +1,11 @@
-process.on('uncaughtException', function(error) {
- process.send(error.message);
- process.exit(1);
-});
+process.on('uncaughtException', function (error) {
+ process.send(error.message)
+ process.exit(1)
+})
-process.on('message', function() {
- setImmediate(function() {
- process.send('ok');
- process.exit(0);
- });
-});
+process.on('message', function () {
+ setImmediate(function () {
+ process.send('ok')
+ process.exit(0)
+ })
+})
diff --git a/spec/fixtures/pages/service-worker/service-worker.js b/spec/fixtures/pages/service-worker/service-worker.js
index 854b3558a95c..7d80f45e2df4 100644
--- a/spec/fixtures/pages/service-worker/service-worker.js
+++ b/spec/fixtures/pages/service-worker/service-worker.js
@@ -1,9 +1,9 @@
-self.addEventListener('fetch', function(event) {
- var requestUrl = new URL(event.request.url);
+self.addEventListener('fetch', function (event) {
+ var requestUrl = new URL(event.request.url)
if (requestUrl.pathname === '/echo' &&
- event.request.headers.has('X-Mock-Response')) {
- var mockResponse = new Response('Hello from serviceWorker!');
- event.respondWith(mockResponse);
+ event.request.headers.has('X-Mock-Response')) {
+ var mockResponse = new Response('Hello from serviceWorker!')
+ event.respondWith(mockResponse)
}
-});
+})
diff --git a/spec/fixtures/workers/shared_worker.js b/spec/fixtures/workers/shared_worker.js
index 402207939793..35cb40d03b54 100644
--- a/spec/fixtures/workers/shared_worker.js
+++ b/spec/fixtures/workers/shared_worker.js
@@ -1,7 +1,7 @@
-this.onconnect = function(event) {
- var port = event.ports[0];
- port.start();
- port.onmessage = function(event) {
- port.postMessage(event.data);
- };
-};
+this.onconnect = function (event) {
+ var port = event.ports[0]
+ port.start()
+ port.onmessage = function (event) {
+ port.postMessage(event.data)
+ }
+}
diff --git a/spec/fixtures/workers/worker.js b/spec/fixtures/workers/worker.js
index 4f445470b9ad..884c17ac86ea 100644
--- a/spec/fixtures/workers/worker.js
+++ b/spec/fixtures/workers/worker.js
@@ -1,3 +1,3 @@
-this.onmessage = function(msg) {
- this.postMessage(msg.data);
-};
+this.onmessage = function (msg) {
+ this.postMessage(msg.data)
+}
diff --git a/spec/modules-spec.js b/spec/modules-spec.js
index fb53a90cf735..0f694e5e6d80 100644
--- a/spec/modules-spec.js
+++ b/spec/modules-spec.js
@@ -1,47 +1,47 @@
-const assert = require('assert');
-const path = require('path');
-const temp = require('temp');
+const assert = require('assert')
+const path = require('path')
+const temp = require('temp')
-describe('third-party module', function() {
- var fixtures = path.join(__dirname, 'fixtures');
- temp.track();
+describe('third-party module', function () {
+ 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() {
- require('runas');
- });
+ describe('runas', function () {
+ it('can be required in renderer', function () {
+ require('runas')
+ })
- it('can be required in node binary', function(done) {
- var runas = path.join(fixtures, 'module', 'runas.js');
- var child = require('child_process').fork(runas);
- child.on('message', function(msg) {
- assert.equal(msg, 'ok');
- done();
- });
- });
- });
+ it('can be required in node binary', function (done) {
+ var runas = path.join(fixtures, 'module', 'runas.js')
+ var child = require('child_process').fork(runas)
+ child.on('message', function (msg) {
+ assert.equal(msg, 'ok')
+ done()
+ })
+ })
+ })
- describe('ffi', function() {
- it('does not crash', function() {
- var ffi = require('ffi');
+ describe('ffi', function () {
+ it('does not crash', function () {
+ var ffi = require('ffi')
var libm = ffi.Library('libm', {
ceil: ['double', ['double']]
- });
- assert.equal(libm.ceil(1.5), 2);
- });
- });
+ })
+ assert.equal(libm.ceil(1.5), 2)
+ })
+ })
}
- describe('q', function() {
- var Q = require('q');
- describe('Q.when', function() {
- it('emits the fullfil callback', function(done) {
- Q(true).then(function(val) {
- assert.equal(val, true);
- done();
- });
- });
- });
- });
-});
+ describe('q', function () {
+ var Q = require('q')
+ describe('Q.when', function () {
+ it('emits the fullfil callback', function (done) {
+ Q(true).then(function (val) {
+ assert.equal(val, true)
+ done()
+ })
+ })
+ })
+ })
+})
diff --git a/spec/node-spec.js b/spec/node-spec.js
index 83f685d95f04..286c4d6f9161 100644
--- a/spec/node-spec.js
+++ b/spec/node-spec.js
@@ -1,220 +1,220 @@
-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;
+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 = path.join(__dirname, 'fixtures');
+describe('node feature', function () {
+ var fixtures = path.join(__dirname, 'fixtures')
- describe('child_process', function() {
- describe('child_process.fork', function() {
- it('works in current process', function(done) {
- var child = child_process.fork(path.join(fixtures, 'module', 'ping.js'));
- child.on('message', function(msg) {
- assert.equal(msg, 'message');
- done();
- });
- child.send('message');
- });
+ describe('child_process', function () {
+ describe('child_process.fork', function () {
+ it('works in current process', function (done) {
+ var child = child_process.fork(path.join(fixtures, 'module', 'ping.js'))
+ child.on('message', function (msg) {
+ assert.equal(msg, 'message')
+ done()
+ })
+ child.send('message')
+ })
- it('preserves args', function(done) {
- var args = ['--expose_gc', '-test', '1'];
- var child = child_process.fork(path.join(fixtures, 'module', 'process_args.js'), args);
- child.on('message', function(msg) {
- assert.deepEqual(args, msg.slice(2));
- done();
- });
- child.send('message');
- });
+ it('preserves args', function (done) {
+ var args = ['--expose_gc', '-test', '1']
+ var child = child_process.fork(path.join(fixtures, 'module', 'process_args.js'), args)
+ child.on('message', function (msg) {
+ assert.deepEqual(args, msg.slice(2))
+ done()
+ })
+ child.send('message')
+ })
- it('works in forked process', function(done) {
- var child = child_process.fork(path.join(fixtures, 'module', 'fork_ping.js'));
- child.on('message', function(msg) {
- assert.equal(msg, 'message');
- done();
- });
- child.send('message');
- });
+ it('works in forked process', function (done) {
+ var child = child_process.fork(path.join(fixtures, 'module', 'fork_ping.js'))
+ child.on('message', function (msg) {
+ assert.equal(msg, 'message')
+ done()
+ })
+ child.send('message')
+ })
- it('works in forked process when options.env is specifed', function(done) {
+ it('works in forked process when options.env is specifed', function (done) {
var child = child_process.fork(path.join(fixtures, 'module', 'fork_ping.js'), [], {
path: process.env['PATH']
- });
- child.on('message', function(msg) {
- assert.equal(msg, 'message');
- done();
- });
- child.send('message');
- });
+ })
+ child.on('message', function (msg) {
+ assert.equal(msg, 'message')
+ done()
+ })
+ child.send('message')
+ })
- it('works in browser process', function(done) {
- var fork = remote.require('child_process').fork;
- var child = fork(path.join(fixtures, 'module', 'ping.js'));
- child.on('message', function(msg) {
- assert.equal(msg, 'message');
- done();
- });
- child.send('message');
- });
+ it('works in browser process', function (done) {
+ var fork = remote.require('child_process').fork
+ var child = fork(path.join(fixtures, 'module', 'ping.js'))
+ child.on('message', function (msg) {
+ assert.equal(msg, 'message')
+ done()
+ })
+ child.send('message')
+ })
- it('has String::localeCompare working in script', function(done) {
- var child = child_process.fork(path.join(fixtures, 'module', 'locale-compare.js'));
- child.on('message', function(msg) {
- assert.deepEqual(msg, [0, -1, 1]);
- done();
- });
- child.send('message');
- });
+ it('has String::localeCompare working in script', function (done) {
+ var child = child_process.fork(path.join(fixtures, 'module', 'locale-compare.js'))
+ child.on('message', function (msg) {
+ assert.deepEqual(msg, [0, -1, 1])
+ done()
+ })
+ child.send('message')
+ })
- it('has setImmediate working in script', function(done) {
- var child = child_process.fork(path.join(fixtures, 'module', 'set-immediate.js'));
- child.on('message', function(msg) {
- assert.equal(msg, 'ok');
- done();
- });
- child.send('message');
- });
- });
- });
+ it('has setImmediate working in script', function (done) {
+ var child = child_process.fork(path.join(fixtures, 'module', 'set-immediate.js'))
+ child.on('message', function (msg) {
+ assert.equal(msg, 'ok')
+ done()
+ })
+ child.send('message')
+ })
+ })
+ })
- describe('contexts', function() {
- describe('setTimeout in fs callback', function() {
+ describe('contexts', function () {
+ describe('setTimeout in fs callback', function () {
if (process.env.TRAVIS === 'true') {
- return;
+ return
}
- it('does not crash', function(done) {
- fs.readFile(__filename, function() {
- setTimeout(done, 0);
- });
- });
- });
+ it('does not crash', function (done) {
+ fs.readFile(__filename, function () {
+ setTimeout(done, 0)
+ })
+ })
+ })
- describe('throw error in node context', function() {
- it('gets caught', function(done) {
- var error = new Error('boo!');
- var lsts = process.listeners('uncaughtException');
- process.removeAllListeners('uncaughtException');
- process.on('uncaughtException', function() {
- var i, len, lst;
- process.removeAllListeners('uncaughtException');
+ describe('throw error in node context', function () {
+ it('gets caught', function (done) {
+ var error = new Error('boo!')
+ var lsts = process.listeners('uncaughtException')
+ process.removeAllListeners('uncaughtException')
+ process.on('uncaughtException', function () {
+ var i, len, lst
+ process.removeAllListeners('uncaughtException')
for (i = 0, len = lsts.length; i < len; i++) {
- lst = lsts[i];
- process.on('uncaughtException', lst);
+ lst = lsts[i]
+ process.on('uncaughtException', lst)
}
- done();
- });
- fs.readFile(__filename, function() {
- throw error;
- });
- });
- });
+ done()
+ })
+ fs.readFile(__filename, function () {
+ throw error
+ })
+ })
+ })
- describe('setTimeout called under Chromium event loop in browser process', function() {
- it('can be scheduled in time', function(done) {
- remote.getGlobal('setTimeout')(done, 0);
- });
- });
+ describe('setTimeout called under Chromium event loop in browser process', function () {
+ it('can be scheduled in time', function (done) {
+ remote.getGlobal('setTimeout')(done, 0)
+ })
+ })
- describe('setInterval called under Chromium event loop in browser process', function() {
- it('can be scheduled in time', function(done) {
- var clear, interval;
- clear = function() {
- remote.getGlobal('clearInterval')(interval);
- done();
- };
- interval = remote.getGlobal('setInterval')(clear, 10);
- });
- });
- });
+ describe('setInterval called under Chromium event loop in browser process', function () {
+ it('can be scheduled in time', function (done) {
+ var clear, interval
+ clear = function () {
+ remote.getGlobal('clearInterval')(interval)
+ done()
+ }
+ interval = remote.getGlobal('setInterval')(clear, 10)
+ })
+ })
+ })
- describe('message loop', function() {
- describe('process.nextTick', function() {
- it('emits the callback', function(done) {
- process.nextTick(done);
- });
+ describe('message loop', function () {
+ describe('process.nextTick', function () {
+ it('emits the callback', function (done) {
+ process.nextTick(done)
+ })
- it('works in nested calls', function(done) {
- process.nextTick(function() {
- process.nextTick(function() {
- process.nextTick(done);
- });
- });
- });
- });
+ it('works in nested calls', function (done) {
+ process.nextTick(function () {
+ process.nextTick(function () {
+ process.nextTick(done)
+ })
+ })
+ })
+ })
- describe('setImmediate', function() {
- it('emits the callback', function(done) {
- setImmediate(done);
- });
+ describe('setImmediate', function () {
+ it('emits the callback', function (done) {
+ setImmediate(done)
+ })
- it('works in nested calls', function(done) {
- setImmediate(function() {
- setImmediate(function() {
- setImmediate(done);
- });
- });
- });
- });
- });
+ it('works in nested calls', function (done) {
+ setImmediate(function () {
+ setImmediate(function () {
+ setImmediate(done)
+ })
+ })
+ })
+ })
+ })
- describe('net.connect', 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 socketPath = path.join(os.tmpdir(), 'atom-shell-test.sock');
- var script = path.join(fixtures, 'module', 'create_socket.js');
- var child = child_process.fork(script, [socketPath]);
- child.on('exit', function(code) {
- assert.equal(code, 0);
- var client = require('net').connect(socketPath);
- client.on('error', function(error) {
- assert.equal(error.code, 'ECONNREFUSED');
- done();
- });
- });
- });
- });
+ it('emit error when connect to a socket path without listeners', function (done) {
+ var socketPath = path.join(os.tmpdir(), 'atom-shell-test.sock')
+ var script = path.join(fixtures, 'module', 'create_socket.js')
+ var child = child_process.fork(script, [socketPath])
+ child.on('exit', function (code) {
+ assert.equal(code, 0)
+ var client = require('net').connect(socketPath)
+ client.on('error', function (error) {
+ assert.equal(error.code, 'ECONNREFUSED')
+ done()
+ })
+ })
+ })
+ })
- describe('Buffer', function() {
- it('can be created from WebKit external string', function() {
- var p = document.createElement('p');
- p.innerText = '闲云潭影日悠悠,物换星移几度秋';
- var b = new Buffer(p.innerText);
- assert.equal(b.toString(), '闲云潭影日悠悠,物换星移几度秋');
- assert.equal(Buffer.byteLength(p.innerText), 45);
- });
+ describe('Buffer', function () {
+ it('can be created from WebKit external string', function () {
+ var p = document.createElement('p')
+ p.innerText = '闲云潭影日悠悠,物换星移几度秋'
+ var b = new Buffer(p.innerText)
+ assert.equal(b.toString(), '闲云潭影日悠悠,物换星移几度秋')
+ assert.equal(Buffer.byteLength(p.innerText), 45)
+ })
- it('correctly parses external one-byte UTF8 string', function() {
- var p = document.createElement('p');
- p.innerText = 'Jøhänñéß';
- var b = new Buffer(p.innerText);
- assert.equal(b.toString(), 'Jøhänñéß');
- assert.equal(Buffer.byteLength(p.innerText), 13);
- });
- });
+ it('correctly parses external one-byte UTF8 string', function () {
+ var p = document.createElement('p')
+ p.innerText = 'Jøhänñéß'
+ var b = new Buffer(p.innerText)
+ assert.equal(b.toString(), 'Jøhänñéß')
+ assert.equal(Buffer.byteLength(p.innerText), 13)
+ })
+ })
- describe('process.stdout', function() {
- it('should not throw exception', function() {
- process.stdout;
- });
+ describe('process.stdout', function () {
+ it('should not throw exception', function () {
+ process.stdout
+ })
- it('should not throw exception when calling write()', function() {
- process.stdout.write('test');
- });
+ it('should not throw exception when calling write()', function () {
+ process.stdout.write('test')
+ })
- xit('should have isTTY defined', function() {
- assert.equal(typeof process.stdout.isTTY, 'boolean');
- });
- });
+ xit('should have isTTY defined', function () {
+ assert.equal(typeof process.stdout.isTTY, 'boolean')
+ })
+ })
- describe('vm.createContext', function() {
- it('should not crash', function() {
- require('vm').runInNewContext('');
- });
- });
-});
+ describe('vm.createContext', function () {
+ it('should not crash', function () {
+ require('vm').runInNewContext('')
+ })
+ })
+})
diff --git a/spec/static/main.js b/spec/static/main.js
index 77a3c3927228..f1d2a5eafa63 100644
--- a/spec/static/main.js
+++ b/spec/static/main.js
@@ -1,81 +1,81 @@
// Disable use of deprecated functions.
-process.throwDeprecation = true;
+process.throwDeprecation = true
-const electron = require('electron');
-const app = electron.app;
-const ipcMain = electron.ipcMain;
-const dialog = electron.dialog;
-const BrowserWindow = electron.BrowserWindow;
+const electron = require('electron')
+const app = electron.app
+const ipcMain = electron.ipcMain
+const dialog = electron.dialog
+const BrowserWindow = electron.BrowserWindow
-const path = require('path');
-const url = require('url');
+const path = require('path')
+const url = require('url')
var argv = require('yargs')
.boolean('ci')
.string('g').alias('g', 'grep')
.boolean('i').alias('i', 'invert')
- .argv;
+ .argv
-var window = null;
-process.port = 0; // will be used by crash-reporter spec.
+var window = null
+process.port = 0; // will be used by crash-reporter spec.
-app.commandLine.appendSwitch('js-flags', '--expose_gc');
-app.commandLine.appendSwitch('ignore-certificate-errors');
-app.commandLine.appendSwitch('disable-renderer-backgrounding');
+app.commandLine.appendSwitch('js-flags', '--expose_gc')
+app.commandLine.appendSwitch('ignore-certificate-errors')
+app.commandLine.appendSwitch('disable-renderer-backgrounding')
// Accessing stdout in the main process will result in the process.stdout
// throwing UnknownSystemError in renderer process sometimes. This line makes
// sure we can reproduce it in renderer process.
-process.stdout;
+process.stdout
// Access console to reproduce #3482.
-console;
+console
-ipcMain.on('message', function(event, arg) {
- event.sender.send('message', arg);
-});
+ipcMain.on('message', function (event, arg) {
+ event.sender.send('message', arg)
+})
-ipcMain.on('console.log', function(event, args) {
- console.error.apply(console, args);
-});
+ipcMain.on('console.log', function (event, args) {
+ console.error.apply(console, args)
+})
-ipcMain.on('console.error', function(event, args) {
- console.error.apply(console, args);
-});
+ipcMain.on('console.error', function (event, args) {
+ console.error.apply(console, args)
+})
-ipcMain.on('process.exit', function(event, code) {
- process.exit(code);
-});
+ipcMain.on('process.exit', function (event, code) {
+ process.exit(code)
+})
-ipcMain.on('eval', function(event, script) {
- event.returnValue = eval(script);
-});
+ipcMain.on('eval', function (event, script) {
+ event.returnValue = eval(script)
+})
-ipcMain.on('echo', function(event, msg) {
- event.returnValue = msg;
-});
+ipcMain.on('echo', function (event, msg) {
+ event.returnValue = msg
+})
-global.isCi = !!argv.ci;
+global.isCi = !!argv.ci
if (global.isCi) {
- process.removeAllListeners('uncaughtException');
- process.on('uncaughtException', function(error) {
- console.error(error, error.stack);
- process.exit(1);
- });
+ process.removeAllListeners('uncaughtException')
+ process.on('uncaughtException', function (error) {
+ console.error(error, error.stack)
+ process.exit(1)
+ })
}
-app.on('window-all-closed', function() {
- app.quit();
-});
+app.on('window-all-closed', function () {
+ app.quit()
+})
-app.on('ready', function() {
+app.on('ready', function () {
// Test if using protocol module would crash.
- electron.protocol.registerStringProtocol('test-if-crashes', function() {});
+ electron.protocol.registerStringProtocol('test-if-crashes', function () {})
// Send auto updater errors to window to be verified in specs
electron.autoUpdater.on('error', function (error) {
- window.send('auto-updater-error', error.message);
- });
+ window.send('auto-updater-error', error.message)
+ })
window = new BrowserWindow({
title: 'Electron Tests',
@@ -83,70 +83,70 @@ app.on('ready', function() {
width: 800,
height: 600,
webPreferences: {
- javascript: true // Test whether web preferences crashes.
+ javascript: true // Test whether web preferences crashes.
},
- });
+ })
window.loadURL(url.format({
pathname: __dirname + '/index.html',
protocol: 'file',
query: {
grep: argv.grep,
- invert: argv.invert ? 'true': ''
+ invert: argv.invert ? 'true' : ''
}
- }));
- window.on('unresponsive', function() {
+ }))
+ window.on('unresponsive', function () {
var chosen = dialog.showMessageBox(window, {
type: 'warning',
buttons: ['Close', 'Keep Waiting'],
message: 'Window is not responsing',
detail: 'The window is not responding. Would you like to force close it or just keep waiting?'
- });
- if (chosen === 0) window.destroy();
- });
+ })
+ if (chosen === 0) window.destroy()
+ })
// For session's download test, listen 'will-download' event in browser, and
// reply the result to renderer for verifying
- var downloadFilePath = path.join(__dirname, '..', 'fixtures', 'mock.pdf');
- ipcMain.on('set-download-option', function(event, need_cancel, prevent_default) {
- window.webContents.session.once('will-download', function(e, item) {
+ var downloadFilePath = path.join(__dirname, '..', 'fixtures', 'mock.pdf')
+ ipcMain.on('set-download-option', function (event, need_cancel, prevent_default) {
+ window.webContents.session.once('will-download', function (e, item) {
if (prevent_default) {
- e.preventDefault();
- const url = item.getURL();
- const filename = item.getFilename();
- setImmediate(function() {
+ e.preventDefault()
+ const url = item.getURL()
+ const filename = item.getFilename()
+ setImmediate(function () {
try {
- item.getURL();
+ item.getURL()
} catch(err) {
- window.webContents.send('download-error', url, filename, err.message);
+ window.webContents.send('download-error', url, filename, err.message)
}
- });
+ })
} else {
- item.setSavePath(downloadFilePath);
- item.on('done', function(e, state) {
+ item.setSavePath(downloadFilePath)
+ item.on('done', function (e, state) {
window.webContents.send('download-done',
- state,
- item.getURL(),
- item.getMimeType(),
- item.getReceivedBytes(),
- item.getTotalBytes(),
- item.getContentDisposition(),
- item.getFilename());
- });
+ state,
+ item.getURL(),
+ item.getMimeType(),
+ item.getReceivedBytes(),
+ item.getTotalBytes(),
+ item.getContentDisposition(),
+ item.getFilename())
+ })
if (need_cancel)
- item.cancel();
+ item.cancel()
}
- });
- event.returnValue = "done";
- });
+ })
+ event.returnValue = 'done'
+ })
- ipcMain.on('executeJavaScript', function(event, code, hasCallback) {
+ ipcMain.on('executeJavaScript', function (event, code, hasCallback) {
if (hasCallback) {
window.webContents.executeJavaScript(code, (result) => {
- window.webContents.send('executeJavaScript-response', result);
- });
+ window.webContents.send('executeJavaScript-response', result)
+ })
} else {
- window.webContents.executeJavaScript(code);
- event.returnValue = "success";
+ window.webContents.executeJavaScript(code)
+ event.returnValue = 'success'
}
- });
-});
+ })
+})
diff --git a/spec/webview-spec.js b/spec/webview-spec.js
index 2d0a6282be34..1bb18c0b5e78 100644
--- a/spec/webview-spec.js
+++ b/spec/webview-spec.js
@@ -1,746 +1,746 @@
-const assert = require('assert');
-const path = require('path');
-const http = require('http');
-const url = require('url');
+const assert = require('assert')
+const path = require('path')
+const http = require('http')
+const url = require('url')
-describe(' tag', function() {
- this.timeout(10000);
+describe(' tag', function () {
+ this.timeout(10000)
- var fixtures = path.join(__dirname, 'fixtures');
- var webview = null;
+ var fixtures = path.join(__dirname, 'fixtures')
+ var webview = null
- beforeEach(function() {
- webview = new WebView;
- });
+ beforeEach(function () {
+ webview = new WebView
+ })
- afterEach(function() {
+ afterEach(function () {
if (document.body.contains(webview)) {
- document.body.removeChild(webview);
+ document.body.removeChild(webview)
}
- });
+ })
- describe('src attribute', function() {
- it('specifies the page to load', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'a');
- done();
- });
- webview.src = "file://" + fixtures + "/pages/a.html";
- document.body.appendChild(webview);
- });
+ describe('src attribute', function () {
+ it('specifies the page to load', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'a')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/a.html'
+ document.body.appendChild(webview)
+ })
- it('navigates to new page when changed', function(done) {
- var listener = function() {
- webview.src = "file://" + fixtures + "/pages/b.html";
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'b');
- done();
- });
- webview.removeEventListener('did-finish-load', listener);
- };
- webview.addEventListener('did-finish-load', listener);
- webview.src = "file://" + fixtures + "/pages/a.html";
- document.body.appendChild(webview);
- });
- });
+ it('navigates to new page when changed', function (done) {
+ var listener = function () {
+ webview.src = 'file://' + fixtures + '/pages/b.html'
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'b')
+ done()
+ })
+ webview.removeEventListener('did-finish-load', listener)
+ }
+ webview.addEventListener('did-finish-load', listener)
+ webview.src = 'file://' + fixtures + '/pages/a.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('nodeintegration attribute', function() {
- it('inserts no node symbols when not set', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'undefined undefined undefined undefined');
- done();
- });
- webview.src = "file://" + fixtures + "/pages/c.html";
- document.body.appendChild(webview);
- });
+ describe('nodeintegration attribute', function () {
+ it('inserts no node symbols when not set', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'undefined undefined undefined undefined')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/c.html'
+ document.body.appendChild(webview)
+ })
- it('inserts node symbols when set', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'function object object');
- done();
- });
- webview.setAttribute('nodeintegration', 'on');
- webview.src = "file://" + fixtures + "/pages/d.html";
- document.body.appendChild(webview);
- });
+ it('inserts node symbols when set', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'function object object')
+ done()
+ })
+ webview.setAttribute('nodeintegration', 'on')
+ webview.src = 'file://' + fixtures + '/pages/d.html'
+ document.body.appendChild(webview)
+ })
- it('loads node symbols after POST navigation when set', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'function object object');
- done();
- });
- webview.setAttribute('nodeintegration', 'on');
- webview.src = "file://" + fixtures + "/pages/post.html";
- document.body.appendChild(webview);
- });
+ it('loads node symbols after POST navigation when set', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'function object object')
+ done()
+ })
+ webview.setAttribute('nodeintegration', 'on')
+ webview.src = 'file://' + fixtures + '/pages/post.html'
+ document.body.appendChild(webview)
+ })
if (process.platform !== 'win32' || process.execPath.toLowerCase().indexOf('\\out\\d\\') === -1) {
- it('loads native modules when navigation happens', function(done) {
- var listener = function() {
- webview.removeEventListener('did-finish-load', listener);
- var listener2 = function(e) {
- assert.equal(e.message, 'function');
- done();
- };
- webview.addEventListener('console-message', listener2);
- webview.reload();
- };
- webview.addEventListener('did-finish-load', listener);
- webview.setAttribute('nodeintegration', 'on');
- webview.src = "file://" + fixtures + "/pages/native-module.html";
- document.body.appendChild(webview);
- });
+ it('loads native modules when navigation happens', function (done) {
+ var listener = function () {
+ webview.removeEventListener('did-finish-load', listener)
+ var listener2 = function (e) {
+ assert.equal(e.message, 'function')
+ done()
+ }
+ webview.addEventListener('console-message', listener2)
+ webview.reload()
+ }
+ webview.addEventListener('did-finish-load', listener)
+ webview.setAttribute('nodeintegration', 'on')
+ webview.src = 'file://' + fixtures + '/pages/native-module.html'
+ document.body.appendChild(webview)
+ })
}
- });
+ })
- describe('preload attribute', function() {
- it('loads the script before other scripts in window', function(done) {
- var listener = function(e) {
- assert.equal(e.message, 'function object object');
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.setAttribute('preload', fixtures + "/module/preload.js");
- webview.src = "file://" + fixtures + "/pages/e.html";
- document.body.appendChild(webview);
- });
+ describe('preload attribute', function () {
+ it('loads the script before other scripts in window', function (done) {
+ var listener = function (e) {
+ assert.equal(e.message, 'function object object')
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.setAttribute('preload', fixtures + '/module/preload.js')
+ webview.src = 'file://' + fixtures + '/pages/e.html'
+ document.body.appendChild(webview)
+ })
- it('preload script can still use "process" in required modules when nodeintegration is off', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'object undefined object');
- done();
- });
- webview.setAttribute('preload', fixtures + "/module/preload-node-off.js");
- webview.src = "file://" + fixtures + "/api/blank.html";
- document.body.appendChild(webview);
- });
+ it('preload script can still use "process" in required modules when nodeintegration is off', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'object undefined object')
+ done()
+ })
+ webview.setAttribute('preload', fixtures + '/module/preload-node-off.js')
+ webview.src = 'file://' + fixtures + '/api/blank.html'
+ document.body.appendChild(webview)
+ })
- it('receives ipc message in preload script', function(done) {
- var message = 'boom!';
- var listener = function(e) {
- assert.equal(e.channel, 'pong');
- assert.deepEqual(e.args, [message]);
- webview.removeEventListener('ipc-message', listener);
- done();
- };
- var listener2 = function() {
- webview.send('ping', message);
- webview.removeEventListener('did-finish-load', listener2);
- };
- webview.addEventListener('ipc-message', listener);
- webview.addEventListener('did-finish-load', listener2);
- webview.setAttribute('preload', fixtures + "/module/preload-ipc.js");
- webview.src = "file://" + fixtures + "/pages/e.html";
- document.body.appendChild(webview);
- });
- });
+ it('receives ipc message in preload script', function (done) {
+ var message = 'boom!'
+ var listener = function (e) {
+ assert.equal(e.channel, 'pong')
+ assert.deepEqual(e.args, [message])
+ webview.removeEventListener('ipc-message', listener)
+ done()
+ }
+ var listener2 = function () {
+ webview.send('ping', message)
+ webview.removeEventListener('did-finish-load', listener2)
+ }
+ webview.addEventListener('ipc-message', listener)
+ webview.addEventListener('did-finish-load', listener2)
+ webview.setAttribute('preload', fixtures + '/module/preload-ipc.js')
+ webview.src = 'file://' + fixtures + '/pages/e.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('httpreferrer attribute', function() {
- it('sets the referrer url', function(done) {
- var referrer = 'http://github.com/';
- var listener = function(e) {
- assert.equal(e.message, referrer);
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.setAttribute('httpreferrer', referrer);
- webview.src = "file://" + fixtures + "/pages/referrer.html";
- document.body.appendChild(webview);
- });
- });
+ describe('httpreferrer attribute', function () {
+ it('sets the referrer url', function (done) {
+ var referrer = 'http://github.com/'
+ var listener = function (e) {
+ assert.equal(e.message, referrer)
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.setAttribute('httpreferrer', referrer)
+ webview.src = 'file://' + fixtures + '/pages/referrer.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('useragent attribute', function() {
- it('sets the user agent', function(done) {
- var referrer = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko';
- var listener = function(e) {
- assert.equal(e.message, referrer);
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.setAttribute('useragent', referrer);
- webview.src = "file://" + fixtures + "/pages/useragent.html";
- document.body.appendChild(webview);
- });
- });
+ describe('useragent attribute', function () {
+ it('sets the user agent', function (done) {
+ var referrer = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko'
+ var listener = function (e) {
+ assert.equal(e.message, referrer)
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.setAttribute('useragent', referrer)
+ webview.src = 'file://' + fixtures + '/pages/useragent.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('disablewebsecurity attribute', function() {
- it('does not disable web security when not set', function(done) {
- var src = " ";
- var encoded = btoa(unescape(encodeURIComponent(src)));
- var listener = function(e) {
- assert(/Not allowed to load local resource/.test(e.message));
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.src = "data:text/html;base64," + encoded;
- document.body.appendChild(webview);
- });
+ describe('disablewebsecurity attribute', function () {
+ it('does not disable web security when not set', function (done) {
+ var src = " "
+ var encoded = btoa(unescape(encodeURIComponent(src)))
+ var listener = function (e) {
+ assert(/Not allowed to load local resource/.test(e.message))
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.src = 'data:text/html;base64,' + encoded
+ document.body.appendChild(webview)
+ })
- it('disables web security when set', function(done) {
- var src = " ";
- var encoded = btoa(unescape(encodeURIComponent(src)));
- var listener = function(e) {
- assert.equal(e.message, 'ok');
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.setAttribute('disablewebsecurity', '');
- webview.src = "data:text/html;base64," + encoded;
- document.body.appendChild(webview);
- });
- });
+ it('disables web security when set', function (done) {
+ var src = " "
+ var encoded = btoa(unescape(encodeURIComponent(src)))
+ var listener = function (e) {
+ assert.equal(e.message, 'ok')
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.setAttribute('disablewebsecurity', '')
+ webview.src = 'data:text/html;base64,' + encoded
+ document.body.appendChild(webview)
+ })
+ })
- describe('partition attribute', function() {
- it('inserts no node symbols when not set', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'undefined undefined undefined undefined');
- done();
- });
- webview.src = "file://" + fixtures + "/pages/c.html";
- webview.partition = 'test1';
- document.body.appendChild(webview);
- });
+ describe('partition attribute', function () {
+ it('inserts no node symbols when not set', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'undefined undefined undefined undefined')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/c.html'
+ webview.partition = 'test1'
+ document.body.appendChild(webview)
+ })
- it('inserts node symbols when set', function(done) {
- webview.addEventListener('console-message', function(e) {
- assert.equal(e.message, 'function object object');
- done();
- });
- webview.setAttribute('nodeintegration', 'on');
- webview.src = "file://" + fixtures + "/pages/d.html";
- webview.partition = 'test2';
- document.body.appendChild(webview);
- });
+ it('inserts node symbols when set', function (done) {
+ webview.addEventListener('console-message', function (e) {
+ assert.equal(e.message, 'function object object')
+ done()
+ })
+ webview.setAttribute('nodeintegration', 'on')
+ webview.src = 'file://' + fixtures + '/pages/d.html'
+ webview.partition = 'test2'
+ document.body.appendChild(webview)
+ })
- it('isolates storage for different id', function(done) {
- var listener = function(e) {
- assert.equal(e.message, " 0");
- webview.removeEventListener('console-message', listener);
- done();
- };
- window.localStorage.setItem('test', 'one');
- webview.addEventListener('console-message', listener);
- webview.src = "file://" + fixtures + "/pages/partition/one.html";
- webview.partition = 'test3';
- document.body.appendChild(webview);
- });
+ it('isolates storage for different id', function (done) {
+ var listener = function (e) {
+ assert.equal(e.message, ' 0')
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ window.localStorage.setItem('test', 'one')
+ webview.addEventListener('console-message', listener)
+ webview.src = 'file://' + fixtures + '/pages/partition/one.html'
+ webview.partition = 'test3'
+ document.body.appendChild(webview)
+ })
- it('uses current session storage when no id is provided', function(done) {
- var listener = function(e) {
- assert.equal(e.message, "one 1");
- webview.removeEventListener('console-message', listener);
- done();
- };
- window.localStorage.setItem('test', 'one');
- webview.addEventListener('console-message', listener);
- webview.src = "file://" + fixtures + "/pages/partition/one.html";
- document.body.appendChild(webview);
- });
- });
+ it('uses current session storage when no id is provided', function (done) {
+ var listener = function (e) {
+ assert.equal(e.message, 'one 1')
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ window.localStorage.setItem('test', 'one')
+ webview.addEventListener('console-message', listener)
+ webview.src = 'file://' + fixtures + '/pages/partition/one.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('allowpopups attribute', function() {
- it('can not open new window when not set', function(done) {
- var listener = function(e) {
- assert.equal(e.message, 'null');
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.src = "file://" + fixtures + "/pages/window-open-hide.html";
- document.body.appendChild(webview);
- });
+ describe('allowpopups attribute', function () {
+ it('can not open new window when not set', function (done) {
+ var listener = function (e) {
+ assert.equal(e.message, 'null')
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.src = 'file://' + fixtures + '/pages/window-open-hide.html'
+ document.body.appendChild(webview)
+ })
- it('can open new window when set', function(done) {
- var listener = function(e) {
- assert.equal(e.message, 'window');
- webview.removeEventListener('console-message', listener);
- done();
- };
- webview.addEventListener('console-message', listener);
- webview.setAttribute('allowpopups', 'on');
- webview.src = "file://" + fixtures + "/pages/window-open-hide.html";
- document.body.appendChild(webview);
- });
- });
+ it('can open new window when set', function (done) {
+ var listener = function (e) {
+ assert.equal(e.message, 'window')
+ webview.removeEventListener('console-message', listener)
+ done()
+ }
+ webview.addEventListener('console-message', listener)
+ webview.setAttribute('allowpopups', 'on')
+ webview.src = 'file://' + fixtures + '/pages/window-open-hide.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('new-window event', function() {
- it('emits when window.open is called', function(done) {
- webview.addEventListener('new-window', function(e) {
- assert.equal(e.url, 'http://host/');
- assert.equal(e.frameName, 'host');
- done();
- });
- webview.src = "file://" + fixtures + "/pages/window-open.html";
- document.body.appendChild(webview);
- });
+ describe('new-window event', function () {
+ it('emits when window.open is called', function (done) {
+ webview.addEventListener('new-window', function (e) {
+ assert.equal(e.url, 'http://host/')
+ assert.equal(e.frameName, 'host')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/window-open.html'
+ document.body.appendChild(webview)
+ })
- it('emits when link with target is called', function(done) {
- webview.addEventListener('new-window', function(e) {
- assert.equal(e.url, 'http://host/');
- assert.equal(e.frameName, 'target');
- done();
- });
- webview.src = "file://" + fixtures + "/pages/target-name.html";
- document.body.appendChild(webview);
- });
- });
+ it('emits when link with target is called', function (done) {
+ webview.addEventListener('new-window', function (e) {
+ assert.equal(e.url, 'http://host/')
+ assert.equal(e.frameName, 'target')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/target-name.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('ipc-message event', function() {
- it('emits when guest sends a ipc message to browser', function(done) {
- webview.addEventListener('ipc-message', function(e) {
- assert.equal(e.channel, 'channel');
- assert.deepEqual(e.args, ['arg1', 'arg2']);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/ipc-message.html";
- webview.setAttribute('nodeintegration', 'on');
- document.body.appendChild(webview);
- });
- });
+ describe('ipc-message event', function () {
+ it('emits when guest sends a ipc message to browser', function (done) {
+ webview.addEventListener('ipc-message', function (e) {
+ assert.equal(e.channel, 'channel')
+ assert.deepEqual(e.args, ['arg1', 'arg2'])
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/ipc-message.html'
+ webview.setAttribute('nodeintegration', 'on')
+ document.body.appendChild(webview)
+ })
+ })
- describe('page-title-set event', function() {
- it('emits when title is set', function(done) {
- webview.addEventListener('page-title-set', function(e) {
- assert.equal(e.title, 'test');
- assert(e.explicitSet);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/a.html";
- document.body.appendChild(webview);
- });
- });
+ describe('page-title-set event', function () {
+ it('emits when title is set', function (done) {
+ webview.addEventListener('page-title-set', function (e) {
+ assert.equal(e.title, 'test')
+ assert(e.explicitSet)
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/a.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('page-favicon-updated event', function() {
- it('emits when favicon urls are received', function(done) {
- webview.addEventListener('page-favicon-updated', function(e) {
- assert.equal(e.favicons.length, 2);
- var pageUrl = process.platform === 'win32' ? 'file:///C:/favicon.png' : 'file:///favicon.png';
- assert.equal(e.favicons[0], pageUrl);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/a.html";
- document.body.appendChild(webview);
- });
- });
+ describe('page-favicon-updated event', function () {
+ it('emits when favicon urls are received', function (done) {
+ webview.addEventListener('page-favicon-updated', function (e) {
+ assert.equal(e.favicons.length, 2)
+ var pageUrl = process.platform === 'win32' ? 'file:///C:/favicon.png' : 'file:///favicon.png'
+ assert.equal(e.favicons[0], pageUrl)
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/a.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('will-navigate event', function() {
- it('emits when a url that leads to oustide of the page is clicked', function(done) {
- webview.addEventListener('will-navigate', function(e) {
- assert.equal(e.url, "http://host/");
- done();
- });
- webview.src = "file://" + fixtures + "/pages/webview-will-navigate.html";
- document.body.appendChild(webview);
- });
- });
+ describe('will-navigate event', function () {
+ it('emits when a url that leads to oustide of the page is clicked', function (done) {
+ webview.addEventListener('will-navigate', function (e) {
+ assert.equal(e.url, 'http://host/')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/webview-will-navigate.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('did-navigate event', function() {
- var p = path.join(fixtures, 'pages', 'webview-will-navigate.html');
- p = p.replace(/\\/g, '/');
+ describe('did-navigate event', function () {
+ var p = path.join(fixtures, 'pages', 'webview-will-navigate.html')
+ p = p.replace(/\\/g, '/')
var pageUrl = url.format({
protocol: 'file',
slashes: true,
pathname: p
- });
+ })
- it('emits when a url that leads to outside of the page is clicked', function(done) {
- webview.addEventListener('did-navigate', function(e) {
- assert.equal(e.url, pageUrl);
- done();
- });
- webview.src = pageUrl;
- document.body.appendChild(webview);
- });
- });
+ it('emits when a url that leads to outside of the page is clicked', function (done) {
+ webview.addEventListener('did-navigate', function (e) {
+ assert.equal(e.url, pageUrl)
+ done()
+ })
+ webview.src = pageUrl
+ document.body.appendChild(webview)
+ })
+ })
- describe('did-navigate-in-page event', function() {
- it('emits when an anchor link is clicked', function(done) {
- var p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page.html');
- p = p.replace(/\\/g, '/');
+ describe('did-navigate-in-page event', function () {
+ it('emits when an anchor link is clicked', function (done) {
+ var p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page.html')
+ p = p.replace(/\\/g, '/')
var pageUrl = url.format({
protocol: 'file',
slashes: true,
pathname: p
- });
- webview.addEventListener('did-navigate-in-page', function(e) {
- assert.equal(e.url, pageUrl + "#test_content");
- done();
- });
- webview.src = pageUrl;
- document.body.appendChild(webview);
- });
+ })
+ webview.addEventListener('did-navigate-in-page', function (e) {
+ assert.equal(e.url, pageUrl + '#test_content')
+ done()
+ })
+ webview.src = pageUrl
+ document.body.appendChild(webview)
+ })
- it('emits when window.history.replaceState is called', function(done) {
- webview.addEventListener('did-navigate-in-page', function(e) {
- assert.equal(e.url, "http://host/");
- done();
- });
- webview.src = "file://" + fixtures + "/pages/webview-did-navigate-in-page-with-history.html";
- document.body.appendChild(webview);
- });
+ it('emits when window.history.replaceState is called', function (done) {
+ webview.addEventListener('did-navigate-in-page', function (e) {
+ assert.equal(e.url, 'http://host/')
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/webview-did-navigate-in-page-with-history.html'
+ document.body.appendChild(webview)
+ })
- it('emits when window.location.hash is changed', function(done) {
- var p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page-with-hash.html');
- p = p.replace(/\\/g, '/');
+ it('emits when window.location.hash is changed', function (done) {
+ var p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page-with-hash.html')
+ p = p.replace(/\\/g, '/')
var pageUrl = url.format({
protocol: 'file',
slashes: true,
pathname: p
- });
- webview.addEventListener('did-navigate-in-page', function(e) {
- assert.equal(e.url, pageUrl + "#test");
- done();
- });
- webview.src = pageUrl;
- document.body.appendChild(webview);
- });
- });
+ })
+ webview.addEventListener('did-navigate-in-page', function (e) {
+ assert.equal(e.url, pageUrl + '#test')
+ done()
+ })
+ webview.src = pageUrl
+ document.body.appendChild(webview)
+ })
+ })
- describe('close event', function() {
- it('should fire when interior page calls window.close', function(done) {
- webview.addEventListener('close', function() {
- done();
- });
- webview.src = "file://" + fixtures + "/pages/close.html";
- document.body.appendChild(webview);
- });
- });
+ describe('close event', function () {
+ it('should fire when interior page calls window.close', function (done) {
+ webview.addEventListener('close', function () {
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/close.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('devtools-opened event', function() {
- it('should fire when webview.openDevTools() is called', function(done) {
- var listener = function() {
- webview.removeEventListener('devtools-opened', listener);
- webview.closeDevTools();
- done();
- };
- webview.addEventListener('devtools-opened', listener);
- webview.addEventListener('dom-ready', function() {
- webview.openDevTools();
- });
- webview.src = "file://" + fixtures + "/pages/base-page.html";
- document.body.appendChild(webview);
- });
- });
+ describe('devtools-opened event', function () {
+ it('should fire when webview.openDevTools() is called', function (done) {
+ var listener = function () {
+ webview.removeEventListener('devtools-opened', listener)
+ webview.closeDevTools()
+ done()
+ }
+ webview.addEventListener('devtools-opened', listener)
+ webview.addEventListener('dom-ready', function () {
+ webview.openDevTools()
+ })
+ webview.src = 'file://' + fixtures + '/pages/base-page.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('devtools-closed event', function() {
- it('should fire when webview.closeDevTools() is called', function(done) {
- var listener2 = function() {
- webview.removeEventListener('devtools-closed', listener2);
- done();
- };
- var listener = function() {
- webview.removeEventListener('devtools-opened', listener);
- webview.closeDevTools();
- };
- webview.addEventListener('devtools-opened', listener);
- webview.addEventListener('devtools-closed', listener2);
- webview.addEventListener('dom-ready', function() {
- webview.openDevTools();
- });
- webview.src = "file://" + fixtures + "/pages/base-page.html";
- document.body.appendChild(webview);
- });
- });
+ describe('devtools-closed event', function () {
+ it('should fire when webview.closeDevTools() is called', function (done) {
+ var listener2 = function () {
+ webview.removeEventListener('devtools-closed', listener2)
+ done()
+ }
+ var listener = function () {
+ webview.removeEventListener('devtools-opened', listener)
+ webview.closeDevTools()
+ }
+ webview.addEventListener('devtools-opened', listener)
+ webview.addEventListener('devtools-closed', listener2)
+ webview.addEventListener('dom-ready', function () {
+ webview.openDevTools()
+ })
+ webview.src = 'file://' + fixtures + '/pages/base-page.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('devtools-focused event', function() {
- it('should fire when webview.openDevTools() is called', function(done) {
- var listener = function() {
- webview.removeEventListener('devtools-focused', listener);
- webview.closeDevTools();
- done();
- };
- webview.addEventListener('devtools-focused', listener);
- webview.addEventListener('dom-ready', function() {
- webview.openDevTools();
- });
- webview.src = "file://" + fixtures + "/pages/base-page.html";
- document.body.appendChild(webview);
- });
- });
+ describe('devtools-focused event', function () {
+ it('should fire when webview.openDevTools() is called', function (done) {
+ var listener = function () {
+ webview.removeEventListener('devtools-focused', listener)
+ webview.closeDevTools()
+ done()
+ }
+ webview.addEventListener('devtools-focused', listener)
+ webview.addEventListener('dom-ready', function () {
+ webview.openDevTools()
+ })
+ webview.src = 'file://' + fixtures + '/pages/base-page.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('.reload()', function() {
- it('should emit beforeunload handler', function(done) {
- var listener = function(e) {
- assert.equal(e.channel, 'onbeforeunload');
- webview.removeEventListener('ipc-message', listener);
- done();
- };
- var listener2 = function() {
- webview.reload();
- webview.removeEventListener('did-finish-load', listener2);
- };
- webview.addEventListener('ipc-message', listener);
- webview.addEventListener('did-finish-load', listener2);
- webview.setAttribute('nodeintegration', 'on');
- webview.src = "file://" + fixtures + "/pages/beforeunload-false.html";
- document.body.appendChild(webview);
- });
- });
+ describe('.reload()', function () {
+ it('should emit beforeunload handler', function (done) {
+ var listener = function (e) {
+ assert.equal(e.channel, 'onbeforeunload')
+ webview.removeEventListener('ipc-message', listener)
+ done()
+ }
+ var listener2 = function () {
+ webview.reload()
+ webview.removeEventListener('did-finish-load', listener2)
+ }
+ webview.addEventListener('ipc-message', listener)
+ webview.addEventListener('did-finish-load', listener2)
+ webview.setAttribute('nodeintegration', 'on')
+ webview.src = 'file://' + fixtures + '/pages/beforeunload-false.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('.clearHistory()', function() {
- it('should clear the navigation history', function(done) {
- var listener = function(e) {
- assert.equal(e.channel, 'history');
- assert.equal(e.args[0], 2);
- assert(webview.canGoBack());
- webview.clearHistory();
- assert(!webview.canGoBack());
- webview.removeEventListener('ipc-message', listener);
- done();
- };
- webview.addEventListener('ipc-message', listener);
- webview.setAttribute('nodeintegration', 'on');
- webview.src = "file://" + fixtures + "/pages/history.html";
- document.body.appendChild(webview);
- });
- });
+ describe('.clearHistory()', function () {
+ it('should clear the navigation history', function (done) {
+ var listener = function (e) {
+ assert.equal(e.channel, 'history')
+ assert.equal(e.args[0], 2)
+ assert(webview.canGoBack())
+ webview.clearHistory()
+ assert(!webview.canGoBack())
+ webview.removeEventListener('ipc-message', listener)
+ done()
+ }
+ webview.addEventListener('ipc-message', listener)
+ webview.setAttribute('nodeintegration', 'on')
+ webview.src = 'file://' + fixtures + '/pages/history.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('basic auth', function() {
- var auth = require('basic-auth');
+ describe('basic auth', function () {
+ var auth = require('basic-auth')
- it('should authenticate with correct credentials', function(done) {
- var message = 'Authenticated';
- var server = http.createServer(function(req, res) {
- var credentials = auth(req);
+ it('should authenticate with correct credentials', function (done) {
+ var message = 'Authenticated'
+ var server = http.createServer(function (req, res) {
+ var credentials = auth(req)
if (credentials.name === 'test' && credentials.pass === 'test') {
- res.end(message);
+ res.end(message)
} else {
- res.end('failed');
+ res.end('failed')
}
- server.close();
- });
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- webview.addEventListener('ipc-message', function(e) {
- assert.equal(e.channel, message);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/basic-auth.html?port=" + port;
- webview.setAttribute('nodeintegration', 'on');
- document.body.appendChild(webview);
- });
- });
- });
+ server.close()
+ })
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ webview.addEventListener('ipc-message', function (e) {
+ assert.equal(e.channel, message)
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/basic-auth.html?port=' + port
+ webview.setAttribute('nodeintegration', 'on')
+ document.body.appendChild(webview)
+ })
+ })
+ })
- describe('dom-ready event', function() {
- it('emits when document is loaded', function(done) {
- var server = http.createServer(function() {});
- server.listen(0, '127.0.0.1', function() {
- var port = server.address().port;
- webview.addEventListener('dom-ready', function() {
- done();
- });
- webview.src = "file://" + fixtures + "/pages/dom-ready.html?port=" + port;
- document.body.appendChild(webview);
- });
- });
+ describe('dom-ready event', function () {
+ it('emits when document is loaded', function (done) {
+ var server = http.createServer(function () {})
+ server.listen(0, '127.0.0.1', function () {
+ var port = server.address().port
+ webview.addEventListener('dom-ready', function () {
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/dom-ready.html?port=' + port
+ document.body.appendChild(webview)
+ })
+ })
- it('throws a custom error when an API method is called before the event is emitted', function() {
+ it('throws a custom error when an API method is called before the event is emitted', function () {
assert.throws(function () {
- webview.stop();
- }, 'Cannot call stop because the webContents is unavailable. The WebView must be attached to the DOM and the dom-ready event emitted before this method can be called.');
- });
- });
+ webview.stop()
+ }, 'Cannot call stop because the webContents is unavailable. The WebView must be attached to the DOM and the dom-ready event emitted before this method can be called.')
+ })
+ })
- describe('executeJavaScript', function() {
- it('should support user gesture', function(done) {
+ describe('executeJavaScript', function () {
+ it('should support user gesture', function (done) {
if (process.env.TRAVIS !== 'true' || process.platform == 'darwin')
- return done();
+ return done()
- var listener = function() {
- webview.removeEventListener('enter-html-full-screen', listener);
- done();
- };
- var listener2 = function() {
- var jsScript = "document.querySelector('video').webkitRequestFullscreen()";
- webview.executeJavaScript(jsScript, true);
- webview.removeEventListener('did-finish-load', listener2);
- };
- webview.addEventListener('enter-html-full-screen', listener);
- webview.addEventListener('did-finish-load', listener2);
- webview.src = "file://" + fixtures + "/pages/fullscreen.html";
- document.body.appendChild(webview);
- });
+ var listener = function () {
+ webview.removeEventListener('enter-html-full-screen', listener)
+ done()
+ }
+ var listener2 = function () {
+ var jsScript = "document.querySelector('video').webkitRequestFullscreen()"
+ webview.executeJavaScript(jsScript, true)
+ webview.removeEventListener('did-finish-load', listener2)
+ }
+ webview.addEventListener('enter-html-full-screen', listener)
+ webview.addEventListener('did-finish-load', listener2)
+ webview.src = 'file://' + fixtures + '/pages/fullscreen.html'
+ document.body.appendChild(webview)
+ })
- it('can return the result of the executed script', function(done) {
+ it('can return the result of the executed script', function (done) {
if (process.env.TRAVIS === 'true' && process.platform == 'darwin')
- return done();
+ return done()
- var listener = function() {
- var jsScript = "'4'+2";
- webview.executeJavaScript(jsScript, false, function(result) {
- assert.equal(result, '42');
- done();
- });
- webview.removeEventListener('did-finish-load', listener);
- };
- webview.addEventListener('did-finish-load', listener);
- webview.src = "about:blank";
- document.body.appendChild(webview);
- });
- });
+ var listener = function () {
+ var jsScript = "'4'+2"
+ webview.executeJavaScript(jsScript, false, function (result) {
+ assert.equal(result, '42')
+ done()
+ })
+ webview.removeEventListener('did-finish-load', listener)
+ }
+ webview.addEventListener('did-finish-load', listener)
+ webview.src = 'about:blank'
+ document.body.appendChild(webview)
+ })
+ })
- describe('sendInputEvent', function() {
- it('can send keyboard event', function(done) {
- webview.addEventListener('ipc-message', function(e) {
- assert.equal(e.channel, 'keyup');
- assert.deepEqual(e.args, [67, true, false]);
- done();
- });
- webview.addEventListener('dom-ready', function() {
+ describe('sendInputEvent', function () {
+ it('can send keyboard event', function (done) {
+ webview.addEventListener('ipc-message', function (e) {
+ assert.equal(e.channel, 'keyup')
+ assert.deepEqual(e.args, [67, true, false])
+ done()
+ })
+ webview.addEventListener('dom-ready', function () {
webview.sendInputEvent({
type: 'keyup',
keyCode: 'c',
modifiers: ['shift']
- });
- });
- webview.src = "file://" + fixtures + "/pages/onkeyup.html";
- webview.setAttribute('nodeintegration', 'on');
- document.body.appendChild(webview);
- });
+ })
+ })
+ webview.src = 'file://' + fixtures + '/pages/onkeyup.html'
+ webview.setAttribute('nodeintegration', 'on')
+ document.body.appendChild(webview)
+ })
- it('can send mouse event', function(done) {
- webview.addEventListener('ipc-message', function(e) {
- assert.equal(e.channel, 'mouseup');
- assert.deepEqual(e.args, [10, 20, false, true]);
- done();
- });
- webview.addEventListener('dom-ready', function() {
+ it('can send mouse event', function (done) {
+ webview.addEventListener('ipc-message', function (e) {
+ assert.equal(e.channel, 'mouseup')
+ assert.deepEqual(e.args, [10, 20, false, true])
+ done()
+ })
+ webview.addEventListener('dom-ready', function () {
webview.sendInputEvent({
type: 'mouseup',
modifiers: ['ctrl'],
x: 10,
y: 20
- });
- });
- webview.src = "file://" + fixtures + "/pages/onmouseup.html";
- webview.setAttribute('nodeintegration', 'on');
- document.body.appendChild(webview);
- });
- });
+ })
+ })
+ webview.src = 'file://' + fixtures + '/pages/onmouseup.html'
+ webview.setAttribute('nodeintegration', 'on')
+ document.body.appendChild(webview)
+ })
+ })
- describe('media-started-playing media-paused events', function() {
- it('emits when audio starts and stops playing', function(done) {
- var audioPlayed = false;
- webview.addEventListener('media-started-playing', function() {
- audioPlayed = true;
- });
- webview.addEventListener('media-paused', function() {
- assert(audioPlayed);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/audio.html";
- document.body.appendChild(webview);
- });
- });
+ describe('media-started-playing media-paused events', function () {
+ it('emits when audio starts and stops playing', function (done) {
+ var audioPlayed = false
+ webview.addEventListener('media-started-playing', function () {
+ audioPlayed = true
+ })
+ webview.addEventListener('media-paused', function () {
+ assert(audioPlayed)
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/audio.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('found-in-page event', function() {
- it('emits when a request is made', function(done) {
- var requestId = null;
- var totalMatches = null;
- var activeMatchOrdinal = [];
- var listener = function(e) {
- assert.equal(e.result.requestId, requestId);
+ describe('found-in-page event', function () {
+ it('emits when a request is made', function (done) {
+ var requestId = null
+ var totalMatches = null
+ var activeMatchOrdinal = []
+ var listener = function (e) {
+ assert.equal(e.result.requestId, requestId)
if (e.result.finalUpdate) {
- assert.equal(e.result.matches, 3);
- totalMatches = e.result.matches;
- listener2();
+ assert.equal(e.result.matches, 3)
+ totalMatches = e.result.matches
+ listener2()
} else {
- activeMatchOrdinal.push(e.result.activeMatchOrdinal);
+ activeMatchOrdinal.push(e.result.activeMatchOrdinal)
if (e.result.activeMatchOrdinal == totalMatches) {
- assert.deepEqual(activeMatchOrdinal, [1, 2, 3]);
- webview.stopFindInPage("clearSelection");
- done();
+ assert.deepEqual(activeMatchOrdinal, [1, 2, 3])
+ webview.stopFindInPage('clearSelection')
+ done()
}
}
- };
- var listener2 = function() {
- requestId = webview.findInPage("virtual");
- };
- webview.addEventListener('found-in-page', listener);
- webview.addEventListener('did-finish-load', listener2);
- webview.src = "file://" + fixtures + "/pages/content.html";
- document.body.appendChild(webview);
- });
- });
+ }
+ var listener2 = function () {
+ requestId = webview.findInPage('virtual')
+ }
+ webview.addEventListener('found-in-page', listener)
+ webview.addEventListener('did-finish-load', listener2)
+ webview.src = 'file://' + fixtures + '/pages/content.html'
+ document.body.appendChild(webview)
+ })
+ })
- xdescribe('did-change-theme-color event', function() {
- it('emits when theme color changes', function(done) {
- webview.addEventListener('did-change-theme-color', function() {
- done();
- });
- webview.src = "file://" + fixtures + "/pages/theme-color.html";
- document.body.appendChild(webview);
- });
- });
+ xdescribe('did-change-theme-color event', function () {
+ it('emits when theme color changes', function (done) {
+ webview.addEventListener('did-change-theme-color', function () {
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/theme-color.html'
+ document.body.appendChild(webview)
+ })
+ })
- describe('permission-request event', function() {
- function setUpRequestHandler(webview, requested_permission) {
- const session = require('electron').remote.session;
- var listener = function(webContents, permission, callback) {
- if (webContents.getId() === webview.getId() ) {
- assert.equal(permission, requested_permission);
- callback(false);
+ describe('permission-request event', function () {
+ function setUpRequestHandler (webview, requested_permission) {
+ const session = require('electron').remote.session
+ var listener = function (webContents, permission, callback) {
+ if (webContents.getId() === webview.getId()) {
+ assert.equal(permission, requested_permission)
+ callback(false)
}
- };
- session.fromPartition(webview.partition).setPermissionRequestHandler(listener);
+ }
+ session.fromPartition(webview.partition).setPermissionRequestHandler(listener)
}
- it('emits when using navigator.getUserMedia api', function(done) {
- webview.addEventListener('ipc-message', function(e) {
- assert(e.channel, 'message');
- assert(e.args, ['PermissionDeniedError']);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/permissions/media.html";
- webview.partition = "permissionTest";
- webview.setAttribute('nodeintegration', 'on');
- setUpRequestHandler(webview, "media");
- document.body.appendChild(webview);
- });
+ it('emits when using navigator.getUserMedia api', function (done) {
+ webview.addEventListener('ipc-message', function (e) {
+ assert(e.channel, 'message')
+ assert(e.args, ['PermissionDeniedError'])
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/permissions/media.html'
+ webview.partition = 'permissionTest'
+ webview.setAttribute('nodeintegration', 'on')
+ setUpRequestHandler(webview, 'media')
+ document.body.appendChild(webview)
+ })
- it('emits when using navigator.geolocation api', function(done) {
- webview.addEventListener('ipc-message', function(e) {
- assert(e.channel, 'message');
- assert(e.args, ['ERROR(1): User denied Geolocation']);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/permissions/geolocation.html";
- webview.partition = "permissionTest";
- webview.setAttribute('nodeintegration', 'on');
- setUpRequestHandler(webview, "geolocation");
- document.body.appendChild(webview);
- });
+ it('emits when using navigator.geolocation api', function (done) {
+ webview.addEventListener('ipc-message', function (e) {
+ assert(e.channel, 'message')
+ assert(e.args, ['ERROR(1): User denied Geolocation'])
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/permissions/geolocation.html'
+ webview.partition = 'permissionTest'
+ webview.setAttribute('nodeintegration', 'on')
+ setUpRequestHandler(webview, 'geolocation')
+ document.body.appendChild(webview)
+ })
- it('emits when using navigator.requestMIDIAccess api', function(done) {
- webview.addEventListener('ipc-message', function(e) {
- assert(e.channel, 'message');
- assert(e.args, ['SecurityError']);
- done();
- });
- webview.src = "file://" + fixtures + "/pages/permissions/midi.html";
- webview.partition = "permissionTest";
- webview.setAttribute('nodeintegration', 'on');
- setUpRequestHandler(webview, "midiSysex");
- document.body.appendChild(webview);
- });
- });
+ it('emits when using navigator.requestMIDIAccess api', function (done) {
+ webview.addEventListener('ipc-message', function (e) {
+ assert(e.channel, 'message')
+ assert(e.args, ['SecurityError'])
+ done()
+ })
+ webview.src = 'file://' + fixtures + '/pages/permissions/midi.html'
+ webview.partition = 'permissionTest'
+ webview.setAttribute('nodeintegration', 'on')
+ setUpRequestHandler(webview, 'midiSysex')
+ document.body.appendChild(webview)
+ })
+ })
- describe('.getWebContents', function() {
- it('can return the webcontents associated', function(done) {
- webview.addEventListener('did-finish-load', function() {
- const webviewContents = webview.getWebContents();
- assert(webviewContents);
- assert.equal(webviewContents.getURL(), 'about:blank');
- done();
- });
- webview.src = "about:blank";
- document.body.appendChild(webview);
- });
- });
-});
+ describe('.getWebContents', function () {
+ it('can return the webcontents associated', function (done) {
+ webview.addEventListener('did-finish-load', function () {
+ const webviewContents = webview.getWebContents()
+ assert(webviewContents)
+ assert.equal(webviewContents.getURL(), 'about:blank')
+ done()
+ })
+ webview.src = 'about:blank'
+ document.body.appendChild(webview)
+ })
+ })
+})
diff --git a/tools/dump-version-info.js b/tools/dump-version-info.js
index e76f09ba2f9b..b4b44fe61aa7 100644
--- a/tools/dump-version-info.js
+++ b/tools/dump-version-info.js
@@ -1,31 +1,31 @@
-var app = require('app');
-var fs = require('fs');
-var path = require('path');
-var request = require('request');
+var app = require('app')
+var fs = require('fs')
+var path = require('path')
+var request = require('request')
-var TARGET_URL = 'https://atom.io/download/atom-shell/index.json';
+var TARGET_URL = 'https://atom.io/download/atom-shell/index.json'
-function getDate() {
- var today = new Date();
- var year = today.getFullYear();
- var month = today.getMonth() + 1;
+function getDate () {
+ var today = new Date()
+ var year = today.getFullYear()
+ var month = today.getMonth() + 1
if (month <= 9)
- month = '0' + month;
- var day= today.getDate();
+ month = '0' + month
+ var day = today.getDate()
if (day <= 9)
- day = '0' + day;
- return year + '-' + month + '-' + day;
+ day = '0' + day
+ return year + '-' + month + '-' + day
}
-function getInfoForCurrentVersion() {
- var json = {};
- json.version = process.versions['atom-shell'];
- json.date = getDate();
+function getInfoForCurrentVersion () {
+ var json = {}
+ json.version = process.versions['atom-shell']
+ json.date = getDate()
var names = ['node', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'chrome']
for (var i in names) {
- var name = names[i];
- json[name] = process.versions[name];
+ var name = names[i]
+ json[name] = process.versions[name]
}
json.files = [
@@ -39,44 +39,44 @@ function getInfoForCurrentVersion() {
'win32-ia32-symbols',
'win32-x64',
'win32-x64-symbols',
- ];
+ ]
- return json;
+ return json
}
-function getIndexJsInServer(callback) {
- request(TARGET_URL, function(e, res, body) {
+function getIndexJsInServer (callback) {
+ request(TARGET_URL, function (e, res, body) {
if (e)
- callback(e);
+ callback(e)
else if (res.statusCode != 200)
- callback(new Error('Server returned ' + res.statusCode));
+ callback(new Error('Server returned ' + res.statusCode))
else
- callback(null, JSON.parse(body));
- });
+ callback(null, JSON.parse(body))
+ })
}
-function findObjectByVersion(all, version) {
+function findObjectByVersion (all, version) {
for (var i in all)
if (all[i].version == version)
- return i;
- return -1;
+ return i
+ return -1
}
-app.on('ready', function() {
- getIndexJsInServer(function(e, all) {
+app.on('ready', function () {
+ getIndexJsInServer(function (e, all) {
if (e) {
- console.error(e);
- process.exit(1);
+ console.error(e)
+ process.exit(1)
}
- var current = getInfoForCurrentVersion();
- var found = findObjectByVersion(all, current.version);
+ var current = getInfoForCurrentVersion()
+ var found = findObjectByVersion(all, current.version)
if (found == -1)
- all.unshift(current);
+ all.unshift(current)
else
- all[found] = current;
+ all[found] = current
- fs.writeFileSync(process.argv[2], JSON.stringify(all));
- process.exit(0);
- });
-});
+ fs.writeFileSync(process.argv[2], JSON.stringify(all))
+ process.exit(0)
+ })
+})
diff --git a/tools/win/register_msdia80_dll.js b/tools/win/register_msdia80_dll.js
index 5691ef9caf5a..e90b9714d1f1 100644
--- a/tools/win/register_msdia80_dll.js
+++ b/tools/win/register_msdia80_dll.js
@@ -1,12 +1,12 @@
-var fs = require('fs');
-var path = require('path');
-var runas = require('runas');
+var fs = require('fs')
+var path = require('path')
+var runas = require('runas')
-var source = path.resolve(__dirname, '..', '..', 'vendor', 'breakpad', 'msdia80.dll');
-var target = 'C:\\Program Files\\Common Files\\Microsoft Shared\\VC\\msdia80.dll';
-if (fs.existsSync(target))
- return;
+var source = path.resolve(__dirname, '..', '..', 'vendor', 'breakpad', 'msdia80.dll')
+var target = 'C:\\Program Files\\Common Files\\Microsoft Shared\\VC\\msdia80.dll'
-runas('cmd',
- ['/K', 'copy', source, target, '&', 'regsvr32', '/s', target, '&', 'exit'],
- {admin: true});
+if (!fs.existsSync(target)) {
+ runas('cmd',
+ ['/K', 'copy', source, target, '&', 'regsvr32', '/s', target, '&', 'exit'],
+ {admin: true})
+}