Repository navigation
[Fix] Card probe crashed on pages with an active sort tab - #8
Closed
sirotaoleg wants to merge 1 commit into
Closed
sirotaoleg wants to merge 1 commit into
sirotaoleg wants to merge 1 commit into
Conversation
browser_probe_cards failed with
Error: page.evaluate: ReferenceError: visible is not defined
at extractSortState (eval at evaluate ...)
extractSortState() in the card-probe script calls visible(), a helper
that only exists in build_browser_state_metadata_js(), a different
script. extractSortState() runs for every card, so on any page with an
element matching its sort selectors (an active [role="tab"], a
*sort*active* control: Google Flights "Best/Cheapest", marketplace sort
bars, Booking tabs) the first card throws and the whole probe returns
nothing. Introduced by 05db325 (mirror of upstream
openJiuwen-ai#1147).
Define isRenderedElement() next to the other card-probe visibility
helpers, with the body of the metadata script's visible(): connected,
at least 1x1 px, not display:none / visibility:hidden / opacity:0, and
not clipped to the viewport. The sort control is page-level and is
often scrolled out of view while cards are read, so the existing
isVisible() / isElementVisible() (both viewport-clipped, isVisible
also needs 20 px) would silently drop it.
Add test_browser_probe_cards_exec.py, which runs the generated probe
under Node against a small DOM double with three result cards and an
active sort tab: the probe returns the cards with sort_state, ignores a
display:none tab, and keeps a tab scrolled above the viewport. Skips
only when node is not installed.
Author
|
Superseded by #12 |
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.
Problem.
browser_probe_cardsfailed withReferenceError: visible is not defined (at extractSortState).extractSortState()calls a helper,visible(), that exists only in a different generated script (the page-state metadata script).Fix. Define
isRenderedElement()next to the other card-probe helpers, with the same semantics as the metadata script'svisible(): rendered and non-zero size, but not clipped to the viewport. The sort control is page-level and is often scrolled out of view while the cards are read.Result. 0 failures in 89
browser_probe_cardscalls after the fix (before: every call on such pages failed).Tests. A new
test_browser_probe_cards_exec.pyactually executes the generated probe under Node, against a small DOM double. It checks that:sort_stateare returned;display:nonetab is ignored;Note: the same line exists in the refactor branch (
browser_move/runtime/probe_js.py) and in upstream openJiuwen.