Search "Highlight All" does not highlight text added after it was pressed
Categories
(Toolkit :: Find Toolbar, defect, P5)
Tracking
()
People
(Reporter: jichr86, Assigned: r.majdodin, NeedInfo)
Details
Attachments
(1 file, 3 external files)
|
4.23 KB,
text/html
|
Details |
Updated•11 years ago
|
Comment 1•11 years ago
|
||
Comment 2•11 years ago
|
||
Updated•10 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 3•3 months ago
|
||
When "Highlight All" is on and the page changes afterwards, the
highlights and the match count keep describing the page as it was
when the search ran: matches added later are not highlighted, and
highlights on removed content linger in the count until the next
search.
While Highlight All is active with the regular selection highlight,
watch the top document with a MutationObserver (childList,
characterData, subtree) and restart the find iterator, which
repopulates the find selection. Rescans are coalesced to
findbar.iteratorTimeout, the same pause the iterator takes between
chunks, and deferred while the iterator is running, so a page that
mutates continuously cannot starve it. The match count is accumulated
across frames in the parent, so a new Findbar:ContentChanged message
asks the findbar to recount; that count joins the iteration the
rescan just started. Modal highlighting already restarts the iterator
from its repaint scheduler and is unchanged. The observer only arms
when the new findbar.liveHighlight pref is set, default on.
The rescan is skipped on pages the highlighter already considers too
big (_isPageTooBig, kPageIsTooBigPx), the same cutoff it already uses
to degrade drawing-intensive work gracefully.
The FindBar actor is only registered for the browsers and test
message manager groups; in a browser outside those groups the rescan
still refreshes the highlight and the count notification is swallowed
— there is no findbar to update.
about:preferences runs its own find-in-page through the same
SELECTION_FIND selection as the in-process Finder. Today the first
findbar search already replaces the pane's highlights; with the
observer armed, any pane DOM change while Highlight All is on does so
too. The conflict is pre-existing (one selection, two writers) — this
widens its trigger, and no test covers the interaction.
The new test appends matches after the search and asserts they get
highlighted and counted, removes a match and asserts it drops out of
both, and asserts that with findbar.liveHighlight off the highlights
stay as they were.
Updated•3 months ago
|
| Assignee | ||
Comment 4•3 months ago
|
||
The rescan added in the previous patch repopulates the find selection
but nothing recomputes the scrollbar marks afterwards. A mutation
that changes the page height does trigger the existing
MozScrolledAreaChanged listener, but that fires before the coalesced
rescan has run, so it redraws the marks from the old selection; an
in-place change triggers nothing, and the marks stay stale until the
next search.
FinderIterator.restart() now returns the promise of its range
collection (undefined when there are no parameters to restart with),
and the rescan scheduler chains updateScrollMarks() on it. The write
is skipped if the iterator is running again at that point: the
restart has been superseded, and the newer operation updates the
marks on its own path.
The new test task spreads the matches out so each gets its own mark,
swaps the text of one match in place — the paragraph keeps its size,
so the page height cannot change — and waits for
find-scrollmarks-changed; without the fix the wait times out, and a
stale write would carry three marks instead of the asserted two.
| Assignee | ||
Comment 5•3 months ago
|
||
This work was done with AI assistance; I have reviewed and can explain every line.
| Assignee | ||
Comment 6•2 months ago
|
||
Try for the stack, three pushes on one base (f9a73919fe03, main of 2026-09-22): browser-chrome on toolkit/modules/tests/browser and toolkit/content/tests/browser, Linux, Windows 64/32 and macOS, opt/debug, 3 runs each.
- The stack, D317719 and D317720, with test-verify: https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=95966
- Main alone, same selection: https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=95470
- Main plus the new test alone, without the stack: https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=95973
What fails, and why:
- On the stack push the only failure is browser_starting_autoscroll_in_about_content.js leaking a window at shutdown on macOS debug, in 2 of 3 runs. It fails the same way on the main-alone push, in 1 of 3 runs, and is bug 2062699; the stack does not touch that test or anything it uses.
- The new test browser_FinderHighlighter_liveUpdate.js:
- Passes in every job of the stack push. Test-verify runs it 30 times per job, 10 in one browser, 5 in fresh browsers and both again in chaos mode, on every platform, with no failure.
- Fails in every job of the main-plus-test push at "testMatchesAddedAfterSearch - Test timed out". That is the expected result without the stack: the test is red without it and green with it.
| Assignee | ||
Comment 7•2 months ago
|
||
D317719 and D317720 were rebased onto current main and updated today. The only change besides the rebase is in the test's setup, which now waits for the highlight of the whole word before counting the ranges; the first try push had shown the earlier wait resolving on the first typed prefix. The try results are in comment 6.
The stack has been in review since 2026-08-11, and the last reviewer activity on it was mossop's inline on 2026-08-19 about a lint, answered on 08-21. :NeilDeakin, :mstriemer: you are the blocking reviewers on D317719, and I would appreciate your reviews. If you would rather change the reviewers, please do.
| Assignee | ||
Comment 8•2 months ago
|
||
The find bar sends case sensitivity, entire word and diacritic matching
to the frames through their own messages, to the browsing contexts that
exist at that moment. A frame created later starts with all three off
and keeps them off until an option changes, so Highlight All and the
match count treat it with the wrong options.
Send the three values with Finder:Highlight, Finder:MatchesCount and
Finder:UpdateHighlightAndMatchCount, as bug 1606392 did with the find
message, and let Finder apply them before handling the message. The setters return when the value is unchanged,
so a frame that already has the options sees no iterator reset.
This work was done with AI assistance; I have reviewed and can explain
every line.
| Assignee | ||
Comment 9•2 months ago
|
||
Try for the updated stack, D317719 and D317720 with the new D329720 in front of them. All four pushes sit on the same base, ee1823453a2c, the state of main on 2026-09-27. The selection is the one of comment 6, 3 runs each.
- The stack, with test-verify: https://treeherder.mozilla.org/jobs?repo=try&revision=dfa6f9307024723429660fd5bb737abf4dcc6a08
- The base with the new tests, without the stack, Linux: https://treeherder.mozilla.org/jobs?repo=try&revision=3b0ea2a35f844e1075cfe5b3e97ab03d1425cf4b
- The base without the stack, test-verify of browser_findbar.js on macOS; the file is touched only so that test-verify runs it: https://treeherder.mozilla.org/jobs?repo=try&revision=36ef100e8c641d04e176d5b9c4c7033b9d7229a4
- The stack again, with new tests for frames added to browser_FinderHighlighter_liveUpdate.js, with test-verify: https://treeherder.mozilla.org/jobs?repo=try&revision=84896b4acc1c0c352df1c361cb311e90fa543d59
Push 4 is green in every job. On push 1 Linux and Windows are green in every job. Its failures, all on macOS, and why the stack does not cause them:
- Test-verify, 6 of 6 jobs: browser_findbar.js fails at "test_preservestate_on_reload - Correct match position entire-word - Got +0, expected 1". The task belongs to the base, not to the stack, and it fails with the same line in 6 of 6 jobs of push 3, the base without the stack.
- Debug browser-chrome, 2 of 3 jobs: browser_starting_autoscroll_in_about_content.js leaks a window at shutdown. No push of this round ran this job on the base. The failure is the known intermittent of bug 2062699: Treeherder records 509 occurrences of it between 2026-08-30 and 2026-09-29, 508 of them on macOS debug, most on autoland. In comment 6 it also occurred on the push without the stack. The stack does not touch that test or anything it uses.
The new tests:
- None of them fails in any job of the pushes 1 and 4, test-verify included.
- Push 2 fails in both of its browser-chrome jobs, as is the expected result without the stack.
| Assignee | ||
Comment 10•1 month ago
•
|
||
:mstriemer, :enndeakin, I updated the revisions 14 days ago to address your comments. If everything is clear now, could you accept them please?
Comment 11•6 days ago
|
||
This issue is still noticeable in everyday use, particularly on modern websites that use virtual scrolling, such as Outlook on the web.
When scrolling through an email list with "Highlight All" enabled, previously highlighted matches lose their highlighting when the corresponding DOM elements are removed and recreated.
As long as "Highlight All" remains enabled, newly inserted or modified content should automatically be searched and matching text highlighted, without requiring any additional user interaction.
It is good to see that this long-standing issue is finally being worked on.
Attached is a self-contained HTML/JavaScript test case demonstrating the issue with Firefox's "Highlight All" feature when DOM elements are dynamically removed and reinserted during scrolling. No external dependencies are required.
| Assignee | ||
Comment 12•5 days ago
|
||
(In reply to NotCompatible from comment #11)
Thanks for the test case. The patches on this bug fix it: with D329720, D317719 and D317720 applied, every ORCHIDTEST is highlighted on the way down to Section 3, where the text did not exist when the search was made, and again on the way back to Section 1, after the page has removed and rebuilt the sections.
The patches are still in review. Until they land, Nightly users can use them through an add-on that applies the same patches to Firefox Nightly: https://github.com/Majdoddin/highlight-all-firefox. It is unsigned and replaces part of Firefox's find code, so it runs only in Nightly, after two about:config prefs are changed; its README lists them.
Description
•