Skip to content

Commit 517972a

Browse files
authored
fix: prevent auto-navigation of web content (#37)
1 parent 52647b5 commit 517972a

2 files changed

Lines changed: 27 additions & 17 deletions

File tree

.github/workflows/test-voiceover.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [macos-14, macos-15, macos-15-intel, macos-26, macos-26-intel]
18+
os: [macos-14, macos-15, macos-26]
1919
browser: [chromium, firefox, webkit]
2020
steps:
2121
- uses: actions/checkout@v6

src/voiceOverTest.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from "@playwright/test";
2-
import { voiceOver, macOSActivate } from "@guidepup/guidepup";
2+
import { voiceOver, macOSActivate, MacOSKeyCodes } from "@guidepup/guidepup";
33
import type { CommandOptions, VoiceOver } from "@guidepup/guidepup";
44
import { applicationNameMap } from "./applicationNameMap";
55

@@ -96,33 +96,36 @@ export const voiceOverTest = test.extend<{
9696
// Ensure application is brought to front and focused.
9797
await macOSActivate(applicationName);
9898

99+
// Cancel auto navigation
100+
await voiceOverPlaywright.perform({ keyCode: MacOSKeyCodes.Control });
101+
99102
// Ensure the document is ready and focused.
100103
await page.bringToFront();
101104
await page.locator("body").waitFor();
102-
await page.locator("body").focus();
103-
await page.locator("body").click();
104-
await page.locator("body").blur();
105-
106-
// Try to navigate into web content.
107-
await voiceOverPlaywright.interact();
108105

109-
// Series of find previous commands to escape accidental interaction
110-
// with sub-content of web content area.
111-
await voiceOverPlaywright.perform(
112-
voiceOverPlaywright.keyboardCommands.findPreviousHeading,
113-
);
114-
await voiceOverPlaywright.perform(
115-
voiceOverPlaywright.keyboardCommands.findPreviousGraphic,
116-
);
106+
// Open the web item rotor defaulting to window spots.
117107
await voiceOverPlaywright.perform(
118-
voiceOverPlaywright.keyboardCommands.findPreviousPlainText,
108+
voiceOverPlaywright.keyboardCommands.openWebItemRotor,
119109
);
120110

111+
// Filter by "content" - currently web content spots for all browsers
112+
// are prefixed by "Content -".
113+
await voiceOverPlaywright.type("content");
114+
115+
// Select the web content window spot.
116+
await voiceOverPlaywright.perform({ keyCode: MacOSKeyCodes.Enter });
117+
118+
// Navigate into web content.
119+
await voiceOverPlaywright.interact();
120+
121121
// Navigate to the beginning of the web content.
122122
await voiceOverPlaywright.perform(
123123
voiceOverPlaywright.keyboardCommands.moveToBeginningOfText,
124124
);
125125

126+
// Cancel auto navigation
127+
await voiceOverPlaywright.perform({ keyCode: MacOSKeyCodes.Control });
128+
126129
if (clearLogs) {
127130
// Clear out logs.
128131
await voiceOverPlaywright.clearItemTextLog();
@@ -132,6 +135,13 @@ export const voiceOverTest = test.extend<{
132135

133136
await voiceOverPlaywright.start(voiceOverStartOptions);
134137
await macOSActivate(applicationName);
138+
139+
// Cancel auto navigation
140+
await voiceOverPlaywright.perform(
141+
{ keyCode: MacOSKeyCodes.Control },
142+
{ capture: false },
143+
);
144+
135145
await use(voiceOverPlaywright);
136146
} finally {
137147
try {

0 commit comments

Comments
 (0)