From 892dd1cb42c2829396e2c562fa85519172fd57ab Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Mon, 19 Dec 2016 19:28:17 +0000 Subject: [PATCH] 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 --- testing/marionette/driver.js | 20 ++++++++++--------- .../tests/unit/test_accessibility.py | 5 ++--- .../tests/unit/test_capabilities.py | 3 +++ testing/marionette/listener.js | 12 +++++------ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index fbad2dd05764..f754f266ec0d 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -156,7 +156,6 @@ this.GeckoDriver = function (appName, server) { "acceptInsecureCerts": !this.secureTLS, // supported features - "raisesAccessibilityExceptions": false, "rotatable": this.appName == "B2G", "proxy": {}, @@ -164,6 +163,7 @@ this.GeckoDriver = function (appName, server) { "specificationLevel": 0, "moz:processID": Services.appinfo.processID, "moz:profile": Services.dirsvc.get("ProfD", Ci.nsIFile).path, + "moz:accessibilityChecks": false, }; this.mm = globalMessageManager; @@ -183,6 +183,10 @@ this.GeckoDriver = function (appName, server) { this.actions = new action.Chain(); }; +Object.defineProperty(GeckoDriver.prototype, "a11yChecks", { + get: function () { return this.sessionCapabilities["moz:accessibilityChecks"]; } +}); + GeckoDriver.prototype.QueryInterface = XPCOMUtils.generateQI([ Ci.nsIMessageListener, Ci.nsIObserver, @@ -532,8 +536,7 @@ GeckoDriver.prototype.newSession = function*(cmd, resp) { // If we are testing accessibility with marionette, start a11y service in // chrome first. This will ensure that we do not have any content-only // services hanging around. - if (this.sessionCapabilities.raisesAccessibilityExceptions && - accessibility.service) { + if (this.a11yChecks && accessibility.service) { logger.info("Preemptively starting accessibility service in Chrome"); } @@ -1784,8 +1787,7 @@ GeckoDriver.prototype.clickElement = function*(cmd, resp) { case Context.CHROME: let win = this.getCurrentWindow(); let el = this.curBrowser.seenEls.get(id, {frame: win}); - yield interaction.clickElement( - el, this.sessionCapabilities.raisesAccessibilityExceptions); + yield interaction.clickElement(el, this.a11yChecks); break; case Context.CONTENT: @@ -1915,7 +1917,7 @@ GeckoDriver.prototype.isElementDisplayed = function*(cmd, resp) { let win = this.getCurrentWindow(); let el = this.curBrowser.seenEls.get(id, {frame: win}); resp.body.value = yield interaction.isElementDisplayed( - el, this.sessionCapabilities.raisesAccessibilityExceptions); + el, this.a11yChecks); break; case Context.CONTENT: @@ -1964,7 +1966,7 @@ GeckoDriver.prototype.isElementEnabled = function*(cmd, resp) { let win = this.getCurrentWindow(); let el = this.curBrowser.seenEls.get(id, {frame: win}); resp.body.value = yield interaction.isElementEnabled( - el, this.sessionCapabilities.raisesAccessibilityExceptions); + el, this.a11yChecks); break; case Context.CONTENT: @@ -1988,7 +1990,7 @@ GeckoDriver.prototype.isElementSelected = function*(cmd, resp) { let win = this.getCurrentWindow(); let el = this.curBrowser.seenEls.get(id, {frame: win}); resp.body.value = yield interaction.isElementSelected( - el, this.sessionCapabilities.raisesAccessibilityExceptions); + el, this.a11yChecks); break; case Context.CONTENT: @@ -2036,7 +2038,7 @@ GeckoDriver.prototype.sendKeysToElement = function*(cmd, resp) { let win = this.getCurrentWindow(); let el = this.curBrowser.seenEls.get(id, {frame: win}); yield interaction.sendKeysToElement( - el, value, true, this.sessionCapabilities.raisesAccessibilityExceptions); + el, value, true, this.a11yChecks); break; case Context.CONTENT: diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py b/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py index 22fd51ddaaed..03edb32486ce 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py @@ -90,10 +90,9 @@ class TestAccessibility(MarionetteTestCase): element = self.marionette.find_element(By.ID, id) 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.start_session( - {"raisesAccessibilityExceptions": raisesAccessibilityExceptions}) + self.marionette.start_session({"moz:accessibilityChecks": enable_a11y_checks}) # Navigate to test_accessibility.html if navigate: test_accessibility = self.marionette.absolute_url("test_accessibility.html") diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py index a7d0e3951d2d..8cbc0e319ecf 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py @@ -48,6 +48,9 @@ class TestCapabilities(MarionetteTestCase): self.assertEqual(self.caps["moz: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): self.marionette.delete_session() capabilities = {"desiredCapabilities": {"somethingAwesome": "cake"}} diff --git a/testing/marionette/listener.js b/testing/marionette/listener.js index 4cf2b629f5b7..df0f13961939 100644 --- a/testing/marionette/listener.js +++ b/testing/marionette/listener.js @@ -634,7 +634,7 @@ function singleTap(id, corx, cory) { 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 => { a11y.assertVisible(acc, el, visible); a11y.assertActionable(acc, el); @@ -1157,7 +1157,7 @@ function clickElement(id) { let el = seenEls.get(id, curContainer); return interaction.clickElement( el, - !!capabilities.raisesAccessibilityExceptions, + !!capabilities["moz:accessibilityChecks"], capabilities.specificationLevel >= 1); } @@ -1216,7 +1216,7 @@ function getElementTagName(id) { function isElementDisplayed(id) { let el = seenEls.get(id, curContainer); return interaction.isElementDisplayed( - el, capabilities.raisesAccessibilityExceptions); + el, capabilities["moz:accessibilityChecks"]); } /** @@ -1269,7 +1269,7 @@ function getElementRect(id) { function isElementEnabled(id) { let el = seenEls.get(id, curContainer); return interaction.isElementEnabled( - el, capabilities.raisesAccessibilityExceptions); + el, capabilities["moz:accessibilityChecks"]); } /** @@ -1281,7 +1281,7 @@ function isElementEnabled(id) { function isElementSelected(id) { let el = seenEls.get(id, curContainer); return interaction.isElementSelected( - el, capabilities.raisesAccessibilityExceptions); + el, capabilities["moz:accessibilityChecks"]); } function* sendKeysToElement(id, val) { @@ -1291,7 +1291,7 @@ function* sendKeysToElement(id, val) { yield interaction.uploadFile(el, path); } else { yield interaction.sendKeysToElement( - el, val, false, capabilities.raisesAccessibilityExceptions); + el, val, false, capabilities["moz:accessibilityChecks"]); } }