Repository: nvaccess/nvda

Issue:
Attribute error breaks automatic say all in Mozilla apps
### Steps to reproduce:
1. Load a page in Firefox or open a message in Thunderbird.
### Actual behavior:
An error is displayed that can break say all on page load.
ERROR - queueHandler.flushQueue (06:11:25.625) - MainThread (6504):
Error in func VirtualBuffer._loadBufferDone
Traceback (most recent call last):
  File "queueHandler.pyc", line 55, in flushQueue
  File "virtualBuffers\__init__.pyc", line 470, in _loadBufferDone
  File "browseMode.pyc", line 1280, in event_treeInterceptor_gainFocus
  File "enum.pyc", line 354, in __getattr__
AttributeError: Focus
### Expected behavior:
No error.
### System configuration
#### NVDA installed/portable/running from source:
Installed
#### NVDA version:
alpha-21672,856adec6
#### Windows version:
Windows 10, Version	10.0.21296 Build 21296.
#### Name and version of other software in use when reproducing the issue:
Firefox 87.0a1, Thunderbird 78.7.0.
#### Other information about your system:
N/a.
### Other questions
#### Does the issue still occur after restarting your computer?
Yes.
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes, alpha-21668,e8f14f9a works normally.
#### If addons are disabled, is your problem still occuring?
Yes.
#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
Yes.


Discussion:
I have just seen this in opening an email in an mshtml mail program, a 
modified outlook express actually, and posted a query in the dev list before 
I found this issue here.

Input: kb(desktop):downArrow
IO - speech.speak (11:58:08.788) - MainThread (332):
Speaking [LangChangeCommand ('en_GB'), 'has attachment; From: 
swl.desp@nhs.net; Subject: Mr Brian Gaff; Received: 27/01/2021 10:35', '757 
of 757']
IO - inputCore.InputManager.executeGesture (11:58:10.930) - winInputHook 
(3188):
Input: kb(desktop):downArrow
IO - inputCore.InputManager.executeGesture (11:58:21.642) - winInputHook 
(3188):
Input: kb(desktop):enter
IO - speech.speak (11:58:21.691) - MainThread (332):
Speaking [LangChangeCommand ('en_GB'), 'Mr Brian Gaff']
DEBUG - treeInterceptorHandler.update (11:58:21.746) - MainThread (332):
Adding new treeInterceptor to runningTable: <virtualBuffers.MSHTML.MSHTML 
object at 0x06739B50>
DEBUG - virtualBuffers.VirtualBuffer._loadBuffer (11:58:21.747) - 
virtualBuffers.MSHTML.VirtualBuffer.loadBuffer (2896):
Buffer load took 0.001 sec, 76 chars
ERROR - queueHandler.flushQueue (11:58:21.755) - MainThread (332):
Error in func VirtualBuffer._loadBufferDone
Traceback (most recent call last):
  File "queueHandler.pyc", line 55, in flushQueue
  File "virtualBuffers\__init__.pyc", line 470, in _loadBufferDone
  File "browseMode.pyc", line 1280, in event_treeInterceptor_gainFocus
  File "enum.pyc", line 354, in __getattr__
AttributeError: Focus
IO - inputCore.InputManager.executeGesture (11:58:25.218) - winInputHook 
(3188):
Input: kb(desktop):control+alt+r
IO - speech.speak (11:58:25.324) - MainThread (332):
Speaking [LangChangeCommand ('en_GB'), 'reboot nvda with log', 'terminal', 
'80 space', 'blank']
INFO - core.main (11:58:25.528) - MainThread (332):
Exiting

That was in Alpha,not tested anything else yet and might also explain why 
nvda has started talking about the email addresses when its actually 
focussed on subject in an open email reply.

Brian

bglists@blueyonder.co.uk
Sent via blueyonder.
Please address personal E-mail to:-
briang1@blueyonder.co.uk, putting 'Brian Gaff'
in the display name field.



Resolving patch:
diff --git a/source/browseMode.py b/source/browseMode.py
--- a/source/browseMode.py
+++ b/source/browseMode.py
@@ -1277,7 +1277,7 @@ def event_treeInterceptor_gainFocus(self):
 
 		if not self.passThrough:
 			if doSayAll:
-				speech.speakObjectProperties(self.rootNVDAObject, name=True, states=True, reason=OutputReason.Focus)
+				speech.speakObjectProperties(self.rootNVDAObject, name=True, states=True, reason=OutputReason.FOCUS)
 				sayAllHandler.readText(sayAllHandler.CURSOR_CARET)
 			else:
 				# Speak it like we would speak focus on any other document object.


Test patch: