forked from mirrors/gecko-dev
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:
parent
4523f18d89
commit
ccfae4a0f0
3 changed files with 55 additions and 1 deletions
|
|
@ -15,11 +15,17 @@
|
||||||
interface nsIAccessibleMacInterface : nsISupports
|
interface nsIAccessibleMacInterface : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List of available attribute names for tthe object.
|
* List of available attribute names for the object.
|
||||||
* Emulates `AXUIElementCopyAttributeNames`.
|
* Emulates `AXUIElementCopyAttributeNames`.
|
||||||
*/
|
*/
|
||||||
readonly attribute Array<AString> attributeNames;
|
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.
|
* List of available action names for tthe object.
|
||||||
* Emulates `AXUIElementCopyActionNames`.
|
* Emulates `AXUIElementCopyActionNames`.
|
||||||
|
|
@ -33,6 +39,13 @@ interface nsIAccessibleMacInterface : nsISupports
|
||||||
[implicit_jscontext]
|
[implicit_jscontext]
|
||||||
jsval getAttributeValue(in AString attributeName);
|
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.
|
* Requests that the accessibility object perform the specified action.
|
||||||
* Emulatets `AXUIElementPerformAction`.
|
* Emulatets `AXUIElementPerformAction`.
|
||||||
|
|
|
||||||
|
|
@ -81,5 +81,11 @@ addAccessibleTask(
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.deepEqual(domSelection, [1, 8], "correct DOM selection");
|
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_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
|
NS_IMETHODIMP
|
||||||
xpcAccessibleMacInterface::GetActionNames(nsTArray<nsString>& aActionNames) {
|
xpcAccessibleMacInterface::GetActionNames(nsTArray<nsString>& aActionNames) {
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
|
||||||
|
|
@ -127,6 +146,22 @@ xpcAccessibleMacInterface::SetAttributeValue(const nsAString& aAttributeName,
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
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) {
|
bool xpcAccessibleMacInterface::SupportsSelector(SEL aSelector) {
|
||||||
// return true if we have this selector, and if isAccessibilitySelectorAllowed
|
// return true if we have this selector, and if isAccessibilitySelectorAllowed
|
||||||
// is implemented too whether it is "allowed".
|
// is implemented too whether it is "allowed".
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue