зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 9eeddf4d34ea (bug 1191432) for various Gij failures.
CLOSED TREE
This commit is contained in:
Родитель
1641a57a57
Коммит
6cfdf70c9e
|
@ -16,13 +16,7 @@ class TestAccessibility(MarionetteTestCase):
|
||||||
"button1",
|
"button1",
|
||||||
# Button2 is an accessible button with a valid accessible name
|
# Button2 is an accessible button with a valid accessible name
|
||||||
# computed from aria-label
|
# computed from aria-label
|
||||||
"button2",
|
"button2"
|
||||||
# Button13 is an accessible button that is implemented via role="button"
|
|
||||||
# and is explorable using tabindex="0"
|
|
||||||
"button13",
|
|
||||||
# button17 is an accessible button that overrides parent's
|
|
||||||
# pointer-events:none; property with its own pointer-events:all;
|
|
||||||
"button17"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Elements that are not accessible with the accessibility API
|
# Elements that are not accessible with the accessibility API
|
||||||
|
@ -41,10 +35,7 @@ class TestAccessibility(MarionetteTestCase):
|
||||||
"button7",
|
"button7",
|
||||||
# Button8 is not currently visible via the accessibility API and may
|
# Button8 is not currently visible via the accessibility API and may
|
||||||
# not be manipulated by it (in hidden subtree)
|
# not be manipulated by it (in hidden subtree)
|
||||||
"button8",
|
"button8"
|
||||||
# Button14 is accessible button but is not explorable because of lack
|
|
||||||
# of tabindex that would make it focusable.
|
|
||||||
"button14"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Elements that are either accessible to accessibility API or not accessible
|
# Elements that are either accessible to accessibility API or not accessible
|
||||||
|
@ -66,12 +57,6 @@ class TestAccessibility(MarionetteTestCase):
|
||||||
|
|
||||||
disabled_elementIDs = ["button11", "no_accessible_but_disabled"]
|
disabled_elementIDs = ["button11", "no_accessible_but_disabled"]
|
||||||
|
|
||||||
# Elements that are enabled but otherwise disabled or not explorable via the accessibility API
|
|
||||||
disabled_accessibility_elementIDs = ["button12", "button15", "button16"]
|
|
||||||
|
|
||||||
# Elements that are reporting selected state
|
|
||||||
valid_option_elementIDs = ["option1", "option2"]
|
|
||||||
|
|
||||||
def run_element_test(self, ids, testFn):
|
def run_element_test(self, ids, testFn):
|
||||||
for id in ids:
|
for id in ids:
|
||||||
element = self.marionette.find_element("id", id)
|
element = self.marionette.find_element("id", id)
|
||||||
|
@ -144,50 +129,13 @@ class TestAccessibility(MarionetteTestCase):
|
||||||
# No exception should be raised
|
# No exception should be raised
|
||||||
self.run_element_test(self.displayed_elementIDs, lambda element: element.is_displayed())
|
self.run_element_test(self.displayed_elementIDs, lambda element: element.is_displayed())
|
||||||
|
|
||||||
def test_element_is_not_enabled_to_accessbility(self):
|
def test_is_element_is_not_enabled_to_accessbility(self):
|
||||||
self.setup_accessibility()
|
self.setup_accessibility()
|
||||||
# Buttons are enabled but disabled/not-explorable via the accessibility API
|
# Button is enabled but disabled via the accessibility API
|
||||||
self.run_element_test(self.disabled_accessibility_elementIDs,
|
self.assertRaises(ElementNotAccessibleException,
|
||||||
lambda element: self.assertRaises(ElementNotAccessibleException,
|
self.marionette.find_element("id", "button12").is_enabled)
|
||||||
element.is_enabled))
|
|
||||||
|
|
||||||
# Buttons are enabled but disabled/not-explorable via the accessibility API and thus are not
|
|
||||||
# clickable via the accessibility API
|
|
||||||
self.run_element_test(self.disabled_accessibility_elementIDs,
|
|
||||||
lambda element: self.assertRaises(ElementNotAccessibleException,
|
|
||||||
element.click))
|
|
||||||
|
|
||||||
self.setup_accessibility(False, False)
|
|
||||||
self.run_element_test(self.disabled_accessibility_elementIDs,
|
|
||||||
lambda element: element.is_enabled())
|
|
||||||
self.run_element_test(self.disabled_accessibility_elementIDs,
|
|
||||||
lambda element: element.click())
|
|
||||||
|
|
||||||
def test_element_is_enabled_to_accessibility(self):
|
def test_element_is_enabled_to_accessibility(self):
|
||||||
self.setup_accessibility()
|
self.setup_accessibility()
|
||||||
# No exception should be raised
|
# No exception should be raised
|
||||||
self.run_element_test(self.disabled_elementIDs, lambda element: element.is_enabled())
|
self.run_element_test(self.disabled_elementIDs, lambda element: element.is_enabled())
|
||||||
|
|
||||||
def test_send_keys_raises_no_exception(self):
|
|
||||||
self.setup_accessibility()
|
|
||||||
# Sending keys to valid input should not raise any exceptions
|
|
||||||
self.run_element_test(['input1'], lambda element: element.send_keys("a"))
|
|
||||||
|
|
||||||
self.setup_accessibility(False, False)
|
|
||||||
# Sending keys to invalid element should not raise any exceptions when raising accessibility
|
|
||||||
# exceptions is disabled
|
|
||||||
self.run_element_test(['button5'], lambda element: element.send_keys("abc"))
|
|
||||||
|
|
||||||
def test_send_keys_raises_element_not_accessible(self):
|
|
||||||
self.setup_accessibility()
|
|
||||||
# Sending keys to invalid element should raise an exception
|
|
||||||
self.run_element_test(['button5'],
|
|
||||||
lambda element: self.assertRaises(ElementNotAccessibleException,
|
|
||||||
element.send_keys))
|
|
||||||
|
|
||||||
def test_is_selected_raises_no_exception(self):
|
|
||||||
self.setup_accessibility()
|
|
||||||
# No exception should be raised for valid options
|
|
||||||
self.run_element_test(self.valid_option_elementIDs, lambda element: element.is_selected())
|
|
||||||
# No exception should be raised for non-selectable elements
|
|
||||||
self.run_element_test(self.valid_elementIDs, lambda element: element.is_selected())
|
|
||||||
|
|
|
@ -32,22 +32,7 @@
|
||||||
<button id="button11" disabled>button11</button>
|
<button id="button11" disabled>button11</button>
|
||||||
<button id="button12" aria-disabled="true">button12</button>
|
<button id="button12" aria-disabled="true">button12</button>
|
||||||
<span id="no_accessible_but_disabled" disabled>I have no accessible object</span>
|
<span id="no_accessible_but_disabled" disabled>I have no accessible object</span>
|
||||||
<span id="button13" tabindex="0" role="button" aria-label="Span button">Span button</span>
|
|
||||||
<span id="button14" role="button" aria-label="Span button">Unexplorable Span button</span>
|
|
||||||
<button id="button15" style="pointer-events:none;">button15</button>
|
|
||||||
<div style="pointer-events:none;">
|
|
||||||
<button id="button16">button16</button>
|
|
||||||
</div>
|
|
||||||
<div style="pointer-events:none;">
|
|
||||||
<button style="pointer-events:all;" id="button17">button17</button>
|
|
||||||
</div>
|
|
||||||
<input id="input1" title="My Input 1" name="myInput1" type="text" value="asdf"/>
|
|
||||||
<select>
|
|
||||||
<option id="option1" value="val1">Val1</option>
|
|
||||||
<option id="option2" value="val2" selected>Val2</option>
|
|
||||||
</select>
|
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
|
||||||
document.getElementById('button5').addEventListener('click', function() {
|
document.getElementById('button5').addEventListener('click', function() {
|
||||||
// A pseudo button that has a listener but is missing button semantics.
|
// A pseudo button that has a listener but is missing button semantics.
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,8 +79,6 @@ Accessibility.prototype = {
|
||||||
'radio menu item',
|
'radio menu item',
|
||||||
'option',
|
'option',
|
||||||
'radiobutton',
|
'radiobutton',
|
||||||
'rowheader',
|
|
||||||
'switch',
|
|
||||||
'slider',
|
'slider',
|
||||||
'spinbutton',
|
'spinbutton',
|
||||||
'pagetab',
|
'pagetab',
|
||||||
|
|
|
@ -928,28 +928,16 @@ function singleTap(msg) {
|
||||||
* Check if the element's unavailable accessibility state matches the enabled
|
* Check if the element's unavailable accessibility state matches the enabled
|
||||||
* state
|
* state
|
||||||
* @param nsIAccessible object
|
* @param nsIAccessible object
|
||||||
* @param WebElement corresponding to nsIAccessible object
|
|
||||||
* @param Boolean enabled element's enabled state
|
* @param Boolean enabled element's enabled state
|
||||||
*/
|
*/
|
||||||
function checkEnabledAccessibility(accesible, element, enabled) {
|
function checkEnabledStateAccessibility(accesible, enabled) {
|
||||||
if (!accesible) {
|
if (!accesible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let disabledAccessibility = accessibility.matchState(
|
if (enabled && accessibility.matchState(accesible, 'STATE_UNAVAILABLE')) {
|
||||||
accesible, 'STATE_UNAVAILABLE');
|
accessibility.handleErrorMessage('Element is enabled but disabled via ' +
|
||||||
let explorable = curFrame.document.defaultView.getComputedStyle(
|
'the accessibility API');
|
||||||
element, null).getPropertyValue('pointer-events') !== 'none';
|
|
||||||
let message;
|
|
||||||
|
|
||||||
if (!explorable && !disabledAccessibility) {
|
|
||||||
message = 'Element is enabled but is not explorable via the ' +
|
|
||||||
'accessibility API';
|
|
||||||
} else if (enabled && disabledAccessibility) {
|
|
||||||
message = 'Element is enabled but disabled via the accessibility API';
|
|
||||||
} else if (!enabled && !disabledAccessibility) {
|
|
||||||
message = 'Element is disabled but enabled via the accessibility API';
|
|
||||||
}
|
}
|
||||||
accessibility.handleErrorMessage(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -990,34 +978,6 @@ function checkActionableAccessibility(accesible) {
|
||||||
'and may not be manipulated via the accessibility API';
|
'and may not be manipulated via the accessibility API';
|
||||||
} else if (!accessibility.hasValidName(accesible)) {
|
} else if (!accessibility.hasValidName(accesible)) {
|
||||||
message = 'Element is missing an accesible name';
|
message = 'Element is missing an accesible name';
|
||||||
} else if (!accessibility.matchState(accesible, 'STATE_FOCUSABLE')) {
|
|
||||||
message = 'Element is not focusable via the accessibility API';
|
|
||||||
}
|
|
||||||
accessibility.handleErrorMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if element's selected state corresponds to its accessibility API
|
|
||||||
* selected state.
|
|
||||||
* @param nsIAccessible object
|
|
||||||
* @param Boolean selected element's selected state
|
|
||||||
*/
|
|
||||||
function checkSelectedAccessibility(accessible, selected) {
|
|
||||||
if (!accessible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!accessibility.matchState(accessible, 'STATE_SELECTABLE')) {
|
|
||||||
// Element is not selectable via the accessibility API
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let selectedAccessibility = accessibility.matchState(
|
|
||||||
accessible, 'STATE_SELECTED');
|
|
||||||
let message;
|
|
||||||
if (selected && !selectedAccessibility) {
|
|
||||||
message = 'Element is selected but not selected via the accessibility API';
|
|
||||||
} else if (!selected && selectedAccessibility) {
|
|
||||||
message = 'Element is not selected but selected via the accessibility API';
|
|
||||||
}
|
}
|
||||||
accessibility.handleErrorMessage(message);
|
accessibility.handleErrorMessage(message);
|
||||||
}
|
}
|
||||||
|
@ -1435,7 +1395,6 @@ function clickElement(id) {
|
||||||
}
|
}
|
||||||
checkActionableAccessibility(acc);
|
checkActionableAccessibility(acc);
|
||||||
if (utils.isElementEnabled(el)) {
|
if (utils.isElementEnabled(el)) {
|
||||||
checkEnabledAccessibility(acc, el, true);
|
|
||||||
utils.synthesizeMouseAtCenter(el, {}, el.ownerDocument.defaultView);
|
utils.synthesizeMouseAtCenter(el, {}, el.ownerDocument.defaultView);
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidElementStateError("Element is not Enabled");
|
throw new InvalidElementStateError("Element is not Enabled");
|
||||||
|
@ -1568,8 +1527,7 @@ function getElementRect(id) {
|
||||||
function isElementEnabled(id) {
|
function isElementEnabled(id) {
|
||||||
let el = elementManager.getKnownElement(id, curFrame);
|
let el = elementManager.getKnownElement(id, curFrame);
|
||||||
let enabled = utils.isElementEnabled(el);
|
let enabled = utils.isElementEnabled(el);
|
||||||
checkEnabledAccessibility(
|
checkEnabledStateAccessibility(accessibility.getAccessibleObject(el), enabled);
|
||||||
accessibility.getAccessibleObject(el), el, enabled);
|
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1580,9 +1538,7 @@ function isElementSelected(msg) {
|
||||||
let command_id = msg.json.command_id;
|
let command_id = msg.json.command_id;
|
||||||
try {
|
try {
|
||||||
let el = elementManager.getKnownElement(msg.json.id, curFrame);
|
let el = elementManager.getKnownElement(msg.json.id, curFrame);
|
||||||
let selected = utils.isElementSelected(el);
|
sendResponse({value: utils.isElementSelected(el)}, command_id);
|
||||||
checkSelectedAccessibility(accessibility.getAccessibleObject(el), selected);
|
|
||||||
sendResponse({value: selected}, command_id);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendError(e, command_id);
|
sendError(e, command_id);
|
||||||
}
|
}
|
||||||
|
@ -1595,11 +1551,7 @@ function sendKeysToElement(msg) {
|
||||||
let command_id = msg.json.command_id;
|
let command_id = msg.json.command_id;
|
||||||
let val = msg.json.value;
|
let val = msg.json.value;
|
||||||
|
|
||||||
try {
|
|
||||||
let el = elementManager.getKnownElement(msg.json.id, curFrame);
|
let el = elementManager.getKnownElement(msg.json.id, curFrame);
|
||||||
// Element should be actionable from the accessibility standpoint to be able
|
|
||||||
// to send keys to it.
|
|
||||||
checkActionableAccessibility(accessibility.getAccessibleObject(el, true));
|
|
||||||
if (el.type == "file") {
|
if (el.type == "file") {
|
||||||
let p = val.join("");
|
let p = val.join("");
|
||||||
fileInputElement = el;
|
fileInputElement = el;
|
||||||
|
@ -1611,9 +1563,6 @@ function sendKeysToElement(msg) {
|
||||||
} else {
|
} else {
|
||||||
utils.sendKeysToElement(curFrame, el, val, sendOk, sendError, command_id);
|
utils.sendKeysToElement(curFrame, el, val, sendOk, sendError, command_id);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
sendError(e, command_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче