JSDoc: Class: Checks

# Class: Checks

## accessibility.Checks(strict)

Component responsible for interacting with platform accessibility API.

Its methods serve as wrappers for testing content and chrome accessibility as well as accessibility of user interactions.

## Constructor

#### new Checks(strict)

##### Parameters:

Name | Type | Description
--- | --- | ---
`strict` | boolean | Flag indicating whether the accessibility issue should be logged or cause an error to be thrown. Default is to log to stdout.

Source:
  - accessibility.js, line 108

### Methods

#### assertActionable(accessible, element)

Test if it is possible to activate an element with the accessibility API.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.
`element` | DOMElement | XULElement | Element associated with |accessible|.

Source:
  - accessibility.js, line 372

##### Throws:

ElementNotAccessibleError If it is impossible to activate |element| with |accessible|.

#### assertEnabled(accessible, element, enabled)

Test if the element's unavailable accessibility state matches the enabled state.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.
`element` | DOMElement | XULElement | Element associated with |accessible|.
`enabled` | boolean | Enabled state of |element|.

Source:
  - accessibility.js, line 337

##### Throws:

ElementNotAccessibleError If |element|'s enabled state does not match |accessible|'s.

#### assertSelected(accessible, Element, selected)

Test that an element's selected state corresponds to its accessibility API selected state.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.
`Element` | DOMElement | XULElement | associated with |accessible|.
`selected` | boolean | The |element|s selected state.

Source:
  - accessibility.js, line 407

##### Throws:

ElementNotAccessibleError If |element|'s selected state does not correspond to |accessible|'s.

#### assertVisible(accessible, element, visible)

Test if the element's visible state corresponds to its accessibility API visibility.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.
`element` | DOMElement | XULElement | Element associated with |accessible|.
`visible` | boolean | Visibility state of |element|.

Source:
  - accessibility.js, line 305

##### Throws:

ElementNotAccessibleError If |element|'s visibility state does not correspond to |accessible|'s.

#### error(message, element)

Throw an error if strict accessibility checks are enforced and log the error to the log.

##### Parameters:

Name | Type | Description
--- | --- | ---
`message` | string |
`element` | DOMElement | XULElement | Element that caused an error.

Source:
  - accessibility.js, line 440

##### Throws:

ElementNotAccessibleError If |strict| is true.

#### getAccessible(element, mustHaveAccessibleopt) → {Promise.<nsIAccessible>}

Get an accessible object for an element.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`element` | DOMElement | XULElement |  |  | Element to get the accessible object for.
`mustHaveAccessible` | boolean | <optional> | false | Flag indicating that the element must have an accessible object. Defaults to not require this.

Source:
  - accessibility.js, line 131

##### Returns:

Promise with an accessibility object for the given element.

Type
  Promise.<nsIAccessible>

#### hasActionCount(accessible) → {boolean}

Test if an accessible has at least one action that it supports.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.

Source:
  - accessibility.js, line 216

##### Returns:

True if the accessible has at least one supported action, false otherwise.

Type
  boolean

#### hasHiddenAttribute(accessible) → {boolean}

Test if an accessible has a {@code hidden} attribute.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.

Source:
  - accessibility.js, line 244

##### Returns:

True if the accessible object has a {@code hidden} attribute, false otherwise.

Type
  boolean

#### hasValidName(accessible) → {boolean}

Test if an accessible has a valid name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.

Source:
  - accessibility.js, line 230

##### Returns:

True if the accessible has a non-empty valid name, or false if this is not the case.

Type
  boolean

#### isActionableRole(accessible) → {boolean}

Test if the accessible has a role that supports some arbitrary action.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.

Source:
  - accessibility.js, line 201

##### Returns:

True if an actionable role is found on the accessible, false otherwise.

Type
  boolean

#### isHidden(accessible) → {boolean}

Test if an accessible is hidden from the user.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object.

Source:
  - accessibility.js, line 280

##### Returns:

True if element is hidden from user, false otherwise.

Type
  boolean

#### matchState(accessible, stateToMatch) → {boolean}

Verify if an accessible has a given state. Test if an accessible has a given state.

##### Parameters:

Name | Type | Description
--- | --- | ---
`accessible` | nsIAccessible | Accessible object to test.
`stateToMatch` | number | State to match.

Source:
  - accessibility.js, line 265

##### Returns:

True if |accessible| has |stateToMatch|, false otherwise.

Type
  boolean