diff --git a/src/Core/Bases/A11yElement.cs b/src/Core/Bases/A11yElement.cs
index 566cfde4b..97098d0fb 100644
--- a/src/Core/Bases/A11yElement.cs
+++ b/src/Core/Bases/A11yElement.cs
@@ -693,6 +693,10 @@ private static A11yElement FromText(string json)
UpdateParent(null, e);
+ // Make ProcessName deterministically empty when loading a file. If we fail
+ // to do this, the ProcessName may incorrectly return a currently running process
+ ClearProcessName(e);
+
return e;
}
@@ -717,6 +721,24 @@ private static void UpdateParent(A11yElement p, A11yElement e)
}
}
+ ///
+ /// Explicitly set the ProcessName property to return string.Empty for the given
+ /// element and for all of its descendants.
+ ///
+ /// The element to update
+ private static void ClearProcessName(A11yElement e)
+ {
+ e._ProcessName = string.Empty;
+
+ if (e.Children == null || e.Children.Count == 0)
+ return;
+
+ foreach (A11yElement child in e.Children)
+ {
+ ClearProcessName(child);
+ }
+ }
+
#region IDisposable Support
private bool _disposedValue = false; // To detect redundant calls
protected bool DisposedValue { get => _disposedValue; set => _disposedValue = value; }