MDL-41030 Behat: Add support for waiting for javascript
This is so that phantomjs (which runs faster than selenium) can pass the tests.
This commit is contained in:
committed by
David Monllao
parent
5d2b67228c
commit
6e2c417c1f
@@ -1043,14 +1043,18 @@ class page_requirements_manager {
|
||||
public function js_init_code($jscode, $ondomready = false, array $module = null) {
|
||||
$jscode = trim($jscode, " ;\n"). ';';
|
||||
|
||||
$uniqid = html_writer::random_id();
|
||||
$startjs = " M.util.js_pending('" . $uniqid . "');";
|
||||
$endjs = " M.util.js_complete('" . $uniqid . "');";
|
||||
|
||||
if ($module) {
|
||||
$this->js_module($module);
|
||||
$modulename = $module['name'];
|
||||
$jscode = "Y.use('$modulename', function(Y) { $jscode });";
|
||||
$jscode = "$startjs Y.use('$modulename', function(Y) { $jscode $endjs });";
|
||||
}
|
||||
|
||||
if ($ondomready) {
|
||||
$jscode = "Y.on('domready', function() { $jscode });";
|
||||
$jscode = "$startjs Y.on('domready', function() { $jscode $endjs });";
|
||||
}
|
||||
|
||||
$this->jsinitcode[] = $jscode;
|
||||
@@ -1216,7 +1220,7 @@ class page_requirements_manager {
|
||||
$output .= js_writer::function_call($data[0], $data[1], $data[2]);
|
||||
}
|
||||
if (!empty($ondomready)) {
|
||||
$output = " Y.on('domready', function() {\n$output\n });";
|
||||
$output = " Y.on('domready', function() {\n$output\n});";
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
@@ -1463,6 +1467,8 @@ class page_requirements_manager {
|
||||
// Add other requested modules.
|
||||
$output = $this->get_extra_modules_code();
|
||||
|
||||
$this->js_init_code('M.util.js_complete("init");', true);
|
||||
|
||||
// All the other linked scripts - there should be as few as possible.
|
||||
if ($this->jsincludes['footer']) {
|
||||
foreach ($this->jsincludes['footer'] as $url) {
|
||||
|
||||
Reference in New Issue
Block a user