Bug 1324529 - Rename Marionette capability raisesAccessibilityExceptions to moz:accessibilityChecks; r=whimboo,yzen

This change renames the `raisesAccessibilityExceptions` capability to
`moz:accessibilityChecks` to conform with the format of extension
capabilities as defined in the WebDriver specification.

As this feature is not tested or used in the Firefox upgrade tests and
has limited deployment outside Mozilla, it is considered safe for this
to be a breaking change.

MozReview-Commit-ID: DRA16cWJDX0

--HG--
extra : rebase_source : 42fac27f655ce431ae68bbaeeec6a208d91e9033
This commit is contained in:
Andreas Tolfsen 2016-12-19 19:28:17 +00:00
Родитель 22418ad00d
Коммит 892dd1cb42
4 изменённых файлов: 22 добавлений и 18 удалений

Просмотреть файл

@ -156,7 +156,6 @@ this.GeckoDriver = function (appName, server) {
"acceptInsecureCerts": !this.secureTLS, "acceptInsecureCerts": !this.secureTLS,
// supported features // supported features
"raisesAccessibilityExceptions": false,
"rotatable": this.appName == "B2G", "rotatable": this.appName == "B2G",
"proxy": {}, "proxy": {},
@ -164,6 +163,7 @@ this.GeckoDriver = function (appName, server) {
"specificationLevel": 0, "specificationLevel": 0,
"moz:processID": Services.appinfo.processID, "moz:processID": Services.appinfo.processID,
"moz:profile": Services.dirsvc.get("ProfD", Ci.nsIFile).path, "moz:profile": Services.dirsvc.get("ProfD", Ci.nsIFile).path,
"moz:accessibilityChecks": false,
}; };
this.mm = globalMessageManager; this.mm = globalMessageManager;
@ -183,6 +183,10 @@ this.GeckoDriver = function (appName, server) {
this.actions = new action.Chain(); this.actions = new action.Chain();
}; };
Object.defineProperty(GeckoDriver.prototype, "a11yChecks", {
get: function () { return this.sessionCapabilities["moz:accessibilityChecks"]; }
});
GeckoDriver.prototype.QueryInterface = XPCOMUtils.generateQI([ GeckoDriver.prototype.QueryInterface = XPCOMUtils.generateQI([
Ci.nsIMessageListener, Ci.nsIMessageListener,
Ci.nsIObserver, Ci.nsIObserver,
@ -532,8 +536,7 @@ GeckoDriver.prototype.newSession = function*(cmd, resp) {
// If we are testing accessibility with marionette, start a11y service in // If we are testing accessibility with marionette, start a11y service in
// chrome first. This will ensure that we do not have any content-only // chrome first. This will ensure that we do not have any content-only
// services hanging around. // services hanging around.
if (this.sessionCapabilities.raisesAccessibilityExceptions && if (this.a11yChecks && accessibility.service) {
accessibility.service) {
logger.info("Preemptively starting accessibility service in Chrome"); logger.info("Preemptively starting accessibility service in Chrome");
} }
@ -1784,8 +1787,7 @@ GeckoDriver.prototype.clickElement = function*(cmd, resp) {
case Context.CHROME: case Context.CHROME:
let win = this.getCurrentWindow(); let win = this.getCurrentWindow();
let el = this.curBrowser.seenEls.get(id, {frame: win}); let el = this.curBrowser.seenEls.get(id, {frame: win});
yield interaction.clickElement( yield interaction.clickElement(el, this.a11yChecks);
el, this.sessionCapabilities.raisesAccessibilityExceptions);
break; break;
case Context.CONTENT: case Context.CONTENT:
@ -1915,7 +1917,7 @@ GeckoDriver.prototype.isElementDisplayed = function*(cmd, resp) {
let win = this.getCurrentWindow(); let win = this.getCurrentWindow();
let el = this.curBrowser.seenEls.get(id, {frame: win}); let el = this.curBrowser.seenEls.get(id, {frame: win});
resp.body.value = yield interaction.isElementDisplayed( resp.body.value = yield interaction.isElementDisplayed(
el, this.sessionCapabilities.raisesAccessibilityExceptions); el, this.a11yChecks);
break; break;
case Context.CONTENT: case Context.CONTENT:
@ -1964,7 +1966,7 @@ GeckoDriver.prototype.isElementEnabled = function*(cmd, resp) {
let win = this.getCurrentWindow(); let win = this.getCurrentWindow();
let el = this.curBrowser.seenEls.get(id, {frame: win}); let el = this.curBrowser.seenEls.get(id, {frame: win});
resp.body.value = yield interaction.isElementEnabled( resp.body.value = yield interaction.isElementEnabled(
el, this.sessionCapabilities.raisesAccessibilityExceptions); el, this.a11yChecks);
break; break;
case Context.CONTENT: case Context.CONTENT:
@ -1988,7 +1990,7 @@ GeckoDriver.prototype.isElementSelected = function*(cmd, resp) {
let win = this.getCurrentWindow(); let win = this.getCurrentWindow();
let el = this.curBrowser.seenEls.get(id, {frame: win}); let el = this.curBrowser.seenEls.get(id, {frame: win});
resp.body.value = yield interaction.isElementSelected( resp.body.value = yield interaction.isElementSelected(
el, this.sessionCapabilities.raisesAccessibilityExceptions); el, this.a11yChecks);
break; break;
case Context.CONTENT: case Context.CONTENT:
@ -2036,7 +2038,7 @@ GeckoDriver.prototype.sendKeysToElement = function*(cmd, resp) {
let win = this.getCurrentWindow(); let win = this.getCurrentWindow();
let el = this.curBrowser.seenEls.get(id, {frame: win}); let el = this.curBrowser.seenEls.get(id, {frame: win});
yield interaction.sendKeysToElement( yield interaction.sendKeysToElement(
el, value, true, this.sessionCapabilities.raisesAccessibilityExceptions); el, value, true, this.a11yChecks);
break; break;
case Context.CONTENT: case Context.CONTENT:

Просмотреть файл

@ -90,10 +90,9 @@ class TestAccessibility(MarionetteTestCase):
element = self.marionette.find_element(By.ID, id) element = self.marionette.find_element(By.ID, id)
testFn(element) testFn(element)
def setup_accessibility(self, raisesAccessibilityExceptions=True, navigate=True): def setup_accessibility(self, enable_a11y_checks=True, navigate=True):
self.marionette.delete_session() self.marionette.delete_session()
self.marionette.start_session( self.marionette.start_session({"moz:accessibilityChecks": enable_a11y_checks})
{"raisesAccessibilityExceptions": raisesAccessibilityExceptions})
# Navigate to test_accessibility.html # Navigate to test_accessibility.html
if navigate: if navigate:
test_accessibility = self.marionette.absolute_url("test_accessibility.html") test_accessibility = self.marionette.absolute_url("test_accessibility.html")

Просмотреть файл

@ -48,6 +48,9 @@ class TestCapabilities(MarionetteTestCase):
self.assertEqual(self.caps["moz:profile"], current_profile) self.assertEqual(self.caps["moz:profile"], current_profile)
self.assertEqual(self.marionette.profile, current_profile) self.assertEqual(self.marionette.profile, current_profile)
self.assertIn("moz:accessibilityChecks", self.caps)
self.assertFalse(self.caps["moz:accessibilityChecks"])
def test_we_can_pass_in_capabilities_on_session_start(self): def test_we_can_pass_in_capabilities_on_session_start(self):
self.marionette.delete_session() self.marionette.delete_session()
capabilities = {"desiredCapabilities": {"somethingAwesome": "cake"}} capabilities = {"desiredCapabilities": {"somethingAwesome": "cake"}}

Просмотреть файл

@ -634,7 +634,7 @@ function singleTap(id, corx, cory) {
throw new ElementNotVisibleError("Element is not currently visible and may not be manipulated"); throw new ElementNotVisibleError("Element is not currently visible and may not be manipulated");
} }
let a11y = accessibility.get(capabilities.raisesAccessibilityExceptions); let a11y = accessibility.get(capabilities["moz:accessibilityChecks"]);
return a11y.getAccessible(el, true).then(acc => { return a11y.getAccessible(el, true).then(acc => {
a11y.assertVisible(acc, el, visible); a11y.assertVisible(acc, el, visible);
a11y.assertActionable(acc, el); a11y.assertActionable(acc, el);
@ -1157,7 +1157,7 @@ function clickElement(id) {
let el = seenEls.get(id, curContainer); let el = seenEls.get(id, curContainer);
return interaction.clickElement( return interaction.clickElement(
el, el,
!!capabilities.raisesAccessibilityExceptions, !!capabilities["moz:accessibilityChecks"],
capabilities.specificationLevel >= 1); capabilities.specificationLevel >= 1);
} }
@ -1216,7 +1216,7 @@ function getElementTagName(id) {
function isElementDisplayed(id) { function isElementDisplayed(id) {
let el = seenEls.get(id, curContainer); let el = seenEls.get(id, curContainer);
return interaction.isElementDisplayed( return interaction.isElementDisplayed(
el, capabilities.raisesAccessibilityExceptions); el, capabilities["moz:accessibilityChecks"]);
} }
/** /**
@ -1269,7 +1269,7 @@ function getElementRect(id) {
function isElementEnabled(id) { function isElementEnabled(id) {
let el = seenEls.get(id, curContainer); let el = seenEls.get(id, curContainer);
return interaction.isElementEnabled( return interaction.isElementEnabled(
el, capabilities.raisesAccessibilityExceptions); el, capabilities["moz:accessibilityChecks"]);
} }
/** /**
@ -1281,7 +1281,7 @@ function isElementEnabled(id) {
function isElementSelected(id) { function isElementSelected(id) {
let el = seenEls.get(id, curContainer); let el = seenEls.get(id, curContainer);
return interaction.isElementSelected( return interaction.isElementSelected(
el, capabilities.raisesAccessibilityExceptions); el, capabilities["moz:accessibilityChecks"]);
} }
function* sendKeysToElement(id, val) { function* sendKeysToElement(id, val) {
@ -1291,7 +1291,7 @@ function* sendKeysToElement(id, val) {
yield interaction.uploadFile(el, path); yield interaction.uploadFile(el, path);
} else { } else {
yield interaction.sendKeysToElement( yield interaction.sendKeysToElement(
el, val, false, capabilities.raisesAccessibilityExceptions); el, val, false, capabilities["moz:accessibilityChecks"]);
} }
} }