MDL-66979 behat: Remove manually triggered events

Behat should not trigger Synthetic browser events. It is incorrect to do
so as the UI should be used to trigger events correctly.

The W3C WebDriver specification explicitly states when and where these
events will be triggered from (the browser) and therefore there is no
ambiguity and no need to synthetically trigger them from Behat.
This commit is contained in:
Andrew Nicols 2020-11-12 13:17:29 +08:00
parent bce46258a4
commit afecc583aa
2 changed files with 0 additions and 48 deletions

View File

@ -57,9 +57,6 @@ class behat_form_checkbox extends behat_form_field {
// Check it if it should be checked and it is not.
$this->field->click();
// Trigger the onchange event as triggered when 'checking' the checkbox.
$this->trigger_on_change();
} else if (empty($value) && $this->field->isChecked()) {
if (!$this->running_javascript()) {
@ -69,9 +66,6 @@ class behat_form_checkbox extends behat_form_field {
// Uncheck if it is checked and shouldn't.
$this->field->click();
// Trigger the onchange event as triggered when 'checking' the checkbox.
$this->trigger_on_change();
}
}
@ -103,17 +97,4 @@ class behat_form_checkbox extends behat_form_field {
return false;
}
/**
* Trigger on change event.
*/
protected function trigger_on_change() {
$driver = $this->session->getDriver();
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
$driver->triggerSynScript(
$this->field->getXPath(),
"Syn.trigger('change', {}, {{ELEMENT}})"
);
}
}
}

View File

@ -67,35 +67,6 @@ class behat_form_select extends behat_form_field {
// By default, assume the passed value is a non-multiple option.
$this->field->selectOption(trim($value));
}
// Wait for all the possible AJAX requests that have been
// already triggered by selectOption() to be finished.
if ($this->running_javascript()) {
// Trigger change event and click on first skip link, as some OS/browsers (Phantomjs, Mac-FF),
// don't close select option field and trigger event.
if (!$singleselect) {
$dialoguexpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' moodle-dialogue-focused ')]";
if (!$node = $this->session->getDriver()->find($dialoguexpath)) {
$script = "Syn.trigger('change', {}, {{ELEMENT}})";
try {
$driver = $this->session->getDriver();
if ($driver instanceof \Moodle\BehatExtension\Driver\MoodleSelenium2Driver) {
$driver->triggerSynScript($this->field->getXpath(), $script);
}
$driver->click('//body//div[@class="skiplinks"]');
} catch (\Exception $e) {
return;
}
} else {
try {
$this->session->getDriver()->click($dialoguexpath);
} catch (\Exception $e) {
return;
}
}
}
$this->session->wait(behat_base::get_timeout() * 1000, behat_base::PAGE_READY_JS);
}
}
/**