This commit is contained in:
Kevin Sawicki 2016-02-17 09:27:25 -08:00
Родитель 54d7c580bd
Коммит 31028ab636
10 изменённых файлов: 110 добавлений и 181 удалений

Просмотреть файл

@ -66,11 +66,10 @@ describe('app module', function() {
});
it('emits a process exit event with the code', function(done) {
var appPath, electronPath, output;
appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app');
electronPath = remote.getGlobal('process').execPath;
var appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app');
var electronPath = remote.getGlobal('process').execPath;
var output = '';
appProcess = ChildProcess.spawn(electronPath, [appPath]);
output = '';
appProcess.stdout.on('data', function(data) {
output += data;
});

Просмотреть файл

@ -42,9 +42,8 @@ describe('browser-window module', function() {
w.close();
});
w.on('closed', function() {
var content, test;
test = path.join(fixtures, 'api', 'unload');
content = fs.readFileSync(test);
var test = path.join(fixtures, 'api', 'unload');
var content = fs.readFileSync(test);
fs.unlinkSync(test);
assert.equal(String(content), 'unload');
done();
@ -66,9 +65,8 @@ describe('browser-window module', function() {
describe('window.close()', function() {
it('should emit unload handler', function(done) {
w.on('closed', function() {
var content, test;
test = path.join(fixtures, 'api', 'close');
content = fs.readFileSync(test);
var test = path.join(fixtures, 'api', 'close');
var content = fs.readFileSync(test);
fs.unlinkSync(test);
assert.equal(String(content), 'close');
done();
@ -86,8 +84,7 @@ describe('browser-window module', function() {
describe('BrowserWindow.destroy()', function() {
it('prevents users to access methods of webContents', function() {
var webContents;
webContents = w.webContents;
var webContents = w.webContents;
w.destroy();
assert.throws((function() {
webContents.getId();
@ -178,8 +175,7 @@ describe('browser-window module', function() {
it('sets the window position', function(done) {
var pos = [10, 10];
w.once('move', function() {
var newPos;
newPos = w.getPosition();
var newPos = w.getPosition();
assert.equal(newPos[0], pos[0]);
assert.equal(newPos[1], pos[1]);
done();
@ -190,16 +186,14 @@ describe('browser-window module', function() {
describe('BrowserWindow.setContentSize(width, height)', function() {
it('sets the content size', function() {
var after, size;
size = [400, 400];
var size = [400, 400];
w.setContentSize(size[0], size[1]);
after = w.getContentSize();
var after = w.getContentSize();
assert.equal(after[0], size[0]);
assert.equal(after[1], size[1]);
});
it('works for framless window', function() {
var after, size;
w.destroy();
w = new BrowserWindow({
show: false,
@ -207,9 +201,9 @@ describe('browser-window module', function() {
width: 400,
height: 400
});
size = [400, 400];
var size = [400, 400];
w.setContentSize(size[0], size[1]);
after = w.getContentSize();
var after = w.getContentSize();
assert.equal(after[0], size[0]);
assert.equal(after[1], size[1]);
});
@ -223,7 +217,6 @@ describe('browser-window module', function() {
describe('"useContentSize" option', function() {
it('make window created with content size when used', function() {
var contentSize;
w.destroy();
w = new BrowserWindow({
show: false,
@ -231,7 +224,7 @@ describe('browser-window module', function() {
height: 400,
useContentSize: true
});
contentSize = w.getContentSize();
var contentSize = w.getContentSize();
assert.equal(contentSize[0], 400);
assert.equal(contentSize[1], 400);
});
@ -243,7 +236,6 @@ describe('browser-window module', function() {
});
it('works for framless window', function() {
var contentSize, size;
w.destroy();
w = new BrowserWindow({
show: false,
@ -252,10 +244,10 @@ describe('browser-window module', function() {
height: 400,
useContentSize: true
});
contentSize = w.getContentSize();
var contentSize = w.getContentSize();
assert.equal(contentSize[0], 400);
assert.equal(contentSize[1], 400);
size = w.getSize();
var size = w.getSize();
assert.equal(size[0], 400);
assert.equal(size[1], 400);
});
@ -270,7 +262,6 @@ describe('browser-window module', function() {
}
it('creates browser window with hidden title bar', function() {
var contentSize;
w.destroy();
w = new BrowserWindow({
show: false,
@ -278,12 +269,11 @@ describe('browser-window module', function() {
height: 400,
titleBarStyle: 'hidden'
});
contentSize = w.getContentSize();
var contentSize = w.getContentSize();
assert.equal(contentSize[1], 400);
});
it('creates browser window with hidden inset title bar', function() {
var contentSize;
w.destroy();
w = new BrowserWindow({
show: false,
@ -291,7 +281,7 @@ describe('browser-window module', function() {
height: 400,
titleBarStyle: 'hidden-inset'
});
contentSize = w.getContentSize();
var contentSize = w.getContentSize();
assert.equal(contentSize[1], 400);
});
});
@ -312,20 +302,18 @@ describe('browser-window module', function() {
});
it('can move the window out of screen', function() {
var after;
w.setPosition(-10, -10);
after = w.getPosition();
var after = w.getPosition();
assert.equal(after[0], -10);
assert.equal(after[1], -10);
});
it('can set the window larger than screen', function() {
var after, size;
size = screen.getPrimaryDisplay().size;
var size = screen.getPrimaryDisplay().size;
size.width += 100;
size.height += 100;
w.setSize(size.width, size.height);
after = w.getSize();
var after = w.getSize();
assert.equal(after[0], size.width);
assert.equal(after[1], size.height);
});
@ -338,8 +326,7 @@ describe('browser-window module', function() {
describe('"preload" option', function() {
it('loads the script before other scripts in window', function(done) {
var preload;
preload = path.join(fixtures, 'module', 'set-global.js');
var preload = path.join(fixtures, 'module', 'set-global.js');
ipcMain.once('answer', function(event, test) {
assert.equal(test, 'preload');
done();
@ -357,8 +344,7 @@ describe('browser-window module', function() {
describe('"node-integration" option', function() {
it('disables node integration when specified to false', function(done) {
var preload;
preload = path.join(fixtures, 'module', 'send-later.js');
var preload = path.join(fixtures, 'module', 'send-later.js');
ipcMain.once('answer', function(event, test) {
assert.equal(test, 'undefined');
done();
@ -532,10 +518,9 @@ describe('browser-window module', function() {
describe('BrowserWindow options argument is optional', function() {
it('should create a window with default size (800x600)', function() {
var size;
w.destroy();
w = new BrowserWindow();
size = w.getSize();
var size = w.getSize();
assert.equal(size[0], 800);
assert.equal(size[1], 600);
});

Просмотреть файл

@ -37,9 +37,8 @@ describe('crash-reporter module', function() {
var called = false;
var server = http.createServer(function(req, res) {
var form;
server.close();
form = new multiparty.Form();
var form = new multiparty.Form();
form.parse(req, function(error, fields) {
if (called) {
return;

Просмотреть файл

@ -20,9 +20,8 @@ describe('ipc module', function() {
describe('remote.require', function() {
it('should returns same object for the same module', function() {
var dialog1, dialog2;
dialog1 = remote.require('electron');
dialog2 = remote.require('electron');
var dialog1 = remote.require('electron');
var dialog2 = remote.require('electron');
assert.equal(dialog1, dialog2);
});
@ -58,9 +57,8 @@ describe('ipc module', function() {
});
it('can construct an object from its member', function() {
var call, obj;
call = remote.require(path.join(fixtures, 'module', 'call.js'));
obj = new call.constructor;
var call = remote.require(path.join(fixtures, 'module', 'call.js'));
var obj = new call.constructor;
assert.equal(obj.test, 'test');
});
});

Просмотреть файл

@ -31,15 +31,13 @@ describe('session module', function() {
describe('session.cookies', function() {
it('should get cookies', function(done) {
var server;
server = http.createServer(function(req, res) {
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;
port = server.address().port;
var port = server.address().port;
w.loadURL(url + ":" + port);
w.webContents.on('did-finish-load', function() {
w.webContents.session.cookies.get({
@ -136,8 +134,7 @@ describe('session module', function() {
});
w.loadURL('file://' + path.join(fixtures, 'api', 'localstorage.html'));
w.webContents.on('did-finish-load', function() {
var options;
options = {
var options = {
origin: "file://",
storages: ['localstorage'],
quotas: ['persistent']

Просмотреть файл

@ -7,9 +7,8 @@ const session = remote.session;
describe('webRequest module', function() {
var ses = session.defaultSession;
var server = http.createServer(function(req, res) {
var content;
res.setHeader('Custom', ['Header']);
content = req.url;
var content = req.url;
if (req.headers.accept === '*/*;test/header') {
content += 'header/received';
}
@ -19,8 +18,7 @@ describe('webRequest module', function() {
before(function(done) {
server.listen(0, '127.0.0.1', function() {
var port;
port = server.address().port;
var port = server.address().port;
defaultURL = "http://127.0.0.1:" + port + "/";
done();
});
@ -109,11 +107,10 @@ describe('webRequest module', function() {
type: 'string'
};
ses.webRequest.onBeforeRequest(function(details, callback) {
var data;
assert.equal(details.url, defaultURL);
assert.equal(details.method, 'POST');
assert.equal(details.uploadData.length, 1);
data = qs.parse(details.uploadData[0].bytes.toString());
var data = qs.parse(details.uploadData[0].bytes.toString());
assert.deepEqual(data, postData);
callback({
cancel: true
@ -178,8 +175,7 @@ describe('webRequest module', function() {
it('can change the request headers', function(done) {
ses.webRequest.onBeforeSendHeaders(function(details, callback) {
var requestHeaders;
requestHeaders = details.requestHeaders;
var requestHeaders = details.requestHeaders;
requestHeaders.Accept = '*/*;test/header';
callback({
requestHeaders: requestHeaders

Просмотреть файл

@ -128,9 +128,8 @@ describe('asar package', function() {
});
it('returns information of root', function() {
var p, stats;
p = path.join(fixtures, 'asar', 'a.asar');
stats = fs.lstatSync(p);
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);
@ -607,9 +606,8 @@ describe('asar package', function() {
});
it('disables asar support in async API', function(done) {
var dir, file;
file = path.join(fixtures, 'asar', 'a.asar', 'file1');
dir = path.join(fixtures, 'asar', 'a.asar', 'dir1');
var file = path.join(fixtures, 'asar', 'a.asar', 'file1');
var dir = path.join(fixtures, 'asar', 'a.asar', 'dir1');
fs.readFile(file, function(error) {
assert.equal(error.code, errorName);
fs.lstat(file, function(error) {
@ -737,15 +735,13 @@ describe('asar package', function() {
var originalFs = require('original-fs');
it('treats .asar as file', function() {
var file, stats;
file = path.join(fixtures, 'asar', 'a.asar');
stats = originalFs.statSync(file);
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 = child_process.fork(path.join(fixtures, 'module', 'original-fs.js'));
var child = child_process.fork(path.join(fixtures, 'module', 'original-fs.js'));
child.on('message', function(msg) {
assert.equal(msg, 'object');
done();

Просмотреть файл

@ -211,10 +211,9 @@ describe('chromium feature', function() {
var b, sourceId;
sourceId = remote.getCurrentWindow().id;
listener = function(event) {
var message;
window.removeEventListener('message', listener);
b.close();
message = JSON.parse(event.data);
var message = JSON.parse(event.data);
assert.equal(message.data, 'testing');
assert.equal(message.origin, 'file://');
assert.equal(message.sourceEqualsOpener, true);
@ -247,28 +246,25 @@ describe('chromium feature', function() {
describe('creating a Uint8Array under browser side', function() {
it('does not crash', function() {
var RUint8Array;
RUint8Array = remote.getGlobal('Uint8Array');
var RUint8Array = remote.getGlobal('Uint8Array');
new RUint8Array;
});
});
describe('webgl', function() {
it('can be get as context in canvas', function() {
var webgl;
if (process.platform === 'linux') {
return;
}
webgl = document.createElement('canvas').getContext('webgl');
var webgl = document.createElement('canvas').getContext('webgl');
assert.notEqual(webgl, null);
});
});
describe('web workers', function() {
it('Worker can work', function(done) {
var message, worker;
worker = new Worker('../fixtures/workers/worker.js');
message = 'ping';
var worker = new Worker('../fixtures/workers/worker.js');
var message = 'ping';
worker.onmessage = function(event) {
assert.equal(event.data, message);
worker.terminate();
@ -278,9 +274,8 @@ describe('chromium feature', function() {
});
it('SharedWorker can work', function(done) {
var message, worker;
worker = new SharedWorker('../fixtures/workers/shared_worker.js');
message = 'ping';
var worker = new SharedWorker('../fixtures/workers/shared_worker.js');
var message = 'ping';
worker.port.onmessage = function(event) {
assert.equal(event.data, message);
done();
@ -377,8 +372,7 @@ describe('chromium feature', function() {
})
});
remote.getGlobal('setImmediate')(function() {
var called;
called = false;
var called = false;
Promise.resolve().then(function() {
done(called ? void 0 : new Error('wrong sequence'));
});

Просмотреть файл

@ -11,8 +11,7 @@ describe('node feature', function() {
describe('child_process', function() {
describe('child_process.fork', function() {
it('works in current process', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'ping.js'));
var child = child_process.fork(path.join(fixtures, 'module', 'ping.js'));
child.on('message', function(msg) {
assert.equal(msg, 'message');
done();
@ -51,9 +50,8 @@ describe('node feature', function() {
});
it('works in browser process', function(done) {
var child, fork;
fork = remote.require('child_process').fork;
child = fork(path.join(fixtures, 'module', 'ping.js'));
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();
@ -62,8 +60,7 @@ describe('node feature', function() {
});
it('has String::localeCompare working in script', function(done) {
var child;
child = child_process.fork(path.join(fixtures, 'module', 'locale-compare.js'));
var child = child_process.fork(path.join(fixtures, 'module', 'locale-compare.js'));
child.on('message', function(msg) {
assert.deepEqual(msg, [0, -1, 1]);
done();
@ -169,14 +166,12 @@ describe('node feature', function() {
}
it('emit error when connect to a socket path without listeners', function(done) {
var child, script, socketPath;
socketPath = path.join(os.tmpdir(), 'atom-shell-test.sock');
script = path.join(fixtures, 'module', 'create_socket.js');
child = child_process.fork(script, [socketPath]);
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) {
var client;
assert.equal(code, 0);
client = require('net').connect(socketPath);
var client = require('net').connect(socketPath);
client.on('error', function(error) {
assert.equal(error.code, 'ECONNREFUSED');
done();
@ -187,19 +182,17 @@ describe('node feature', function() {
describe('Buffer', function() {
it('can be created from WebKit external string', function() {
var b, p;
p = document.createElement('p');
var p = document.createElement('p');
p.innerText = '闲云潭影日悠悠,物换星移几度秋';
b = new Buffer(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 b, p;
p = document.createElement('p');
var p = document.createElement('p');
p.innerText = 'Jøhänñéß';
b = new Buffer(p.innerText);
var b = new Buffer(p.innerText);
assert.equal(b.toString(), 'Jøhänñéß');
assert.equal(Buffer.byteLength(p.innerText), 13);
});

Просмотреть файл

@ -95,8 +95,7 @@ describe('<webview> tag', function() {
describe('preload attribute', function() {
it('loads the script before other scripts in window', function(done) {
var listener;
listener = function(e) {
var listener = function(e) {
assert.equal(e.message, 'function object object');
webview.removeEventListener('console-message', listener);
done();
@ -118,15 +117,14 @@ describe('<webview> tag', function() {
});
it('receives ipc message in preload script', function(done) {
var listener, listener2, message;
message = 'boom!';
listener = function(e) {
var message = 'boom!';
var listener = function(e) {
assert.equal(e.channel, 'pong');
assert.deepEqual(e.args, [message]);
webview.removeEventListener('ipc-message', listener);
done();
};
listener2 = function() {
var listener2 = function() {
webview.send('ping', message);
webview.removeEventListener('did-finish-load', listener2);
};
@ -140,9 +138,8 @@ describe('<webview> tag', function() {
describe('httpreferrer attribute', function() {
it('sets the referrer url', function(done) {
var listener, referrer;
referrer = 'http://github.com/';
listener = function(e) {
var referrer = 'http://github.com/';
var listener = function(e) {
assert.equal(e.message, referrer);
webview.removeEventListener('console-message', listener);
done();
@ -156,9 +153,8 @@ describe('<webview> tag', function() {
describe('useragent attribute', function() {
it('sets the user agent', function(done) {
var listener, referrer;
referrer = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko';
listener = function(e) {
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();
@ -172,10 +168,9 @@ describe('<webview> tag', function() {
describe('disablewebsecurity attribute', function() {
it('does not disable web security when not set', function(done) {
var encoded, listener, src;
src = "<script src='file://" + __dirname + "/static/jquery-2.0.3.min.js'></script> <script>console.log('ok');</script>";
encoded = btoa(unescape(encodeURIComponent(src)));
listener = function(e) {
var src = "<script src='file://" + __dirname + "/static/jquery-2.0.3.min.js'></script> <script>console.log('ok');</script>";
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();
@ -186,10 +181,9 @@ describe('<webview> tag', function() {
});
it('disables web security when set', function(done) {
var encoded, listener, src;
src = "<script src='file://" + __dirname + "/static/jquery-2.0.3.min.js'></script> <script>console.log('ok');</script>";
encoded = btoa(unescape(encodeURIComponent(src)));
listener = function(e) {
var src = "<script src='file://" + __dirname + "/static/jquery-2.0.3.min.js'></script> <script>console.log('ok');</script>";
var encoded = btoa(unescape(encodeURIComponent(src)));
var listener = function(e) {
assert.equal(e.message, 'ok');
webview.removeEventListener('console-message', listener);
done();
@ -223,8 +217,7 @@ describe('<webview> tag', function() {
});
it('isolates storage for different id', function(done) {
var listener;
listener = function(e) {
var listener = function(e) {
assert.equal(e.message, " 0");
webview.removeEventListener('console-message', listener);
done();
@ -237,8 +230,7 @@ describe('<webview> tag', function() {
});
it('uses current session storage when no id is provided', function(done) {
var listener;
listener = function(e) {
var listener = function(e) {
assert.equal(e.message, "one 1");
webview.removeEventListener('console-message', listener);
done();
@ -252,8 +244,7 @@ describe('<webview> tag', function() {
describe('allowpopups attribute', function() {
it('can not open new window when not set', function(done) {
var listener;
listener = function(e) {
var listener = function(e) {
assert.equal(e.message, 'null');
webview.removeEventListener('console-message', listener);
done();
@ -264,8 +255,7 @@ describe('<webview> tag', function() {
});
it('can open new window when set', function(done) {
var listener;
listener = function(e) {
var listener = function(e) {
assert.equal(e.message, 'window');
webview.removeEventListener('console-message', listener);
done();
@ -327,9 +317,8 @@ describe('<webview> tag', function() {
describe('page-favicon-updated event', function() {
it('emits when favicon urls are received', function(done) {
webview.addEventListener('page-favicon-updated', function(e) {
var pageUrl;
assert.equal(e.favicons.length, 2);
pageUrl = process.platform === 'win32' ? 'file:///C:/favicon.png' : 'file:///favicon.png';
var pageUrl = process.platform === 'win32' ? 'file:///C:/favicon.png' : 'file:///favicon.png';
assert.equal(e.favicons[0], pageUrl);
done();
});
@ -350,10 +339,9 @@ describe('<webview> tag', function() {
});
describe('did-navigate event', function() {
var p, pageUrl;
p = path.join(fixtures, 'pages', 'webview-will-navigate.html');
var p = path.join(fixtures, 'pages', 'webview-will-navigate.html');
p = p.replace(/\\/g, '/');
pageUrl = url.format({
var pageUrl = url.format({
protocol: 'file',
slashes: true,
pathname: p
@ -370,10 +358,9 @@ describe('<webview> tag', function() {
});
describe('did-navigate-in-page event', function() {
it('emits when an anchor link is clicked', function(done) {
var p, pageUrl;
p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page.html');
var p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page.html');
p = p.replace(/\\/g, '/');
pageUrl = url.format({
var pageUrl = url.format({
protocol: 'file',
slashes: true,
pathname: p
@ -396,10 +383,9 @@ describe('<webview> tag', function() {
});
it('emits when window.location.hash is changed', function(done) {
var p, pageUrl;
p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page-with-hash.html');
var p = path.join(fixtures, 'pages', 'webview-did-navigate-in-page-with-hash.html');
p = p.replace(/\\/g, '/');
pageUrl = url.format({
var pageUrl = url.format({
protocol: 'file',
slashes: true,
pathname: p
@ -425,8 +411,7 @@ describe('<webview> tag', function() {
describe('devtools-opened event', function() {
it('should fire when webview.openDevTools() is called', function(done) {
var listener;
listener = function() {
var listener = function() {
webview.removeEventListener('devtools-opened', listener);
webview.closeDevTools();
done();
@ -442,12 +427,11 @@ describe('<webview> tag', function() {
describe('devtools-closed event', function() {
it('should fire when webview.closeDevTools() is called', function(done) {
var listener, listener2;
listener2 = function() {
var listener2 = function() {
webview.removeEventListener('devtools-closed', listener2);
done();
};
listener = function() {
var listener = function() {
webview.removeEventListener('devtools-opened', listener);
webview.closeDevTools();
};
@ -463,8 +447,7 @@ describe('<webview> tag', function() {
describe('devtools-focused event', function() {
it('should fire when webview.openDevTools() is called', function(done) {
var listener;
listener = function() {
var listener = function() {
webview.removeEventListener('devtools-focused', listener);
webview.closeDevTools();
done();
@ -480,13 +463,12 @@ describe('<webview> tag', function() {
describe('<webview>.reload()', function() {
it('should emit beforeunload handler', function(done) {
var listener, listener2;
listener = function(e) {
var listener = function(e) {
assert.equal(e.channel, 'onbeforeunload');
webview.removeEventListener('ipc-message', listener);
done();
};
listener2 = function() {
var listener2 = function() {
webview.reload();
webview.removeEventListener('did-finish-load', listener2);
};
@ -500,8 +482,7 @@ describe('<webview> tag', function() {
describe('<webview>.clearHistory()', function() {
it('should clear the navigation history', function(done) {
var listener;
listener = function(e) {
var listener = function(e) {
assert.equal(e.channel, 'history');
assert.equal(e.args[0], 2);
assert(webview.canGoBack());
@ -518,14 +499,12 @@ describe('<webview> tag', function() {
});
describe('basic auth', function() {
var auth;
auth = require('basic-auth');
var auth = require('basic-auth');
it('should authenticate with correct credentials', function(done) {
var message, server;
message = 'Authenticated';
server = http.createServer(function(req, res) {
var credentials;
credentials = auth(req);
var message = 'Authenticated';
var server = http.createServer(function(req, res) {
var credentials = auth(req);
if (credentials.name === 'test' && credentials.pass === 'test') {
res.end(message);
} else {
@ -534,8 +513,7 @@ describe('<webview> tag', function() {
server.close();
});
server.listen(0, '127.0.0.1', function() {
var port;
port = server.address().port;
var port = server.address().port;
webview.addEventListener('ipc-message', function(e) {
assert.equal(e.channel, message);
done();
@ -549,11 +527,9 @@ describe('<webview> tag', function() {
describe('dom-ready event', function() {
it('emits when document is loaded', function(done) {
var server;
server = http.createServer(function() {});
var server = http.createServer(function() {});
server.listen(0, '127.0.0.1', function() {
var port;
port = server.address().port;
var port = server.address().port;
webview.addEventListener('dom-ready', function() {
done();
});
@ -575,14 +551,12 @@ describe('<webview> tag', function() {
}
it('should support user gesture', function(done) {
var listener, listener2;
listener = function() {
var listener = function() {
webview.removeEventListener('enter-html-full-screen', listener);
done();
};
listener2 = function() {
var jsScript;
jsScript = 'document.getElementsByTagName("video")[0].webkitRequestFullScreen()';
var listener2 = function() {
var jsScript = 'document.getElementsByTagName("video")[0].webkitRequestFullScreen()';
webview.executeJavaScript(jsScript, true);
webview.removeEventListener('did-finish-load', listener2);
};
@ -634,8 +608,7 @@ describe('<webview> tag', function() {
describe('media-started-playing media-paused events', function() {
it('emits when audio starts and stops playing', function(done) {
var audioPlayed;
audioPlayed = false;
var audioPlayed = false;
webview.addEventListener('media-started-playing', function() {
audioPlayed = true;
});
@ -650,9 +623,8 @@ describe('<webview> tag', function() {
describe('found-in-page event', function() {
it('emits when a request is made', function(done) {
var listener, listener2, requestId;
requestId = null;
listener = function(e) {
var requestId = null;
var listener = function(e) {
assert.equal(e.result.requestId, requestId);
if (e.result.finalUpdate) {
assert.equal(e.result.matches, 3);
@ -660,7 +632,7 @@ describe('<webview> tag', function() {
done();
}
};
listener2 = function() {
var listener2 = function() {
requestId = webview.findInPage("virtual");
};
webview.addEventListener('found-in-page', listener);