diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSDriverDecorator.php b/core/tests/Drupal/FunctionalJavascriptTests/JSDriverDecorator.php new file mode 100644 index 0000000..4afe616 --- /dev/null +++ b/core/tests/Drupal/FunctionalJavascriptTests/JSDriverDecorator.php @@ -0,0 +1,251 @@ +wait($timeout, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))'); + if (!$result) { + throw new \RuntimeException('Unable to complete AJAX request.'); + } + } + + public function setSession(Session $session) { + return $this->driver->setSession($session); + } + + public function start() { + return $this->driver->start(); + } + + public function isStarted() { + return $this->driver->isStarted(); + } + + public function stop() { + return $this->driver->stop(); + } + + public function reset() { + return $this->driver->reset(); + } + + public function visit($url) { + $result = $this->driver->visit($url); + $this->waitOnAjaxRequest(); + + return $result; + } + + public function getCurrentUrl() { + return $this->driver->getCurrentUrl(); + } + + public function reload() { + return $this->driver->reload(); + } + + public function forward() { + return $this->driver->forward(); + } + + public function back() { + return $this->driver->back(); + } + + public function setBasicAuth($user, $password) { + return $this->driver->setBasicAuth($user, $password); + } + + public function switchToWindow($name = null) { + return $this->driver->switchToWindow($name); + } + + public function switchToIFrame($name = null) { + return $this->driver->switchToIFrame($name); + } + + public function setRequestHeader($name, $value) { + return $this->driver->setRequestHeader($name, $value); + } + + public function getResponseHeaders() { + return $this->driver->getResponseHeaders(); + } + + public function setCookie($name, $value = null) { + return $this->driver->setCookie($name, $value); + } + + public function getCookie($name) { + return $this->driver->getCookie($name); + } + + public function getStatusCode() { + return $this->driver->getStatusCode(); + } + + public function getContent() { + return $this->driver->getContent(); + } + + public function getScreenshot() { + return $this->driver->getScreenshot(); + } + + public function getWindowNames() { + return $this->driver->getWindowName(); + } + + public function getWindowName() { + return $this->driver->getWindowNames(); + } + + public function find($xpath) { + return $this->driver->find($xpath); + } + + public function getTagName($xpath) { + return $this->driver->getTagName($xpath); + } + + public function getText($xpath) { + return $this->driver->getText($xpath); + } + + public function getHtml($xpath) { + return $this->driver->getHtml($xpath); + } + + public function getOuterHtml($xpath) { + return $this->driver->getOuterHtml($xpath); + } + + public function getAttribute($xpath, $name) { + return $this->driver->getAttribute($xpath, $name); + } + + public function getValue($xpath) { + return $this->driver->getValue($xpath); + } + + public function setValue($xpath, $value) { + return $this->driver->setValue($xpath, $value); + } + + public function check($xpath) { + return $this->driver->check($xpath); + } + + public function uncheck($xpath) { + return $this->driver->uncheck($xpath); + } + + public function isChecked($xpath) { + return $this->driver->isChecked($xpath); + } + + public function selectOption($xpath, $value, $multiple = FALSE) { + return $this->driver->selectOption($xpath, $value, $multiple); + } + + public function isSelected($xpath) { + return $this->driver->isSelected($xpath); + } + + public function click($xpath) { + $result = $this->driver->click($xpath); + $this->waitOnAjaxRequest(); + + return $result; + } + + public function doubleClick($xpath) { + return $this->driver->doubleClick($xpath); + } + + public function rightClick($xpath) { + return $this->driver->rightClick($xpath); + } + + public function attachFile($xpath, $path) { + return $this->driver->attachFile($xpath, $path); + } + + public function isVisible($xpath) { + return $this->driver->isVisible($xpath); + } + + public function mouseOver($xpath) { + return $this->driver->mouseOver($xpath); + } + + public function focus($xpath) { + return $this->driver->focus($xpath); + } + + public function blur($xpath) { + return $this->driver->blur($xpath); + } + + public function keyPress($xpath, $char, $modifier = null) { + return $this->driver->keyPress($xpath, $char, $modifier); + } + + public function keyDown($xpath, $char, $modifier = null) { + return $this->driver->keyDown($xpath, $char, $modifier); + } + + public function keyUp($xpath, $char, $modifier = null) { + return $this->driver->keyUp($xpath, $char, $modifier); + } + + public function dragTo($sourceXpath, $destinationXpath) { + return $this->driver->dragTo($sourceXpath, $destinationXpath); + } + + public function executeScript($script) { + return $this->driver->executeScript($script); + } + + public function evaluateScript($script) { + return $this->driver->evaluateScript($script); + } + + public function wait($timeout, $condition) { + return $this->driver->wait($timeout, $condition); + } + + public function resizeWindow($width, $height, $name = null) { + return $this->driver->resizeWindow($width, $height, $name); + } + + public function maximizeWindow($name = null) { + return $this->driver->maximizeWindow($name); + } + + public function submitForm($xpath) { + $result = $this->submitForm($xpath); + $this->waitOnAjaxRequest(); + + return $result; + } + + /** + * {@inheritdoc} + */ + public function __call($name, $arguments) { + return call_user_func_array([$this, $name], $arguments); + } + +} diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index d5156ee..15b4ee0 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -46,6 +46,13 @@ protected function initMink() { /** * {@inheritdoc} */ + protected function getDefaultDriverInstance() { + return new JSDriverDecorator(parent::getDefaultDriverInstance()); + } + + /** + * {@inheritdoc} + */ protected function tearDown() { if ($this->mink) { // Wait for all requests to finish. It is possible that an AJAX request is