From fb3ab9e1f1f32bdbd40c8bce56a3818a0c311cfe Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 19 Jan 2016 10:54:12 -0800 Subject: [PATCH 1/4] Use const and remove extra returns --- spec/api-desktop-capturer-spec.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spec/api-desktop-capturer-spec.js b/spec/api-desktop-capturer-spec.js index 3a03366d4545..13c6f9e2e52a 100644 --- a/spec/api-desktop-capturer-spec.js +++ b/spec/api-desktop-capturer-spec.js @@ -1,17 +1,14 @@ -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(); }); }); }); From c719b252cb154e73673deed3f760883a9f60a7c7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 19 Jan 2016 10:57:18 -0800 Subject: [PATCH 2/4] Add failing spec --- spec/api-desktop-capturer-spec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/api-desktop-capturer-spec.js b/spec/api-desktop-capturer-spec.js index 13c6f9e2e52a..85f3f194b751 100644 --- a/spec/api-desktop-capturer-spec.js +++ b/spec/api-desktop-capturer-spec.js @@ -11,4 +11,17 @@ describe('desktopCapturer', function() { done(); }); }); + + it('does not throw an error when called twice (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); + }) }); From 517dce443b96b8ce2de0c0b8eeef8df835cce84e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 19 Jan 2016 11:02:12 -0800 Subject: [PATCH 3/4] Remove unused errorMessage reference --- atom/browser/lib/desktop-capturer.js | 2 +- spec/api-desktop-capturer-spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/lib/desktop-capturer.js b/atom/browser/lib/desktop-capturer.js index da649df1ce0c..a4154f0c5b1c 100644 --- a/atom/browser/lib/desktop-capturer.js +++ b/atom/browser/lib/desktop-capturer.js @@ -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); diff --git a/spec/api-desktop-capturer-spec.js b/spec/api-desktop-capturer-spec.js index 85f3f194b751..c3ca940e61fe 100644 --- a/spec/api-desktop-capturer-spec.js +++ b/spec/api-desktop-capturer-spec.js @@ -14,7 +14,7 @@ describe('desktopCapturer', function() { it('does not throw an error when called twice (regression)', function(done) { var callCount = 0; - var callback = function(error, sources) { + var callback = function (error, sources) { callCount++; assert.equal(error, null); assert.notEqual(sources.length, 0); From b014eea8d369e5b6998fb1be31a17c3f9f8df14a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 19 Jan 2016 11:05:57 -0800 Subject: [PATCH 4/4] Tweak spec description --- spec/api-desktop-capturer-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api-desktop-capturer-spec.js b/spec/api-desktop-capturer-spec.js index c3ca940e61fe..ead916c7d538 100644 --- a/spec/api-desktop-capturer-spec.js +++ b/spec/api-desktop-capturer-spec.js @@ -12,7 +12,7 @@ describe('desktopCapturer', function() { }); }); - it('does not throw an error when called twice (regression)', function(done) { + it('does not throw an error when called more than once (regression)', function(done) { var callCount = 0; var callback = function (error, sources) { callCount++;