Skip full pageload wait on non-jQuery pages in waitForAjaxLoad#926
Open
lbajsarowicz wants to merge 1 commit into
Open
Skip full pageload wait on non-jQuery pages in waitForAjaxLoad#926lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
waitForAjaxLoad() waited on 'window.jQuery.active == 0', but on pages without jQuery the expression is never truthy, so waitForJS() polls until it times out and throws; the catch then sleeps another full pageload_timeout. That is ~2x WAIT_TIMEOUT (60s by default) burned on every call on any non-jQuery page, for no benefit. Treat an absent jQuery as 'no AJAX pending' so the check resolves immediately. Behavior on jQuery pages (all Magento admin pages) is unchanged. Ref magento#925
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MagentoWebDriver::waitForAjaxLoad()waits for jQuery to be idle:On a page that does not load jQuery,
!!window.jQueryis alwaysfalse, so theexpression is never truthy.
waitForJS()therefore polls until it times out andthrows, and the
catchblock then sleeps another fullpageload_timeout:Net effect: roughly 2×
WAIT_TIMEOUT(60s with the default 30s timeout) is burned onevery
waitForAjaxLoad()call on any non-jQuery page — andwaitForPageLoad()callswaitForAjaxLoad()on every navigation. This penalizes storefront/headless flows and anytheme that does not ship jQuery.
Fixed Issues
Part of #925
Fix
Treat an absent jQuery as "no AJAX pending" so the condition resolves immediately instead
of timing out:
window.jQuery.active == 0branch is evaluated exactly as before.full-timeout wait.
The trailing
$this->wait(1)settle buffer is intentionally left in place.Manual testing scenarios
step no longer stalls for ~
2 × WAIT_TIMEOUT.Questions or comments
Isolated one-line change. Follow-ups from #925 (per-step
getLog/getCurrentURLchatter,loading-mask polling, session reuse) will come as separate PRs with timing evidence.
Contribution checklist
develop)