Backed out changeset 9eeddf4d34ea (bug 1191432) for various Gij failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2015-08-10 10:29:13 -04:00
parent f1286c1802
commit 737ec92bd5
4 changed files with 24 additions and 144 deletions

View File

@ -4,7 +4,7 @@
from marionette import MarionetteTestCase
from marionette_driver.errors import (ElementNotAccessibleException,
ElementNotVisibleException)
ElementNotVisibleException)
class TestAccessibility(MarionetteTestCase):
@ -16,13 +16,7 @@ class TestAccessibility(MarionetteTestCase):
"button1",
# Button2 is an accessible button with a valid accessible name
# computed from aria-label
"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"
"button2"
]
# Elements that are not accessible with the accessibility API
@ -41,10 +35,7 @@ class TestAccessibility(MarionetteTestCase):
"button7",
# Button8 is not currently visible via the accessibility API and may
# not be manipulated by it (in hidden subtree)
"button8",
# Button14 is accessible button but is not explorable because of lack
# of tabindex that would make it focusable.
"button14"
"button8"
]
# 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"]
# 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):
for id in ids:
element = self.marionette.find_element("id", id)
@ -144,50 +129,13 @@ class TestAccessibility(MarionetteTestCase):
# No exception should be raised
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()
# Buttons are enabled but disabled/not-explorable via the accessibility API
self.run_element_test(self.disabled_accessibility_elementIDs,
lambda element: self.assertRaises(ElementNotAccessibleException,
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())
# Button is enabled but disabled via the accessibility API
self.assertRaises(ElementNotAccessibleException,
self.marionette.find_element("id", "button12").is_enabled)
def test_element_is_enabled_to_accessibility(self):
self.setup_accessibility()
# No exception should be raised
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())

View File

@ -32,22 +32,7 @@
<button id="button11" disabled>button11</button>
<button id="button12" aria-disabled="true">button12</button>
<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>
'use strict';
document.getElementById('button5').addEventListener('click', function() {
// A pseudo button that has a listener but is missing button semantics.
return true;

View File

@ -79,8 +79,6 @@ Accessibility.prototype = {
'radio menu item',
'option',
'radiobutton',
'rowheader',
'switch',
'slider',
'spinbutton',
'pagetab',

View File

@ -928,28 +928,16 @@ function singleTap(msg) {
* Check if the element's unavailable accessibility state matches the enabled
* state
* @param nsIAccessible object
* @param WebElement corresponding to nsIAccessible object
* @param Boolean enabled element's enabled state
*/
function checkEnabledAccessibility(accesible, element, enabled) {
function checkEnabledStateAccessibility(accesible, enabled) {
if (!accesible) {
return;
}
let disabledAccessibility = accessibility.matchState(
accesible, 'STATE_UNAVAILABLE');
let explorable = curFrame.document.defaultView.getComputedStyle(
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';
if (enabled && accessibility.matchState(accesible, 'STATE_UNAVAILABLE')) {
accessibility.handleErrorMessage('Element is enabled but disabled via ' +
'the accessibility API');
}
accessibility.handleErrorMessage(message);
}
/**
@ -990,34 +978,6 @@ function checkActionableAccessibility(accesible) {
'and may not be manipulated via the accessibility API';
} else if (!accessibility.hasValidName(accesible)) {
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);
}
@ -1435,7 +1395,6 @@ function clickElement(id) {
}
checkActionableAccessibility(acc);
if (utils.isElementEnabled(el)) {
checkEnabledAccessibility(acc, el, true);
utils.synthesizeMouseAtCenter(el, {}, el.ownerDocument.defaultView);
} else {
throw new InvalidElementStateError("Element is not Enabled");
@ -1568,8 +1527,7 @@ function getElementRect(id) {
function isElementEnabled(id) {
let el = elementManager.getKnownElement(id, curFrame);
let enabled = utils.isElementEnabled(el);
checkEnabledAccessibility(
accessibility.getAccessibleObject(el), el, enabled);
checkEnabledStateAccessibility(accessibility.getAccessibleObject(el), enabled);
return enabled;
}
@ -1580,9 +1538,7 @@ function isElementSelected(msg) {
let command_id = msg.json.command_id;
try {
let el = elementManager.getKnownElement(msg.json.id, curFrame);
let selected = utils.isElementSelected(el);
checkSelectedAccessibility(accessibility.getAccessibleObject(el), selected);
sendResponse({value: selected}, command_id);
sendResponse({value: utils.isElementSelected(el)}, command_id);
} catch (e) {
sendError(e, command_id);
}
@ -1595,24 +1551,17 @@ function sendKeysToElement(msg) {
let command_id = msg.json.command_id;
let val = msg.json.value;
try {
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") {
let p = val.join("");
fileInputElement = el;
// In e10s, we can only construct File objects in the parent process,
// so pass the filename to driver.js, which in turn passes them back
// to this frame script in receiveFiles.
sendSyncMessage("Marionette:getFiles",
{value: p, command_id: command_id});
} else {
utils.sendKeysToElement(curFrame, el, val, sendOk, sendError, command_id);
}
} catch (e) {
sendError(e, command_id);
let el = elementManager.getKnownElement(msg.json.id, curFrame);
if (el.type == "file") {
let p = val.join("");
fileInputElement = el;
// In e10s, we can only construct File objects in the parent process,
// so pass the filename to driver.js, which in turn passes them back
// to this frame script in receiveFiles.
sendSyncMessage("Marionette:getFiles",
{value: p, command_id: command_id});
} else {
utils.sendKeysToElement(curFrame, el, val, sendOk, sendError, command_id);
}
}