Bug 1383501: Modify a11y::IsHandlerRegistered to include check of path to handler binary; r=eeejay
authorAaron Klotz <aklotz@mozilla.com>
Thu, 14 Sep 2017 13:05:26 -0600
changeset 665161 9e895d32653b939602552eb859c319b50457afba
parent 665160 69521f759e299849c0ae9ab0f7f11ea322730aea
child 665162 f01cd7cd431c204e8792e2ddf961eb6891072706
push id79943
push userbmo:tchiovoloni@mozilla.com
push dateThu, 14 Sep 2017 23:59:48 +0000
reviewerseeejay
bugs1383501
milestone57.0a1
Bug 1383501: Modify a11y::IsHandlerRegistered to include check of path to handler binary; r=eeejay
accessible/windows/msaa/Platform.cpp
--- a/accessible/windows/msaa/Platform.cpp
+++ b/accessible/windows/msaa/Platform.cpp
@@ -15,16 +15,18 @@
 #include "nsWinUtils.h"
 #include "mozilla/a11y/ProxyAccessible.h"
 #include "mozilla/mscom/ActivationContext.h"
 #include "mozilla/mscom/InterceptorLog.h"
 #include "mozilla/mscom/Registration.h"
 #include "mozilla/mscom/Utils.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/WindowsVersion.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsDirectoryServiceUtils.h"
 #include "ProxyWrappers.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 using namespace mozilla::mscom;
 
 static StaticAutoPtr<RegisteredProxy> gRegCustomProxy;
 static StaticAutoPtr<RegisteredProxy> gRegProxy;
@@ -204,17 +206,42 @@ a11y::IsHandlerRegistered()
   subKey.AppendLiteral(u"\\InprocHandler32");
 
   rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, subKey,
                     nsIWindowsRegKey::ACCESS_READ);
   if (NS_FAILED(rv)) {
     return false;
   }
 
-  return true;
+  nsAutoString handlerPath;
+  rv = regKey->ReadStringValue(nsAutoString(), handlerPath);
+  if (NS_FAILED(rv)) {
+    return false;
+  }
+
+  nsCOMPtr<nsIFile> actualHandler;
+  rv = NS_NewLocalFile(handlerPath, false, getter_AddRefs(actualHandler));
+  if (NS_FAILED(rv)) {
+    return false;
+  }
+
+  nsCOMPtr<nsIFile> expectedHandler;
+  rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(expectedHandler));
+  if (NS_FAILED(rv)) {
+    return false;
+  }
+
+  rv = expectedHandler->Append(NS_LITERAL_STRING("AccessibleHandler.dll"));
+  if (NS_FAILED(rv)) {
+    return false;
+  }
+
+  bool equal;
+  rv = expectedHandler->Equals(actualHandler, &equal);
+  return NS_SUCCEEDED(rv) && equal;
 }
 
 void
 a11y::SetInstantiator(const nsAString& aInstantiator)
 {
   if (!gInstantiator) {
     gInstantiator = new nsString();
   }