Merge branch 'MDL-67728-master' of git://github.com/crazyserver/moodle

main
Eloy Lafuente (stronk7) 2020-03-03 19:50:08 +01:00
commit 57eed3003f
2 changed files with 17 additions and 15 deletions

View File

@ -72,7 +72,7 @@
if (window.M.util.pending_js.length === 1) { if (window.M.util.pending_js.length === 1) {
runAfterEverything(function() { runAfterEverything(function() {
// Check there isn't a spinner... // Check there isn't a spinner...
updateSpinner(); checkUIBlocked();
// Only remove it if the pending array is STILL empty after all that. // Only remove it if the pending array is STILL empty after all that.
if (window.M.util.pending_js.length === 1) { if (window.M.util.pending_js.length === 1) {
@ -109,23 +109,23 @@
return realOpen.apply(this, arguments); return realOpen.apply(this, arguments);
}; };
var waitingSpinner = false; var waitingBlocked = false;
/** /**
* Checks if a loading spinner is present and visible; if so, adds it to the pending array * Checks if a loading spinner is present and visible; if so, adds it to the pending array
* (and if not, removes it). * (and if not, removes it).
*/ */
var updateSpinner = function() { var checkUIBlocked = function() {
var spinner = document.querySelector('span.core-loading-spinner'); var blocked = document.querySelector('span.core-loading-spinner, ion-loading, .click-block-active');
if (spinner && spinner.offsetParent) { if (blocked && blocked.offsetParent) {
if (!waitingSpinner) { if (!waitingBlocked) {
addPending('spinner'); addPending('blocked');
waitingSpinner = true; waitingBlocked = true;
} }
} else { } else {
if (waitingSpinner) { if (waitingBlocked) {
removePending('spinner'); removePending('blocked');
waitingSpinner = false; waitingBlocked = false;
} }
} }
}; };
@ -167,7 +167,7 @@
setTimeout(pollRecentMutation, 500); setTimeout(pollRecentMutation, 500);
} }
// Also update the spinner presence if needed. // Also update the spinner presence if needed.
updateSpinner(); checkUIBlocked();
}; };
// Set listener using the mutation callback. // Set listener using the mutation callback.
@ -182,7 +182,9 @@
* @param {function} process Callback function that handles each matched node * @param {function} process Callback function that handles each matched node
*/ */
var findPossibleMatches = function(xpath, process) { var findPossibleMatches = function(xpath, process) {
var matches = document.evaluate(xpath, document); var select = 'ion-alert, ion-popover, ion-action-sheet, core-ion-tab.show-tab ion-page.show-page, ion-page.show-page, html';
var parent = document.querySelector(select);
var matches = document.evaluate(xpath, parent || document);
while (true) { while (true) {
var match = matches.iterateNext(); var match = matches.iterateNext();
if (!match) { if (!match) {

View File

@ -294,7 +294,7 @@ class behat_app extends behat_base {
} }
} }
throw new DriverException('Moodle app not found in browser'); throw new DriverException('Moodle app not found in browser');
}, false, 30); }, false, 60);
// Run the scripts to install Moodle 'pending' checks. // Run the scripts to install Moodle 'pending' checks.
$this->getSession()->executeScript( $this->getSession()->executeScript(
@ -312,7 +312,7 @@ class behat_app extends behat_base {
return 'mainpage'; return 'mainpage';
} }
throw new DriverException('Moodle app login URL prompt not found'); throw new DriverException('Moodle app login URL prompt not found');
}, behat_base::get_extended_timeout(), 30); }, behat_base::get_extended_timeout(), 60);
// If it's the login page, we automatically fill in the URL and leave it on the user/pass // If it's the login page, we automatically fill in the URL and leave it on the user/pass
// page. If it's the main page, we just leave it there. // page. If it's the main page, we just leave it there.