Closed Bug 1787105 Opened 2 years ago Closed 2 years ago

[CTW] Potential infinite loop in OffsetAtPoint

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: Jamie, Assigned: Jamie)

References

Details

(Whiteboard: [ctw-m3])

Attachments

(1 file)

Real world STR (JAWS + CTW):

  1. Open https://www.mozilla.org/
  2. Press 3 to move to the "Love the Web" heading.
  3. Down arrow several times to move to the email address text box.
    • Expected: This should work without problems.
    • Actual: JAWS moves into the field, switches into forms mode, then Firefox hangs.

Distilled STR (slightly different conditions to the real world one, but causes the same loop):

  1. Open this test case:
    data:text/html,a<div style="width: 5px; height: 5px;"><p></p></div>
  2. Get the top left point for the div.
  3. Call OffsetAtPoint on the div with the point from 2).
    • Expected: Return -1.
    • Actual: Hang.

When a container isn't empty but contains no usable characters, moving backward a character steps past the start point. That means the loop can never reach the end point. Since FindBoundary will intentionally return the end of the document if you try to move past it, we get into an infinite loop. I was worried about this possibility when I reviewed, but I couldn't come up with a way it could happen.

The fix is fairly simple. We protect the loop so it only runs if (point <= endPoint). Again, the test is probably going to be annoying.

This can happen in a container containing no actual characters.
Previously, we would end up in an infinite loop in this case.

Assignee: nobody → jteh
Status: NEW → ASSIGNED
Pushed by jteh@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ad4255fd4560
HyperTextAccessibleBase::OffsetAtPoint: Don't try to move forward if the end point moves before the start point. r=morgan
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: