Skip to content

Commit 6f4dffa

Browse files
authored
Fix Chrome system tests (#19121)
### Summary of the issue: A recent update to chrome has introduced a "Ask Google about this page" option in the omnibox (address bar). This option is sometimes spoken, even though it isn't focused, when focusing the address bar. This causes system tests which rely on Chrome to fail, as they are unable to recognise that the address bar has been focused. This breaks some tests in the Chrome, symbols, and image descriptions system test suites. ### Description of user facing changes: None. ### Description of developer facing changes: System tests work again. ### Description of development approach: When setting up a system test that uses Chrome, after sending `alt+d` to focus the address bar, if the speech is not what we expect, try reporting the focused object (`NVDA+tab`) to double-check. This works because "Address and search bar" speech is cancelled by the "Ask Google about this page" speech, so the system tests are unaware where the focus has landed. By explicitly checking the current focus, we work around this issue. ### Testing strategy: Ran the Chrome system test "checkbox labelled by inner element" locally, with and without this patch, to ensure that it was broken on my machine without the patch, and fixed with it. Ran in CI. ### Known issues with pull request: This does not fix the underlying issue, which will still likely inconvenience users. However, as this is stopping us being able to create snapshot, beta, rc or release builds, this fix needed to be prioritised.
1 parent a8f4f80 commit 6f4dffa

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

source/_remoteClient/secureDesktop.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def terminate(self) -> None:
313313
if self._mapFile is not None:
314314
if not closeHandle(self._mapFile):
315315
log.debugWarning(
316-
f"Error closing handle to IPC file mapping. {GetLastError()}: {FormatError()}"
316+
f"Error closing handle to IPC file mapping. {GetLastError()}: {FormatError()}",
317317
)
318318
log.info("Secure desktop cleanup completed")
319319

@@ -384,7 +384,7 @@ def enterSecureDesktop(self) -> None:
384384
log.error(f"Couldn't map view of file. {GetLastError()}: {FormatError()}")
385385
if not closeHandle(mapFile):
386386
log.debugWarning(
387-
f"Error closing handle to IPC file mapping. {GetLastError()}: {FormatError()}"
387+
f"Error closing handle to IPC file mapping. {GetLastError()}: {FormatError()}",
388388
)
389389
return
390390
buffer = (WCHAR * self._IPC_MAXLEN).from_address(bufferAddress)
@@ -410,7 +410,7 @@ def enterSecureDesktop(self) -> None:
410410
log.debugWarning(f"Error unmapping IPC shared memory. {GetLastError()}: {FormatError()}")
411411
if not closeHandle(mapFile):
412412
log.debugWarning(
413-
f"Error closing handle to IPC file mapping. {GetLastError()}: {FormatError()}"
413+
f"Error closing handle to IPC file mapping. {GetLastError()}: {FormatError()}",
414414
)
415415
self.sdServer.close()
416416
self.sdServer = None
@@ -482,7 +482,7 @@ def leaveSecureDesktop(self) -> None:
482482
if self._mapFile is not None:
483483
if not closeHandle(self._mapFile):
484484
log.debugWarning(
485-
"Failed to close handle to memory mapped IPC file. {GetLastError()}: {FormatError()}"
485+
"Failed to close handle to memory mapped IPC file. {GetLastError()}: {FormatError()}",
486486
)
487487
self._mapFile = None
488488

@@ -552,7 +552,7 @@ def initializeSecureDesktop(self) -> Optional[ConnectionInfo]:
552552
log.debugWarning(f"Failed to unmap view of IPC file. {GetLastError()}: {FormatError()}")
553553
if not closeHandle(mapFile):
554554
log.debugWarning(
555-
f"Failed to close handle to IPC file mapping. {GetLastError()}: {FormatError()}"
555+
f"Failed to close handle to IPC file mapping. {GetLastError()}: {FormatError()}",
556556
)
557557

558558
def _onLeaderDisplayChange(self, **kwargs: Any) -> None:

tests/system/libraries/ChromeLib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,14 @@ def _waitForStartMarker(self) -> bool:
185185
"alt+d",
186186
) # focus the address bar, chrome shortcut
187187
if expectedAddressBarSpeech not in moveToAddressBarSpeech:
188-
builtIn.log(
189-
f"Didn't read '{expectedAddressBarSpeech}' after alt+d, instead got: {moveToAddressBarSpeech}",
190-
)
191-
return False
188+
# The "Ask Google about this page" button is sometimes spoken,
189+
# which clobbers the expected output
190+
moveToAddressBarSpeech = _NvdaLib.getSpeechAfterKey("nvda+tab") # report current focus.
191+
if expectedAddressBarSpeech not in moveToAddressBarSpeech:
192+
builtIn.log(
193+
f"Didn't read '{expectedAddressBarSpeech}' after alt+d, instead got: {moveToAddressBarSpeech}",
194+
)
195+
return False
192196

193197
afterControlF6Speech = _NvdaLib.getSpeechAfterKey("control+F6") # focus web content, chrome shortcut.
194198
if ChromeLib._testCaseTitle not in afterControlF6Speech:

0 commit comments

Comments
 (0)