Bug 732908 - Expose 'Firefox' and 'Thunderbird' as the accessible app names -- even for pre-release versions, r=ginn

This commit is contained in:
Alexander Surkov 2012-03-06 19:01:55 +09:00
parent 11dbe5c7e5
commit eed57b3c71
3 changed files with 42 additions and 25 deletions

View File

@ -696,6 +696,16 @@ nsApplicationAccessibleWrap::Unload()
// }
}
NS_IMETHODIMP
nsApplicationAccessibleWrap::GetName(nsAString& aName)
{
// ATK doesn't provide a way to obtain an application name (for example,
// Firefox or Thunderbird) like IA2 does. Thus let's return an application
// name as accessible name that was used to get a branding name (for example,
// Minefield aka nightly Firefox or Daily aka nightly Thunderbird).
return GetAppName(aName);
}
NS_IMETHODIMP
nsApplicationAccessibleWrap::GetNativeInterface(void **aOutAccessible)
{

View File

@ -57,6 +57,8 @@ public:
virtual bool Init();
// nsAccessible
NS_IMETHOD GetName(nsAString &aName);
virtual bool AppendChild(nsAccessible* aChild);
virtual bool RemoveChild(nsAccessible* aChild);

View File

@ -15,41 +15,46 @@
<script type="application/javascript">
function doTest()
{
var accessible = getApplicationAccessible();
if (!accessible) {
SimpleTest.finish();
return;
}
var accessible = getApplicationAccessible();
if (!accessible) {
SimpleTest.finish();
return;
}
// nsIAccessible::name
var bundleServ = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var bundle = bundleServ.createBundle("chrome://branding/locale/brand.properties");
var bundleServ =
Components.classes["@mozilla.org/intl/stringbundle;1"].
getService(Components.interfaces.nsIStringBundleService);
var brandBundle =
bundleServ.createBundle("chrome://branding/locale/brand.properties");
var applicationName = "";
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
getService(Components.interfaces.nsIXULAppInfo);
// nsIAccessible::name
var applicationName = "";
if (LINUX || SOLARIS) {
applicationName = appInfo.name;
} else {
try {
applicationName = bundle.GetStringFromName("brandShortName");
} catch(e) {
applicationName = brandBundle.GetStringFromName("brandShortName");
} catch(e) {
}
if (applicationName == "")
applicationName = "Gecko based application";
applicationName = "Gecko based application";
}
is (accessible.name, applicationName, "wrong application accessible name");
is (accessible.name, applicationName, "wrong application accessible name");
// nsIAccessibleApplication
is(accessible.appName, appInfo.name, "Wrong application name");
is(accessible.appVersion, appInfo.version, "Wrong application version");
is(accessible.platformName, "Gecko", "Wrong platform name");
is(accessible.platformVersion, appInfo.platformVersion,
"Wrong platform version");
// nsIAccessibleApplication
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"].
getService(Components.interfaces.nsIXULAppInfo);
is(accessible.appName, appInfo.name, "Wrong application name");
is(accessible.appVersion, appInfo.version, "Wrong application version");
is(accessible.platformName, "Gecko", "Wrong platform name");
is(accessible.platformVersion, appInfo.platformVersion,
"Wrong platform version");
SimpleTest.finish();
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>