Skip to content

Commit 143a558

Browse files
thymikeeclaude
andcommitted
fix(apple-runner): accept the iOS 27 floating-bar back control outside the classic header band (#3333)
On iOS 27.1 the SwiftUI floating toolbar hosts the back control as a _UIButtonBarButton with identifier BackButton at midY 194 in a 678pt window, below the classic header band (maxY 149). topNavigationBackElement matched it by keyword but isTopNavigationControlFrame rejected it, and the leading fallback then tapped empty space. Add isTopNavigationBackCandidateFrame: the classic band still admits any keyword match, and an exact BackButton identifier (UIKit's system back identity, exposed by XCUI) is additionally admitted anywhere in the upper 40% of the window. It is bounded rather than a bypass, so a deep content control is never tapped, and keyword-only matches such as a "back-link" button at the same position stay rejected. Ranking, InAppBackOutcome, the unknown-vs-unavailable split (#2728), and the macOS/tvOS branches are untouched. Verified on iPhone Duo / iOS 27.1: 01-settings.ad passes 7/7 steps in 6/6 runs, and back from General navigates to the root. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 19203c6 commit 143a558

2 files changed

Lines changed: 74 additions & 1 deletion

File tree

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import XCTest
33

44
extension RunnerTests {
55
static let navigationBackKeywords = ["back", "close", "cancel"]
6+
static let systemBackButtonIdentifier = "BackButton"
7+
static let floatingBarBackControlMaxYFraction: CGFloat = 0.4
68
static let navigationFallbackVerificationDelay: TimeInterval = 0.25
79

810
/// What one in-app `back` attempt concluded. `.unverified` carries the typed capture failure the
@@ -88,7 +90,11 @@ extension RunnerTests {
8890
let candidates = app.buttons.matching(Self.navigationBackPredicate()).allElementsBoundByIndex.compactMap {
8991
element -> (XCUIElement, Int)? in
9092
guard element.exists, element.isHittable else { return nil }
91-
guard Self.isTopNavigationControlFrame(element.frame, in: frame) else { return nil }
93+
guard Self.isTopNavigationBackCandidateFrame(
94+
element.frame,
95+
in: frame,
96+
identifier: element.identifier
97+
) else { return nil }
9298
guard let rank = Self.navigationBackControlRank(
9399
label: element.label,
94100
identifier: element.identifier
@@ -132,6 +138,24 @@ extension RunnerTests {
132138
return candidate.midY >= window.minY && candidate.midY <= maxY
133139
}
134140

141+
/// UIKit names the system back control `BackButton`. That identity is the evidence that lets it sit
142+
/// below the classic header band, where the iOS 27 floating toolbar places it (#3333); keyword-only
143+
/// matches stay inside the band so content controls that merely say "back" are not tapped.
144+
static func isTopNavigationBackCandidateFrame(
145+
_ candidate: CGRect,
146+
in window: CGRect,
147+
identifier: String
148+
) -> Bool {
149+
if isTopNavigationControlFrame(candidate, in: window) { return true }
150+
guard identifier == systemBackButtonIdentifier,
151+
SnapshotGeometry.isPositiveFinite(candidate), SnapshotGeometry.isPositiveFinite(window)
152+
else {
153+
return false
154+
}
155+
let maxY = window.minY + window.height * floatingBarBackControlMaxYFraction
156+
return candidate.midY >= window.minY && candidate.midY <= maxY
157+
}
158+
135159
static func topLeadingNavigationFallbackPoint(in frame: CGRect) -> CGPoint? {
136160
guard SnapshotGeometry.isPositiveFinite(frame) else {
137161
return nil

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+NavigationTests.swift‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,55 @@ extension RunnerTests {
5151
XCTAssertFalse(Self.isTopNavigationControlFrame(.infinite, in: window))
5252
}
5353

54+
func testTopNavigationBackCandidateAcceptsIOS27FloatingBarSystemBackButton() {
55+
let window = CGRect(x: 0, y: 0, width: 466, height: 678)
56+
let floatingBarBack = CGRect(x: 399, y: 175, width: 38, height: 38)
57+
58+
XCTAssertFalse(Self.isTopNavigationControlFrame(floatingBarBack, in: window))
59+
XCTAssertTrue(
60+
Self.isTopNavigationBackCandidateFrame(floatingBarBack, in: window, identifier: "BackButton")
61+
)
62+
}
63+
64+
func testTopNavigationBackCandidateRejectsKeywordOnlyMatchBelowHeaderBand() {
65+
let window = CGRect(x: 0, y: 0, width: 466, height: 678)
66+
let floatingBarBack = CGRect(x: 399, y: 175, width: 38, height: 38)
67+
68+
XCTAssertFalse(
69+
Self.isTopNavigationBackCandidateFrame(floatingBarBack, in: window, identifier: "back-link")
70+
)
71+
XCTAssertFalse(
72+
Self.isTopNavigationBackCandidateFrame(floatingBarBack, in: window, identifier: "")
73+
)
74+
}
75+
76+
func testTopNavigationBackCandidateBoundsSystemBackButtonToUpperWindow() {
77+
let window = CGRect(x: 0, y: 0, width: 430, height: 932)
78+
79+
XCTAssertFalse(
80+
Self.isTopNavigationBackCandidateFrame(
81+
CGRect(x: 20, y: 760, width: 72, height: 44),
82+
in: window,
83+
identifier: "BackButton"
84+
)
85+
)
86+
XCTAssertFalse(
87+
Self.isTopNavigationBackCandidateFrame(.infinite, in: window, identifier: "BackButton")
88+
)
89+
}
90+
91+
func testTopNavigationBackCandidateKeepsClassicHeaderBandForKeywordMatches() {
92+
let window = CGRect(x: 0, y: 0, width: 430, height: 932)
93+
94+
XCTAssertTrue(
95+
Self.isTopNavigationBackCandidateFrame(
96+
CGRect(x: 340, y: 84, width: 72, height: 44),
97+
in: window,
98+
identifier: "back-link"
99+
)
100+
)
101+
}
102+
54103
func testNavigationVisualVerificationSeparatesNoChangeFromNoSample() {
55104
XCTAssertEqual(
56105
Self.navigationVisualObservation(before: Data([1, 2, 3]), after: Data([1, 2, 4])),

0 commit comments

Comments
 (0)