diff --git a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php index ecbe96237742fdf437de4df14b78721d85b1a5c6..b89b5a4b92cc6f2d078e475fb51f2038d9f50ce0 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php @@ -168,6 +168,24 @@ public function setValue($xpath, $value) { $not_clickable_exception = NULL; $result = $this->waitFor(10, function () use (&$not_clickable_exception, $xpath, $value) { try { + // \Behat\Mink\Driver\Selenium2Driver::setValue() will call .blur() on + // the element, modify that to trigger the "input" and "change" events + // instead. They indicate the value has changed, rather than implying + // user focus changes. + $this->executeJsOnXpath($xpath, <<<JS +var node = {{ELEMENT}}; +var original = node.blur; +node.blur = function() { + node.dispatchEvent(new Event("input", {bubbles:true})); + node.dispatchEvent(new Event("change", {bubbles:true})); + // Do not wait for the debounce, which only triggers the 'formUpdated` event + // up to once every 0.3 seconds. In tests, no humans are typing, hence there + // is no need to debounce. + // @see Drupal.behaviors.formUpdated + node.dispatchEvent(new Event("formUpdated", {bubbles:true})); + node.blur = original; +}; +JS); parent::setValue($xpath, $value); return TRUE; }