Closed Bug 1681402 Opened 3 years ago Closed 3 years ago

Improve stability and error handling for _selection_location_helper()

Categories

(Core :: Layout, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

By searching test_accessiblecaret_ on bugzilla, we have a lot of intermittent bugs of KeyError: '0' or KeyError: '-1' for various testcase on AccessibleCaret. Most of them are on macOS.

One of the failure log looks like

Marionette	DEBUG	21 -> [0,25,"WebDriver:ExecuteScript",{"script":"var sel = arguments[0].editor.selection;return sel.rangeCount;","newSandbox":true, ... 6-4254-9346-b55e-6588df576563"}],"filename":"tests/layout/base/tests/marionette/selection.py","sandbox":"system","line":178}]
Marionette	DEBUG	21 <- [1,25,null,{"value":1}]
Marionette	DEBUG	21 -> [0,26,"WebDriver:GetElementTagName",{"id":"e49c6566-4254-9346-b55e-6588df576563"}]
Marionette	DEBUG	21 <- [1,26,null,{"value":"input"}]
Marionette	DEBUG	21 -> [0,27,"WebDriver:ExecuteScript",{"script":"var sel = arguments[0].editor.selection;return sel.getRangeAt(0).getClientRects(); ... 6-4254-9346-b55e-6588df576563"}],"filename":"tests/layout/base/tests/marionette/selection.py","sandbox":"system","line":171}]
Marionette	DEBUG	21 <- [1,27,null,{"value":{"item":{},"length":0}}]
Marionette	DEBUG	21 -> [0,28,"WebDriver:GetElementTagName",{"id":"e49c6566-4254-9346-b55e-6588df576563"}]
Marionette	DEBUG	21 <- [1,28,null,{"value":"input"}]
Marionette	DEBUG	21 -> [0,29,"WebDriver:ExecuteScript",{"script":"var sel = arguments[0].editor.selection;return sel.getRangeAt(0).getClientRects(); ... 6-4254-9346-b55e-6588df576563"}],"filename":"tests/layout/base/tests/marionette/selection.py","sandbox":"system","line":171}]
Marionette	DEBUG	21 <- [1,29,null,{"value":{"0":{"x":12,"y":22,"width":0,"height":14,"top":22,"right":12,"bottom":36,"left":12},"item":{},"length":1}}]

https://treeherder.mozilla.org/logviewer?job_id=323204001&repo=autoland&lineNumber=53626-53635

This should be the log of executing

        range_count = self.range_count()
        first_rect_list = self.selection_rect_list(0)
        last_rect_list = self.selection_rect_list(range_count - 1)

https://searchfox.org/mozilla-central/rev/71621bfa47a371f2b1ccfd33c704913124afb933/layout/base/tests/marionette/selection.py#190-192

The first getClientRects() (via self.selection_rect_list()) doesn't returns a rect, but the second one does. Some of the intermittent logs show the opposite.

Summary: Flush layout in → Improve stability and error handling for _selection_location_helper()
See Also: → 1667910

This patch doesn't change the behavior, but should improve the stability
and error handling of _selection_location_helper().

Throw exceptions if we don't see any range in Selection or we cannot get
any rects out of the first range, making the error message clearer.

Blocks: 1682382
Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/63d099513042
Improve stability and error handling for _selection_location_helper(). r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: