Bug 1324529 - Rename Marionette capability raisesAccessibilityExceptions to moz:accessibilityChecks; r?whimboo,yzen draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 19 Dec 2016 19:28:17 +0000
changeset 451159 90867943f90dc7fd4074a2f9c6f7cc3bb5b65ce9
parent 451111 d4b3146a5567a7ddbcdfa5244945db55616cb8d1
child 539941 c2c0faad171fb4efd3d0ff2a153fc0fa4a8fdeb5
push id39069
push userbmo:ato@mozilla.com
push dateMon, 19 Dec 2016 19:32:30 +0000
reviewerswhimboo, yzen
bugs1324529
milestone53.0a1
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
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
testing/marionette/listener.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -151,24 +151,24 @@ this.GeckoDriver = function (appName, se
     // mandated capabilities
     "browserName": Services.appinfo.name.toLowerCase(),
     "browserVersion": Services.appinfo.version,
     "platformName": Services.sysinfo.getProperty("name").toLowerCase(),
     "platformVersion": Services.sysinfo.getProperty("version"),
     "acceptInsecureCerts": !this.secureTLS,
 
     // supported features
-    "raisesAccessibilityExceptions": false,
     "rotatable": this.appName == "B2G",
     "proxy": {},
 
     // proprietary extensions
     "specificationLevel": 0,
     "moz:processID": Services.appinfo.processID,
     "moz:profile": Services.dirsvc.get("ProfD", Ci.nsIFile).path,
+    "moz:accessibilityChecks": false,
   };
 
   this.mm = globalMessageManager;
   this.listener = proxy.toListener(() => this.mm, this.sendAsync.bind(this));
 
   // always keep weak reference to current dialogue
   this.dialog = null;
   let handleDialog = (subject, topic) => {
@@ -178,16 +178,20 @@ this.GeckoDriver = function (appName, se
     }
     this.dialog = new modal.Dialog(() => this.curBrowser, winr);
   };
   modal.addHandler(handleDialog);
 
   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,
   Ci.nsISupportsWeakReference
 ]);
 
 /**
  * Switches to the global ChromeMessageBroadcaster, potentially replacing
@@ -514,18 +518,17 @@ GeckoDriver.prototype.newSession = funct
     logger.warn("TLS certificate errors will be ignored for this session");
     let acceptAllCerts = new cert.InsecureSweepingOverride();
     cert.installOverride(acceptAllCerts);
   }
 
   // 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");
   }
 
   let registerBrowsers = this.registerPromise();
   let browserListening = this.listeningPromise();
 
   let waitForWindow = function() {
     let win = this.getCurrentWindow();
@@ -1800,18 +1803,17 @@ GeckoDriver.prototype.getActiveElement =
  */
 GeckoDriver.prototype.clickElement = function*(cmd, resp) {
   let id = cmd.parameters.id;
 
   switch (this.context) {
     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:
       // We need to protect against the click causing an OOP frame to close.
       // This fires the mozbrowserclose event when it closes so we need to
       // listen for it and then just send an error back. The person making the
       // call should be aware something isnt right and handle accordingly
       this.addFrameCloseListener("click");
@@ -1931,17 +1933,17 @@ GeckoDriver.prototype.getElementTagName 
 GeckoDriver.prototype.isElementDisplayed = function*(cmd, resp) {
   let id = cmd.parameters.id;
 
   switch (this.context) {
     case Context.CHROME:
       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:
       resp.body.value = yield this.listener.isElementDisplayed(id);
       break;
   }
 };
 
@@ -1980,17 +1982,17 @@ GeckoDriver.prototype.isElementEnabled =
   let id = cmd.parameters.id;
 
   switch (this.context) {
     case Context.CHROME:
       // Selenium atom doesn't quite work here
       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:
       resp.body.value = yield this.listener.isElementEnabled(id);
       break;
   }
 },
 
@@ -2004,17 +2006,17 @@ GeckoDriver.prototype.isElementSelected 
   let id = cmd.parameters.id;
 
   switch (this.context) {
     case Context.CHROME:
       // Selenium atom doesn't quite work here
       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:
       resp.body.value = yield this.listener.isElementSelected(id);
       break;
   }
 };
 
@@ -2052,17 +2054,17 @@ GeckoDriver.prototype.sendKeysToElement 
   let {id, value} = cmd.parameters;
   assert.defined(value, `Expected character sequence: ${value}`);
 
   switch (this.context) {
     case Context.CHROME:
       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:
       yield this.listener.sendKeysToElement(id, value);
       break;
   }
 };
 
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
@@ -85,20 +85,19 @@ class TestAccessibility(MarionetteTestCa
     # 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(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")
             self.marionette.navigate(test_accessibility)
 
     def test_valid_single_tap(self):
         self.setup_accessibility()
         # No exception should be raised
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -43,16 +43,19 @@ class TestCapabilities(MarionetteTestCas
         self.assertEqual(self.caps["moz:processID"], self.appinfo["processID"])
         self.assertEqual(self.marionette.process_id, self.appinfo["processID"])
 
         current_profile = self.marionette.instance.runner.profile.profile
         self.assertIn("moz:profile", self.caps)
         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"}}
         self.marionette.start_session(capabilities)
         caps = self.marionette.session_capabilities
         self.assertIn("somethingAwesome", caps)
 
     def test_set_specification_level(self):
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -630,17 +630,17 @@ function emitTouchEvent(type, touch) {
 function singleTap(id, corx, cory) {
   let el = seenEls.get(id, curContainer);
   // after this block, the element will be scrolled into view
   let visible = element.isVisible(el, corx, cory);
   if (!visible) {
     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);
     if (!curContainer.frame.document.createTouch) {
       actions.mouseEventsOnly = true;
     }
     let c = element.coordinates(el, corx, cory);
     if (!actions.mouseEventsOnly) {
@@ -1153,17 +1153,17 @@ function getActiveElement() {
  *
  * @param {WebElement} id
  *     Reference to the web element to click.
  */
 function clickElement(id) {
   let el = seenEls.get(id, curContainer);
   return interaction.clickElement(
       el,
-      !!capabilities.raisesAccessibilityExceptions,
+      !!capabilities["moz:accessibilityChecks"],
       capabilities.specificationLevel >= 1);
 }
 
 function getElementAttribute(id, name) {
   let el = seenEls.get(id, curContainer);
   if (element.isBooleanAttribute(el, name)) {
     if (el.hasAttribute(name)) {
       return "true";
@@ -1212,17 +1212,17 @@ function getElementTagName(id) {
  * Determine the element displayedness of the given web element.
  *
  * Also performs additional accessibility checks if enabled by session
  * capability.
  */
 function isElementDisplayed(id) {
   let el = seenEls.get(id, curContainer);
   return interaction.isElementDisplayed(
-      el, capabilities.raisesAccessibilityExceptions);
+      el, capabilities["moz:accessibilityChecks"]);
 }
 
 /**
  * Retrieves the computed value of the given CSS property of the given
  * web element.
  *
  * @param {String} id
  *     Web element reference.
@@ -1265,39 +1265,39 @@ function getElementRect(id) {
  *     Reference to web element.
  *
  * @return {boolean}
  *     True if enabled, false otherwise.
  */
 function isElementEnabled(id) {
   let el = seenEls.get(id, curContainer);
   return interaction.isElementEnabled(
-      el, capabilities.raisesAccessibilityExceptions);
+      el, capabilities["moz:accessibilityChecks"]);
 }
 
 /**
  * Determines if the referenced element is selected or not.
  *
  * This operation only makes sense on input elements of the Checkbox-
  * and Radio Button states, or option elements.
  */
 function isElementSelected(id) {
   let el = seenEls.get(id, curContainer);
   return interaction.isElementSelected(
-      el, capabilities.raisesAccessibilityExceptions);
+      el, capabilities["moz:accessibilityChecks"]);
 }
 
 function* sendKeysToElement(id, val) {
   let el = seenEls.get(id, curContainer);
   if (el.type == "file") {
     let path = val.join("");
     yield interaction.uploadFile(el, path);
   } else {
     yield interaction.sendKeysToElement(
-        el, val, false, capabilities.raisesAccessibilityExceptions);
+        el, val, false, capabilities["moz:accessibilityChecks"]);
   }
 }
 
 /**
  * Clear the text of an element.
  */
 function clearElement(id) {
   try {