Skip to content

Commit

Permalink
Merge branch 'MDL-69360-master' of git://github.com/NoelDeMartin/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Sep 3, 2020
2 parents aa3342b + 7440ed4 commit a4d1e0f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/behat/behat_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {

/**
* The JS code to check that the page is ready.
*
* The document must be complete and either M.util.pending_js must be empty, or it must not be defined at all.
*/
const PAGE_READY_JS = '(typeof M !== "undefined" && M.util && M.util.pending_js && !Boolean(M.util.pending_js.length)) && (document.readyState === "complete")';
const PAGE_READY_JS = "document.readyState === 'complete' && " .
"(typeof M !== 'object' || typeof M.util !== 'object' || " .
"typeof M.util.pending_js === 'undefined' || M.util.pending_js.length === 0)";

/**
* Locates url, based on provided path.
Expand Down Expand Up @@ -818,19 +822,15 @@ public static function wait_for_pending_js_in_session(Session $session) {
try {
$jscode = trim(preg_replace('/\s+/', ' ', '
return (function() {
if (typeof M === "undefined") {
if (document.readyState === "complete") {
return "";
} else {
return "incomplete";
}
} else if (' . self::PAGE_READY_JS . ') {
if (document.readyState !== "complete") {
return "incomplete";
}
if (typeof M !== "object" || typeof M.util !== "object" || typeof M.util.pending_js === "undefined") {
return "";
} else if (typeof M.util !== "undefined") {
return M.util.pending_js.join(":");
} else {
return "incomplete"
}
return M.util.pending_js.join(":");
})()'));
$pending = self::evaluate_script_in_session($session, $jscode);
} catch (NoSuchWindow $nsw) {
Expand Down

0 comments on commit a4d1e0f

Please sign in to comment.