Skip to content

Commit 233a91c

Browse files
committed
Add browser webview click focus regressions
1 parent e259eae commit 233a91c

2 files changed

Lines changed: 96 additions & 2 deletions

File tree

cmuxTests/BrowserConfigTests.swift

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,3 +3273,84 @@ final class BrowserOmnibarFocusPolicyTests: XCTestCase {
32733273
)
32743274
}
32753275
}
3276+
3277+
final class BrowserWebViewClickFocusPolicyTests: XCTestCase {
3278+
func testDismissesOmnibarWhenLocalAddressBarStateIsFocused() {
3279+
let panelId = UUID()
3280+
3281+
XCTAssertTrue(
3282+
browserWebViewClickShouldDismissOmnibar(
3283+
localAddressBarFocused: true,
3284+
focusedAddressBarPanelId: nil,
3285+
pendingAddressBarFocusRequestId: nil,
3286+
panelId: panelId
3287+
)
3288+
)
3289+
}
3290+
3291+
func testDismissesOmnibarWhenAppFocusStateStillPointsAtThisPanel() {
3292+
let panelId = UUID()
3293+
3294+
XCTAssertTrue(
3295+
browserWebViewClickShouldDismissOmnibar(
3296+
localAddressBarFocused: false,
3297+
focusedAddressBarPanelId: panelId,
3298+
pendingAddressBarFocusRequestId: nil,
3299+
panelId: panelId
3300+
)
3301+
)
3302+
}
3303+
3304+
func testDismissesOmnibarWhenAddressBarFocusRequestIsStillPending() {
3305+
let panelId = UUID()
3306+
3307+
XCTAssertTrue(
3308+
browserWebViewClickShouldDismissOmnibar(
3309+
localAddressBarFocused: false,
3310+
focusedAddressBarPanelId: nil,
3311+
pendingAddressBarFocusRequestId: UUID(),
3312+
panelId: panelId
3313+
)
3314+
)
3315+
}
3316+
3317+
func testDoesNotDismissOmnibarForAnotherPanelsFocusedAddressBar() {
3318+
let panelId = UUID()
3319+
3320+
XCTAssertFalse(
3321+
browserWebViewClickShouldDismissOmnibar(
3322+
localAddressBarFocused: false,
3323+
focusedAddressBarPanelId: UUID(),
3324+
pendingAddressBarFocusRequestId: nil,
3325+
panelId: panelId
3326+
)
3327+
)
3328+
}
3329+
3330+
func testPromotesWebViewFocusWhenPanelIsFocused() {
3331+
XCTAssertTrue(
3332+
browserWebViewClickShouldPromoteWebViewFocus(
3333+
isPanelFocused: true,
3334+
shouldDismissOmnibar: false
3335+
)
3336+
)
3337+
}
3338+
3339+
func testPromotesWebViewFocusWhenOmnibarStillOwnsFocus() {
3340+
XCTAssertTrue(
3341+
browserWebViewClickShouldPromoteWebViewFocus(
3342+
isPanelFocused: false,
3343+
shouldDismissOmnibar: true
3344+
)
3345+
)
3346+
}
3347+
3348+
func testDoesNotPromoteWebViewFocusWhenPanelIsNotFocusedAndOmnibarDoesNotOwnFocus() {
3349+
XCTAssertFalse(
3350+
browserWebViewClickShouldPromoteWebViewFocus(
3351+
isPanelFocused: false,
3352+
shouldDismissOmnibar: false
3353+
)
3354+
)
3355+
}
3356+
}

cmuxUITests/BrowserPaneNavigationKeybindUITests.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ final class BrowserPaneNavigationKeybindUITests: XCTestCase {
758758
return
759759
}
760760

761+
guard let browserPanelId = setup["browserPanelId"], !browserPanelId.isEmpty else {
762+
XCTFail("Missing browserPanelId in setup data")
763+
return
764+
}
761765
XCTAssertEqual(setup["webInputFocusSeeded"], "true", "Expected page input harness to be seeded before textarea check")
762766
guard let textareaId = setup["webInputFocusTextareaElementId"], !textareaId.isEmpty else {
763767
XCTFail("Missing webInputFocusTextareaElementId in setup data")
@@ -862,7 +866,9 @@ final class BrowserPaneNavigationKeybindUITests: XCTestCase {
862866
app.typeKey("l", modifierFlags: [.command])
863867
XCTAssertTrue(
864868
waitForDataMatch(timeout: 5.0) { data in
865-
data["webViewFocusedAfterAddressBarFocus"] == "false"
869+
data["webViewFocusedAfterAddressBarFocus"] == "false" &&
870+
data["webViewFocusedAfterAddressBarFocusPanelId"] == browserPanelId &&
871+
data["browserArrowFocusedAddressBarPanelId"] == browserPanelId
866872
},
867873
"Expected Cmd+L to focus omnibar before the textarea click path"
868874
)
@@ -964,6 +970,7 @@ final class BrowserPaneNavigationKeybindUITests: XCTestCase {
964970
XCTAssertTrue(
965971
waitForData(
966972
keys: [
973+
"browserPanelId",
967974
"webInputFocusSeeded",
968975
"webContentEditableSeeded",
969976
"webContentEditableElementId",
@@ -980,6 +987,10 @@ final class BrowserPaneNavigationKeybindUITests: XCTestCase {
980987
return
981988
}
982989

990+
guard let browserPanelId = setup["browserPanelId"], !browserPanelId.isEmpty else {
991+
XCTFail("Missing browserPanelId in setup data")
992+
return
993+
}
983994
XCTAssertEqual(setup["webInputFocusSeeded"], "true", "Expected test page inputs to be seeded before contenteditable regression check")
984995
XCTAssertEqual(setup["webContentEditableSeeded"], "true", "Expected contenteditable fixture to be seeded before contenteditable regression check")
985996
guard let editorId = setup["webContentEditableElementId"], !editorId.isEmpty else {
@@ -1084,7 +1095,9 @@ final class BrowserPaneNavigationKeybindUITests: XCTestCase {
10841095
app.typeKey("l", modifierFlags: [.command])
10851096
XCTAssertTrue(
10861097
waitForDataMatch(timeout: 5.0) { data in
1087-
data["webViewFocusedAfterAddressBarFocus"] == "false"
1098+
data["webViewFocusedAfterAddressBarFocus"] == "false" &&
1099+
data["webViewFocusedAfterAddressBarFocusPanelId"] == browserPanelId &&
1100+
data["browserArrowFocusedAddressBarPanelId"] == browserPanelId
10881101
},
10891102
"Expected Cmd+L to focus omnibar before the contenteditable click path"
10901103
)

0 commit comments

Comments
 (0)