зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1642030 - Support testing of parameterized attributes in Mac mochitests. r=morgan
Depends on D77559 Differential Revision: https://phabricator.services.mozilla.com/D77562
This commit is contained in:
Родитель
4523f18d89
Коммит
ccfae4a0f0
|
@ -15,11 +15,17 @@
|
|||
interface nsIAccessibleMacInterface : nsISupports
|
||||
{
|
||||
/**
|
||||
* List of available attribute names for tthe object.
|
||||
* List of available attribute names for the object.
|
||||
* Emulates `AXUIElementCopyAttributeNames`.
|
||||
*/
|
||||
readonly attribute Array<AString> attributeNames;
|
||||
|
||||
/**
|
||||
* List of available parameterized attribute names for the object.
|
||||
* Emulates `AXUIElementCopyParameterizedAttributeNames`.
|
||||
*/
|
||||
readonly attribute Array<AString> parameterizedAttributeNames;
|
||||
|
||||
/**
|
||||
* List of available action names for tthe object.
|
||||
* Emulates `AXUIElementCopyActionNames`.
|
||||
|
@ -33,6 +39,13 @@ interface nsIAccessibleMacInterface : nsISupports
|
|||
[implicit_jscontext]
|
||||
jsval getAttributeValue(in AString attributeName);
|
||||
|
||||
/**
|
||||
* Returns the value of an attribute given a name and a parameter.
|
||||
* Emulates `AXUIElementCopyParameterizedAttributeValue`.
|
||||
**/
|
||||
[implicit_jscontext]
|
||||
jsval getParameterizedAttributeValue(in AString attributeName, in jsval parameter);
|
||||
|
||||
/**
|
||||
* Requests that the accessibility object perform the specified action.
|
||||
* Emulatets `AXUIElementPerformAction`.
|
||||
|
|
|
@ -81,5 +81,11 @@ addAccessibleTask(
|
|||
});
|
||||
|
||||
Assert.deepEqual(domSelection, [1, 8], "correct DOM selection");
|
||||
|
||||
is(
|
||||
input.getParameterizedAttributeValue("AXStringForRange", NSRange(3, 5)),
|
||||
"er Fu",
|
||||
"AXStringForRange works"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -47,6 +47,25 @@ xpcAccessibleMacInterface::GetAttributeNames(nsTArray<nsString>& aAttributeNames
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::GetParameterizedAttributeNames(nsTArray<nsString>& aAttributeNames) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
|
||||
|
||||
if (!mNativeObject || [mNativeObject isExpired]) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
for (NSString* name in [mNativeObject accessibilityParameterizedAttributeNames]) {
|
||||
nsAutoString attribName;
|
||||
nsCocoaUtils::GetStringForNSString(name, attribName);
|
||||
aAttributeNames.AppendElement(attribName);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::GetActionNames(nsTArray<nsString>& aActionNames) {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
|
||||
|
@ -127,6 +146,22 @@ xpcAccessibleMacInterface::SetAttributeValue(const nsAString& aAttributeName,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::GetParameterizedAttributeValue(const nsAString& aAttributeName,
|
||||
JS::HandleValue aParameter,
|
||||
JSContext* aCx,
|
||||
JS::MutableHandleValue aResult) {
|
||||
nsresult rv = NS_OK;
|
||||
id paramObj = JsValueToNSObject(aParameter, aCx, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NSString* attribName = nsCocoaUtils::ToNSString(aAttributeName);
|
||||
return NSObjectToJsValue(
|
||||
[mNativeObject accessibilityAttributeValue:attribName forParameter:paramObj], aCx, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool xpcAccessibleMacInterface::SupportsSelector(SEL aSelector) {
|
||||
// return true if we have this selector, and if isAccessibilitySelectorAllowed
|
||||
// is implemented too whether it is "allowed".
|
||||
|
|
Загрузка…
Ссылка в новой задаче