Skip to content

Commit 1234590

Browse files
authored
fix(ios-runner): reject CGRect.infinite in navigation frame guards (#1816)
topLeadingNavigationFallbackPoint and isTopNavigationControlFrame only validated width/height, never the origin. CGRect.infinite has a finite (if absurd, ~-9e307) origin, so it slipped past the isFinite/>0 guard: the fallback point collapsed to roughly (-9e307, -9e307), and an unresolved element frame was classified as sitting in the nav header band. Extract isUsableNavigationFrame(_:), which adds the isInfinite check TapPointPolicy.isAllowed already uses for the same rect, and share it between both helpers. Fixes #1812
1 parent 142d156 commit 1234590

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,16 @@ extension RunnerTests {
8181
return navigationBackKeywords.firstIndex { text.contains($0) }
8282
}
8383

84+
// isFinite/>0 alone don't reject CGRect.infinite — its origin (~-9e307) is finite.
85+
static func isUsableNavigationFrame(_ frame: CGRect) -> Bool {
86+
guard frame.width.isFinite, frame.height.isFinite, frame.width > 0, frame.height > 0 else {
87+
return false
88+
}
89+
return !frame.isInfinite
90+
}
91+
8492
static func isTopNavigationControlFrame(_ candidate: CGRect, in window: CGRect) -> Bool {
85-
guard
86-
candidate.width.isFinite,
87-
candidate.height.isFinite,
88-
window.width.isFinite,
89-
window.height.isFinite,
90-
candidate.width > 0,
91-
candidate.height > 0,
92-
window.width > 0,
93-
window.height > 0
94-
else {
93+
guard isUsableNavigationFrame(candidate), isUsableNavigationFrame(window) else {
9594
return false
9695
}
9796
// Accept the compact navigation/search header band without matching deep content controls.
@@ -100,7 +99,7 @@ extension RunnerTests {
10099
}
101100

102101
static func topLeadingNavigationFallbackPoint(in frame: CGRect) -> CGPoint? {
103-
guard frame.width.isFinite, frame.height.isFinite, frame.width > 0, frame.height > 0 else {
102+
guard isUsableNavigationFrame(frame) else {
104103
return nil
105104
}
106105
// Aim at the standard leading navigation slot, bounded for compact and tablet widths.

0 commit comments

Comments
 (0)