From 80ac8522cce0cc3b4bae3df5b0a6f7e80eaf055e Mon Sep 17 00:00:00 2001 From: Tony Levi Date: Wed, 21 Jan 2015 21:24:26 +1030 Subject: [PATCH 1/2] MDL-48926 behat: Do not poll within spin for non-javascript mode --- lib/behat/behat_base.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/behat/behat_base.php b/lib/behat/behat_base.php index 8c60cecd4fe..c2dac9a9e72 100644 --- a/lib/behat/behat_base.php +++ b/lib/behat/behat_base.php @@ -302,6 +302,11 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { $loops = $timeout; } + // DOM will never change on non-javascript case; do not wait or try again. + if (!$this->running_javascript()) { + $loops = 1; + } + for ($i = 0; $i < $loops; $i++) { // We catch the exception thrown by the step definition to execute it again. try { @@ -320,10 +325,12 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { continue; } - if ($microsleep) { - usleep(100000); - } else { - sleep(1); + if ($this->running_javascript()) { + if ($microsleep) { + usleep(100000); + } else { + sleep(1); + } } } From 20153f6308fd19e3bad1e2bc3bace0152b8832a0 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Thu, 22 Jan 2015 11:58:06 +0800 Subject: [PATCH 2/2] MDL-48926 behat: No expand form required in non-js mode --- lib/tests/behat/behat_forms.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index abdc35e253b..1a820991b9e 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -98,6 +98,10 @@ class behat_forms extends behat_base { * @return void */ protected function expand_all_fields() { + // Expand only if JS mode, else not needed. + if (!$this->running_javascript()) { + return; + } // We already know that we waited for the DOM and the JS to be loaded, even the editor // so, we will use the reduced timeout as it is a common task and we should save time.