diff --git a/lib/behat/behat_base.php b/lib/behat/behat_base.php index d01213b4fec..b39da2c28d2 100644 --- a/lib/behat/behat_base.php +++ b/lib/behat/behat_base.php @@ -727,7 +727,7 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { $pending = ''; try { $jscode = ' - return function() { + return (function() { if (typeof M === "undefined") { if (document.readyState === "complete") { return ""; @@ -741,7 +741,7 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { } else { return "incomplete" } - }();'; + }());'; $pending = $this->getSession()->evaluateScript($jscode); } catch (NoSuchWindow $nsw) { // We catch an exception here, in case we just closed the window we were interacting with.