Merge pull request #4158 from atom/desktop-capturer-error-message

Fix error calling desktopCapturer.getSources twice
This commit is contained in:
Cheng Zhao 2016-01-20 09:42:51 -07:00
commit 54b5369215
2 changed files with 19 additions and 9 deletions

View file

@ -59,7 +59,7 @@ desktopCapturer.emit = function(event, name, sources) {
request = requestsQueue[i];
if (deepEqual(handledRequest.options, request.options)) {
if ((ref1 = request.webContents) != null) {
ref1.send("ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_" + request.id, errorMessage, result);
ref1.send("ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_" + request.id, result);
}
} else {
unhandledRequestsQueue.push(request);

View file

@ -1,17 +1,27 @@
var assert, desktopCapturer;
assert = require('assert');
desktopCapturer = require('electron').desktopCapturer;
const assert = require('assert');
const desktopCapturer = require('electron').desktopCapturer;
describe('desktopCapturer', function() {
return it('should return a non-empty array of sources', function(done) {
return desktopCapturer.getSources({
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);
return done();
done();
});
});
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();
}
desktopCapturer.getSources({types: ['window', 'screen']}, callback);
desktopCapturer.getSources({types: ['window', 'screen']}, callback);
})
});