Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
ad8c864c
Commit
ad8c864c
authored
Aug 25, 2020
by
Noel De Martin
Browse files
MDL-69360 behat: Fix js ready checks for non-moodle sites
parent
539edb15
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/behat/behat_base.php
View file @
ad8c864c
...
...
@@ -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.
...
...
@@ -818,19 +822,15 @@ EOF;
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment