From 23bead9a30d4b6059055f93deb0c4440a02392a6 Mon Sep 17 00:00:00 2001 From: vladikoff Date: Wed, 21 May 2014 04:05:09 -0400 Subject: [PATCH] fix(test): Force focus in Mocha tests. --- app/tests/lib/helpers.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/tests/lib/helpers.js b/app/tests/lib/helpers.js index 1aa948850..704c252da 100644 --- a/app/tests/lib/helpers.js +++ b/app/tests/lib/helpers.js @@ -8,6 +8,14 @@ define([ 'sinon' ], function (sinon) { function requiresFocus(callback, done) { + // Give the document focus + window.focus(); + + // Remove focus from any focused element + if (document.activeElement) { + document.activeElement.blur(); + } + if (document.hasFocus && document.hasFocus()) { callback(); } else {