Loading core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php +1 −13 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ use PHPUnit\Framework\Constraint\IsNull; use PHPUnit\Framework\Constraint\LogicalNot; use WebDriver\Exception; use WebDriver\Exception\CurlExec; // cspell:ignore interactable Loading Loading @@ -156,18 +155,7 @@ public function waitForText($text, $timeout = 10000) { * The result of $callback. */ private function waitForHelper(int $timeout, callable $callback) { WebDriverCurlService::disableRetry(); $wrapper = function (Element $element) use ($callback) { try { return call_user_func($callback, $element); } catch (CurlExec $e) { return NULL; } }; $result = $this->session->getPage()->waitFor($timeout / 1000, $wrapper); WebDriverCurlService::enableRetry(); return $result; return $this->session->getPage()->waitFor($timeout / 1000, $callback); } /** Loading core/tests/Drupal/Tests/DocumentElement.php +30 −0 Original line number Diff line number Diff line Loading @@ -7,7 +7,10 @@ namespace Drupal\Tests; use Behat\Mink\Driver\BrowserKitDriver; use Behat\Mink\Element\Element; use Behat\Mink\Element\TraversableElement; use Drupal\FunctionalJavascriptTests\WebDriverCurlService; use WebDriver\Exception\CurlExec; /** * Document element. Loading Loading @@ -85,4 +88,31 @@ public function getText() { return parent::getText(); } /** * {@inheritdoc} */ public function waitFor($timeout, $callback) { // Wraps waits in a function to catch curl exceptions to continue waiting. WebDriverCurlService::disableRetry(); $count = 0; $wrapper = function (Element $element) use ($callback, &$count) { $count++; try { return call_user_func($callback, $element); } catch (CurlExec $e) { return NULL; } }; $result = parent::waitFor($timeout, $wrapper); if (!$result && $count < 2) { // If the callback or the system is really slow, then it might have only // fired once. In this case it is better to trigger it once more as the // page state has probably changed while the callback is running. return call_user_func($callback, $this); } WebDriverCurlService::enableRetry(); return $result; } } Loading
core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php +1 −13 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ use PHPUnit\Framework\Constraint\IsNull; use PHPUnit\Framework\Constraint\LogicalNot; use WebDriver\Exception; use WebDriver\Exception\CurlExec; // cspell:ignore interactable Loading Loading @@ -156,18 +155,7 @@ public function waitForText($text, $timeout = 10000) { * The result of $callback. */ private function waitForHelper(int $timeout, callable $callback) { WebDriverCurlService::disableRetry(); $wrapper = function (Element $element) use ($callback) { try { return call_user_func($callback, $element); } catch (CurlExec $e) { return NULL; } }; $result = $this->session->getPage()->waitFor($timeout / 1000, $wrapper); WebDriverCurlService::enableRetry(); return $result; return $this->session->getPage()->waitFor($timeout / 1000, $callback); } /** Loading
core/tests/Drupal/Tests/DocumentElement.php +30 −0 Original line number Diff line number Diff line Loading @@ -7,7 +7,10 @@ namespace Drupal\Tests; use Behat\Mink\Driver\BrowserKitDriver; use Behat\Mink\Element\Element; use Behat\Mink\Element\TraversableElement; use Drupal\FunctionalJavascriptTests\WebDriverCurlService; use WebDriver\Exception\CurlExec; /** * Document element. Loading Loading @@ -85,4 +88,31 @@ public function getText() { return parent::getText(); } /** * {@inheritdoc} */ public function waitFor($timeout, $callback) { // Wraps waits in a function to catch curl exceptions to continue waiting. WebDriverCurlService::disableRetry(); $count = 0; $wrapper = function (Element $element) use ($callback, &$count) { $count++; try { return call_user_func($callback, $element); } catch (CurlExec $e) { return NULL; } }; $result = parent::waitFor($timeout, $wrapper); if (!$result && $count < 2) { // If the callback or the system is really slow, then it might have only // fired once. In this case it is better to trigger it once more as the // page state has probably changed while the callback is running. return call_user_func($callback, $this); } WebDriverCurlService::enableRetry(); return $result; } }