Merge pull request #4158 from atom/desktop-capturer-error-message
Fix error calling desktopCapturer.getSources twice
This commit is contained in:
commit
54b5369215
2 changed files with 19 additions and 9 deletions
|
@ -59,7 +59,7 @@ desktopCapturer.emit = function(event, name, sources) {
|
||||||
request = requestsQueue[i];
|
request = requestsQueue[i];
|
||||||
if (deepEqual(handledRequest.options, request.options)) {
|
if (deepEqual(handledRequest.options, request.options)) {
|
||||||
if ((ref1 = request.webContents) != null) {
|
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 {
|
} else {
|
||||||
unhandledRequestsQueue.push(request);
|
unhandledRequestsQueue.push(request);
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
var assert, desktopCapturer;
|
const assert = require('assert');
|
||||||
|
const desktopCapturer = require('electron').desktopCapturer;
|
||||||
assert = require('assert');
|
|
||||||
|
|
||||||
desktopCapturer = require('electron').desktopCapturer;
|
|
||||||
|
|
||||||
describe('desktopCapturer', function() {
|
describe('desktopCapturer', function() {
|
||||||
return it('should return a non-empty array of sources', function(done) {
|
it('should return a non-empty array of sources', function(done) {
|
||||||
return desktopCapturer.getSources({
|
desktopCapturer.getSources({
|
||||||
types: ['window', 'screen']
|
types: ['window', 'screen']
|
||||||
}, function(error, sources) {
|
}, function(error, sources) {
|
||||||
assert.equal(error, null);
|
assert.equal(error, null);
|
||||||
assert.notEqual(sources.length, 0);
|
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);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue