Bug 786163 - sort out name calculation for HTML input buttons, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Sun, 03 Feb 2013 13:49:18 +0900
changeset 120687 6472bf8f484b82320ff4a3338a81b8460492d222
parent 120686 f9f36de41b0e8bdb95662f5bfc4ba3d582903580
child 120688 b10cbe334217969b0fbd5b9fdf4e7a67d0808c32
push id22362
push usersurkov.alexander@gmail.com
push dateSun, 03 Feb 2013 04:47:10 +0000
treeherdermozilla-inbound@6472bf8f484b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs786163
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 786163 - sort out name calculation for HTML input buttons, r=tbsaunde
accessible/src/html/HTMLFormControlAccessible.cpp
accessible/tests/mochitest/events.js
accessible/tests/mochitest/name/Makefile.in
accessible/tests/mochitest/name/markup.js
accessible/tests/mochitest/name/markuprules.xml
accessible/tests/mochitest/name/test_button.html
accessible/tests/mochitest/name/test_general.html
accessible/tests/mochitest/name/test_markup.html
--- a/accessible/src/html/HTMLFormControlAccessible.cpp
+++ b/accessible/src/html/HTMLFormControlAccessible.cpp
@@ -254,36 +254,33 @@ role
 HTMLButtonAccessible::NativeRole()
 {
   return roles::PUSHBUTTON;
 }
 
 ENameValueFlag
 HTMLButtonAccessible::NativeName(nsString& aName)
 {
+  // No need to check @value attribute for buttons since this attribute results
+  // in native anonymous text node and the name is calculated from subtree.
+  // The same magic works for @alt and @value attributes in case of type="image"
+  // element that has no valid @src (note if input@type="image" has an image
+  // then neither @alt nor @value attributes are used to generate a visual label
+  // and thus we need to obtain the accessible name directly from attribute
+  // value). Also the same algorithm works in case of default labels for
+  // type="submit"/"reset"/"image" elements.
+
   ENameValueFlag nameFlag = Accessible::NativeName(aName);
-  if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input)
+  if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input ||
+      !mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
+                             nsGkAtoms::image, eCaseMatters))
     return nameFlag;
 
-  // Note: No need to check @value attribute since it results in anonymous text
-  // node. The name is calculated from subtree in this case.
-  if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName)) {
-    // Use the button's (default) label if nothing else works
-    nsIFrame* frame = GetFrame();
-    if (frame) {
-      nsIFormControlFrame* fcFrame = do_QueryFrame(frame);
-      if (fcFrame)
-        fcFrame->GetFormProperty(nsGkAtoms::defaultLabel, aName);
-    }
-  }
-
-  if (aName.IsEmpty() &&
-      !mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, aName)) {
-    mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, aName);
-  }
+  if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
+    mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
 
   aName.CompressWhitespace();
   return eNameOK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLButtonAccessible: Widgets
 
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -63,28 +63,32 @@ var gA11yEventDumpFeature = "";
  * @param aEventType  [in] event type
  * @param aTarget     [in] event target
  * @param aFunc       [in] function to call when event is handled
  * @param aContext    [in, optional] object in which context the function is
  *                    called
  * @param aArg1       [in, optional] argument passed into the function
  * @param aArg2       [in, optional] argument passed into the function
  */
-function waitForEvent(aEventType, aTarget, aFunc, aContext, aArg1, aArg2)
+function waitForEvent(aEventType, aTargetOrFunc, aFunc, aContext, aArg1, aArg2)
 {
   var handler = {
     handleEvent: function handleEvent(aEvent) {
 
-      if (aTarget) {
-        if (aTarget instanceof nsIAccessible &&
-            aTarget != aEvent.accessible)
+      var target = aTargetOrFunc;
+      if (typeof aTargetOrFunc == "function")
+        target = aTargetOrFunc.call();
+
+      if (target) {
+        if (target instanceof nsIAccessible &&
+            target != aEvent.accessible)
           return;
 
-        if (aTarget instanceof nsIDOMNode &&
-            aTarget != aEvent.DOMNode)
+        if (target instanceof nsIDOMNode &&
+            target != aEvent.DOMNode)
           return;
       }
 
       unregisterA11yEventListener(aEventType, this);
 
       window.setTimeout(
         function ()
         {
--- a/accessible/tests/mochitest/name/Makefile.in
+++ b/accessible/tests/mochitest/name/Makefile.in
@@ -10,17 +10,16 @@ VPATH		= @srcdir@
 relativesrcdir  = accessible/name
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_A11Y_FILES =\
 		general.css \
 		general.xbl \
 		markup.js \
-		test_button.html \
 		test_general.html \
 		test_general.xul \
 		test_link.html \
 		test_list.html \
 		test_markup.html \
 		test_svg.html \
 		test_browserui.xul \
 		test_tree.xul \
--- a/accessible/tests/mochitest/name/markup.js
+++ b/accessible/tests/mochitest/name/markup.js
@@ -36,37 +36,44 @@ var gTestIterator =
 {
   iterateMarkups: function gTestIterator_iterateMarkups(aMarkupElms)
   {
     this.markupElms = aMarkupElms;
 
     this.iterateNext();
   },
 
-  iterateRules: function gTestIterator_iterateRules(aElm, aContainer, aRuleElms)
+  iterateRules: function gTestIterator_iterateRules(aElm, aContainer,
+                                                    aRuleSetElm, aRuleElms,
+                                                    aTestID)
   {
+    this.ruleSetElm = aRuleSetElm;
     this.ruleElms = aRuleElms;
     this.elm = aElm;
     this.container = aContainer;
+    this.testID = aTestID;
 
     this.iterateNext();
   },
 
   iterateNext: function gTestIterator_iterateNext()
   {
     if (this.markupIdx == -1) {
       this.markupIdx++;
       testNamesForMarkup(this.markupElms[this.markupIdx]);
       return;
     }
 
     this.ruleIdx++;
     if (this.ruleIdx == this.ruleElms.length) {
       // When test is finished then name is empty and no explict-name.
-      testName(this.elm, null, "No name test. ");
+      var defaultName = this.ruleSetElm.hasAttribute("defaultName") ?
+        this.ruleSetElm.getAttribute("defaultName") : null;
+      testName(this.elm, defaultName,
+               "Default name test (" + gTestIterator.testID + "). ");
       testAbsentAttrs(this.elm, {"explicit-name" : "true"});
 
       this.markupIdx++;
       if (this.markupIdx == this.markupElms.length) {
         //disableLogging("tree"); // debugging
         SimpleTest.finish();
         return;
       }
@@ -84,20 +91,22 @@ var gTestIterator =
       return;
     }
 
     testNameForRule(this.elm, this.ruleElms[this.ruleIdx]);
   },
 
   markupElms: null,
   markupIdx: -1,
+  rulesetElm: null,
   ruleElms: null,
   ruleIdx: -1,
   elm: null,
-  container: null
+  container: null,
+  testID: ""
 };
 
 /**
  * Process every 'markup' element and test names for it. Used by testNames
  * function.
  */
 function testNamesForMarkup(aMarkupElm)
 {
@@ -121,33 +130,37 @@ function testNamesForMarkup(aMarkupElm)
   waitForEvent(EVENT_REORDER, document, testNamesForMarkupRules,
                 null, aMarkupElm, div);
 
   document.body.appendChild(div);
 }
 
 function testNamesForMarkupRules(aMarkupElm, aContainer)
 {
+  var testID = aMarkupElm.getAttribute("id");
   if (gDumpToConsole)
-    dump("\nProcessing markup rules '" + aMarkupElm.getAttribute("id") + "'\n");
+    dump("\nProcessing markup rules '" + testID + "'\n");
 
   var serializer = new XMLSerializer();
 
   var expr = "//html/body/div[@id='test']/" + aMarkupElm.getAttribute("ref");
   var elm = evaluateXPath(document, expr, htmlDocResolver)[0];
 
   var ruleId = aMarkupElm.getAttribute("ruleset");
+  var ruleElm = gRuleDoc.querySelector("[id='" + ruleId + "']");
   var ruleElms = getRuleElmsByRulesetId(ruleId);
 
   var processMarkupRules =
-    gTestIterator.iterateRules.bind(gTestIterator, elm, aContainer, ruleElms);
+    gTestIterator.iterateRules.bind(gTestIterator, elm, aContainer,
+                                    ruleElm, ruleElms, testID);
 
   // Images may be recreated after we append them into subtree. We need to wait
   // in this case. If we are on profiling enabled build then stack tracing
-  // works and thus let's log instead.
+  // works and thus let's log instead. Note, that works if you enabled logging
+  // (refer to testNames() function).
   if (isAccessible(elm) || isLogged("stack"))
     processMarkupRules();
   else
     waitForEvent(EVENT_SHOW, elm, processMarkupRules);
 }
 
 /**
  * Test name for current rule and current 'markup' element. Used by
@@ -193,30 +206,50 @@ function testNameForAttrRule(aElm, aRule
 
   } else if (type == "ref" && attrValue) {
     var ids = attrValue.split(/\s+/);
     for (var idx = 0; idx < ids.length; idx++) {
       var labelElm = getNode(ids[idx]);
       if (name != "")
         name += " ";
 
-      name += labelElm.getAttribute("a11yname");
+      name += labelElm.getAttribute("textequiv");
     }
   }
 
-  var msg = "Attribute '" + attr + "' test. ";
+  var msg = "Attribute '" + attr + "' test (" + gTestIterator.testID + "). ";
   testName(aElm, name, msg);
+
   if (aRule.getAttribute("explict-name") != "false")
     testAttrs(aElm, {"explicit-name" : "true"}, true);
   else
     testAbsentAttrs(aElm, {"explicit-name" : "true"});
 
-  aElm.removeAttribute(attr);
+  // If @recreated attribute is used then this attribute change recreates an
+  // accessible. Wait for reorder event in this case or otherwise proceed next
+  // test immediately.
+  if (aRule.hasAttribute("recreated")) {
+    waitForEvent(EVENT_REORDER, aElm.parentNode,
+                 gTestIterator.iterateNext, gTestIterator);
+    aElm.removeAttribute(attr);
 
-  gTestIterator.iterateNext();
+  } else if (aRule.hasAttribute("textchanged")) {
+    waitForEvent(EVENT_TEXT_INSERTED, aElm,
+                 gTestIterator.iterateNext, gTestIterator);
+    aElm.removeAttribute(attr);
+
+  } else if (aRule.hasAttribute("contentchanged")) {
+    waitForEvent(EVENT_REORDER, aElm,
+                 gTestIterator.iterateNext, gTestIterator);
+    aElm.removeAttribute(attr);
+
+  } else {
+    aElm.removeAttribute(attr);
+    gTestIterator.iterateNext();
+  }
 }
 
 function testNameForElmRule(aElm, aRule)
 {
   var labelElm;
 
   var tagname = aRule.getAttribute("elm");
   var attrname = aRule.getAttribute("elmattr");
@@ -249,36 +282,36 @@ function testNameForElmRule(aElm, aRule)
   }
 
   if (!labelElm) {
     ok(false, msg + " Failed to find '" + tagname + "' element.");
     gTestIterator.iterateNext();
     return;
   }
 
-  var msg = "Element '" + tagname + "' test.";
-  testName(aElm, labelElm.getAttribute("a11yname"), msg);
+  var msg = "Element '" + tagname + "' test (" + gTestIterator.testID + ").";
+  testName(aElm, labelElm.getAttribute("textequiv"), msg);
   testAttrs(aElm, {"explicit-name" : "true"}, true);
 
   var parentNode = labelElm.parentNode;
 
   if (gDumpToConsole) {
     dump("\nProcessed elm rule. Wait for reorder event on " +
          prettyName(parentNode) + "\n");
   }
   waitForEvent(EVENT_REORDER, parentNode,
                gTestIterator.iterateNext, gTestIterator);
 
   parentNode.removeChild(labelElm);
 }
 
 function testNameForSubtreeRule(aElm, aRule)
 {
-  var msg = "From subtree test.";
-  testName(aElm, aElm.getAttribute("a11yname"), msg);
+  var msg = "From subtree test (" + gTestIterator.testID + ").";
+  testName(aElm, aElm.getAttribute("textequiv"), msg);
   testAbsentAttrs(aElm, {"explicit-name" : "true"});
 
   if (gDumpToConsole) {
     dump("\nProcessed from subtree rule. Wait for reorder event on " +
          prettyName(aElm) + "\n");
   }
   waitForEvent(EVENT_REORDER, aElm, gTestIterator.iterateNext, gTestIterator);
 
--- a/accessible/tests/mochitest/name/markuprules.xml
+++ b/accessible/tests/mochitest/name/markuprules.xml
@@ -58,238 +58,311 @@
   <ruledfn>
     <ruleset id="aria">
       <rule attr="aria-label" type="string"/>
       <rule attr="aria-labelledby" type="ref"/>
     </ruleset>
   </ruledfn>
   <rulesample>
     <markup ref="html:div" ruleset="aria">
-      <html:span id="label" a11yname="test2">test2</html:span>
+      <html:span id="label" textequiv="test2">test2</html:span>
       <html:div aria-label="test1"
                 aria-labelledby="label">it's a div</html:div>
     </markup>
   </rulesample>
 
   Initially 'markup' element holds markup for all rules specified by 'ruleset'
   attribute. This allows us to check if the sequence of name computation rules
   is correct. Here 'ruleset' element defines two rules. We get the first rule
   which means accesible name is computed from value of 'aria-label' attribute.
   Then we check accessible name for the test element and remove 'aria-label'
   attribute. After we get the second rule which means we should get IDs from
   'aria-labelledby' attribute and compose accessible name from values of
-  'a11yname' attributes (that are supposed to give the desired name for each
+  'textequiv' attributes (that are supposed to give the desired name for each
   element that is being pointed to by aria-labelledby). Check accessible name
   and finish test.
 -->
 
 <rules xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <ruledfn>
 
     <!-- bricks -->
-    <ruleset id="aria">
+    <ruleset id="ARIA">
       <rule attr="aria-labelledby" type="ref"/>
       <rule attr="aria-label" type="string"/>
     </ruleset>
 
-    <ruleset id="htmlctrl_start">
-      <ruleset ref="aria"/>
+    <ruleset id="HTMLElm:Head">
+      <ruleset ref="ARIA"/>
       <rule elm="label" elmattr="for"/>
-      <rule fromsubtree="true"/>
-    </ruleset>
-
-    <ruleset id="htmlctrl_end">
-      <rule attr="title" type="string"/>
-    </ruleset>
-
-    <ruleset id="htmlelm_start">
-      <ruleset ref="aria"/>
-      <rule elm="label" elmattr="for"/>
-    </ruleset>
-
-    <ruleset id="htmlelm_end">
-      <rule attr="title" type="string"/>
     </ruleset>
 
     <!-- general -->
-    <ruleset id="htmlctrl">
-      <ruleset ref="htmlctrl_start"/>
-      <ruleset ref="htmlctrl_end"/>
+    <ruleset id="HTMLControl">
+      <ruleset ref="ARIA"/>
+      <rule elm="label" elmattr="for"/>
+      <rule fromsubtree="true"/>
+      <rule attr="title" type="string"/>
     </ruleset>
 
-    <ruleset id="htmlelm">
-      <ruleset ref="htmlelm_start"/>
-      <ruleset ref="htmlelm_end"/>
+    <ruleset id="HTMLElm">
+      <ruleset ref="HTMLElm:Head"/>
+      <rule attr="title" type="string"/>
     </ruleset>
 
     <!-- specific -->
-    <ruleset id="htmlinputbutton">
-      <ruleset ref="htmlelm_start"/>
-      <rule attr="value" type="string" explict-name="false"/>
-      <rule attr="alt" type="string"/>
-      <rule attr="src" type="string"/>
-      <rule attr="data" type="string"/>
-      <ruleset ref="htmlelm_end"/>
+    <ruleset id="HTMLInputButton">
+      <ruleset ref="HTMLElm:Head"/>
+      <rule attr="value" type="string" explict-name="false" reordered="true"/>
+      <rule attr="title" type="string"/>
+    </ruleset>
+
+    <ruleset id="HTMLInputSubmit" defaultName="Submit Query">
+      <ruleset ref="HTMLElm:Head"/>
+      <rule attr="value" type="string" explict-name="false" textchanged="true"/>
+    </ruleset>
+
+    <ruleset id="HTMLInputReset" defaultName="Reset">
+      <ruleset ref="HTMLElm:Head"/>
+      <rule attr="value" type="string" explict-name="false" textchanged="true"/>
     </ruleset>
 
-    <ruleset id="htmloption">
-      <ruleset ref="aria"/>
+    <ruleset id="HTMLInputImage">
+      <ruleset ref="HTMLElm:Head"/>
+      <rule attr="alt" type="string" recreated="true"/>
+      <rule attr="value" type="string" recreated="true"/>
+      <rule attr="title" type="string"/>
+    </ruleset>
+
+    <ruleset id="HTMLInputImageNoValidSrc" defaultName="Submit Query">
+      <ruleset ref="HTMLElm:Head"/>
+      <rule attr="alt" type="string" explict-name="false" recreated="true"/>
+      <rule attr="value" type="string" explict-name="false" recreated="true"/>
+    </ruleset>
+
+    <ruleset id="HTMLOption">
+      <ruleset ref="ARIA"/>
       <rule attr="label" type="string"/>
       <rule fromsubtree="true"/>
       <rule attr="title" type="string"/>
     </ruleset>
 
-    <ruleset id="htmlimage">
-      <ruleset ref="aria"/>
+    <ruleset id="HTMLImg">
+      <ruleset ref="ARIA"/>
       <rule attr="alt" type="string"/>
-      <ruleset ref="htmlelm_end"/>
+      <rule attr="title" type="string"/>
     </ruleset>
 
-    <ruleset id="htmlimageemptyalt">
-      <ruleset ref="aria"/>
-      <ruleset ref="htmlelm_end"/>
+    <ruleset id="HTMLImgEmptyAlt">
+      <ruleset ref="ARIA"/>
+      <rule attr="title" type="string"/>
       <rule attr="alt" type="string"/>
     </ruleset>
 
-    <ruleset id="htmltable">
-      <ruleset ref="htmlelm_start"/>
+    <ruleset id="HTMLTable">
+      <ruleset ref="HTMLElm:Head"/>
       <rule elm="caption"/>
       <rule attr="summary" type="string"/>
-      <ruleset ref="htmlelm_end"/>
+      <rule attr="title" type="string"/>
     </ruleset>
   </ruledfn>
 
   <rulesample>
 
-    <markup ref="html:button" ruleset="htmlctrl" id="markup1test">
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
-      <html:label for="btn" a11yname="test4">test4</html:label>
+    <markup id="HTMLButtonTest"
+            ref="html:button" ruleset="HTMLControl">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="btn" textequiv="test4">test4</html:label>
       <html:button id="btn"
                    aria-label="test1"
                    aria-labelledby="l1 l2"
                    title="test5"
-                   a11yname="press me">press me</html:button>
+                   textequiv="press me">press me</html:button>
     </markup>
 
-    <markup ref="html:input" ruleset="htmlinputbutton" id="markup2test">
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
-      <html:label for="btn" a11yname="test4">test4</html:label>
+    <markup id="HTMLInputButtonTest"
+            ref="html:input" ruleset="HTMLInputButton">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="btn" textequiv="test4">test4</html:label>
       <html:input id="btn"
                   type="button"
                   aria-label="test1"
                   aria-labelledby="l1 l2"
-                  value="test5"
-                  alt="test6"
-                  src="test7"
-                  data="test8"
-                  title="test9"/>
+                  value="name from value"
+                  alt="no name from al"
+                  src="no name from src"
+                  data="no name from data"
+                  title="name from title"/>
+    </markup>
+
+    <markup id="HTMLInputSubmitTest"
+            ref="html:input" ruleset="HTMLInputSubmit">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="btn-submit" textequiv="test4">test4</html:label>
+      <html:input id="btn-submit"
+                  type="submit"
+                  aria-label="test1"
+                  aria-labelledby="l1 l2"
+                  value="name from value"
+                  alt="no name from atl"
+                  src="no name from src"
+                  data="no name from data"
+                  title="no name from title"/>
     </markup>
 
-    <markup ref="html:select/html:option[1]" ruleset="htmloption"
-            id="markup3test">
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
+    <markup id="HTMLInputResetTest"
+            ref="html:input" ruleset="HTMLInputReset">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="btn-reset" textequiv="test4">test4</html:label>
+      <html:input id="btn-reset"
+                  type="reset"
+                  aria-label="test1"
+                  aria-labelledby="l1 l2"
+                  value="name from value"
+                  alt="no name from alt"
+                  src="no name from src"
+                  data="no name from data"
+                  title="no name from title"/>
+    </markup>
+
+    <markup id="HTMLInputImageTest"
+            ref="html:input" ruleset="HTMLInputImage">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="btn-image" textequiv="test4">test4</html:label>
+      <html:input id="btn-image"
+                  type="image"
+                  aria-label="test1"
+                  aria-labelledby="l1 l2"
+                  alt="name from alt"
+                  value="name from value"
+                  src="../moz.png"
+                  data="no name from data"
+                  title="name from title"/>
+    </markup>
+
+    <markup id="HTMLInputImageNoValidSrcTest"
+            ref="html:input" ruleset="HTMLInputImageNoValidSrc">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="btn-image" textequiv="test4">test4</html:label>
+      <html:input id="btn-image"
+                  type="image"
+                  aria-label="test1"
+                  aria-labelledby="l1 l2"
+                  alt="name from alt"
+                  value="name from value"
+                  data="no name from data"
+                  title="no name from title"/>
+    </markup>
+
+    <markup id="HTMLOptionTest"
+            ref="html:select/html:option[1]" ruleset="HTMLOption">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
       <html:select>
         <html:option id="opt"
                      aria-label="test1"
                      aria-labelledby="l1 l2"
                      label="test4"
                      title="test5"
-                     a11yname="option1">option1</html:option>
+                     textequiv="option1">option1</html:option>
         <html:option>option2</html:option>
       </html:select>
     </markup>
 
-    <markup ref="html:img" ruleset="htmlimage"
-            id="markupHTMLImageTest">
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
+    <markup id="HTMLImageTest"
+            ref="html:img" ruleset="HTMLImg">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
       <html:img id="img"
                 aria-label="Logo of Mozilla"
                 aria-labelledby="l1 l2"
                 alt="Mozilla logo"
                 title="This is a logo"
                 src="../moz.png"/>
     </markup>
 
-    <markup ref="html:img" ruleset="htmlimageemptyalt">
-            id="markupHTMLImageEmptyAltTest"
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
+    <markup id="HTMLImageEmptyAltTest"
+            ref="html:img" ruleset="HTMLImgEmptyAlt">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
       <html:img id="imgemptyalt"
                  aria-label="Logo of Mozilla"
                  aria-labelledby="l1 l2"
                  title="This is a logo"
                  alt=""
                  src="../moz.png"/>
     </markup>
 
-    <markup ref="html:table/html:tr/html:td" ruleset="htmlelm"
-            id="markup4test">
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
-      <html:label for="tc" a11yname="test4">test4</html:label>
+    <markup id="HTMLTdTest"
+            ref="html:table/html:tr/html:td" ruleset="HTMLElm">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="tc" textequiv="test4">test4</html:label>
       <html:table>
         <html:tr>
           <html:td id="tc"
                    aria-label="test1"
                    aria-labelledby="l1 l2"
                    title="test5">
             <html:p>This is a paragraph</html:p>
             <html:a href="#">This is a link</html:a>
             <html:ul>
               <html:li>This is a list</html:li>
             </html:ul>
           </html:td>
         </html:tr>
       </html:table>
     </markup>
 
-    <markup ref="html:table/html:tr/html:td" ruleset="htmlctrl"
-            id="markup5test">
-      <html:span id="l1" a11yname="test2">test2</html:span>
-      <html:span id="l2" a11yname="test3">test3</html:span>
-      <html:label for="gc" a11yname="test4">test4</html:label>
+    <markup id="HTMLTdARIAGridCellTest"
+            ref="html:table/html:tr/html:td" ruleset="HTMLControl">
+      <html:span id="l1" textequiv="test2">test2</html:span>
+      <html:span id="l2" textequiv="test3">test3</html:span>
+      <html:label for="gc" textequiv="test4">test4</html:label>
       <html:table>
         <html:tr>
           <html:td id="gc"
                    role="gridcell"
                    aria-label="test1"
                    aria-labelledby="l1 l2"
-                   a11yname="This is a paragraph This is a link • Listitem1 • Listitem2"
+                   textequiv="This is a paragraph This is a link • Listitem1 • Listitem2"
                    title="This is a paragraph This is a link This is a list">
             <html:p>This is a paragraph</html:p>
             <html:a href="#">This is a link</html:a>
             <html:ul>
               <html:li>Listitem1</html:li>
               <html:li>Listitem2</html:li>
             </html:ul>
           </html:td>
         </html:tr>
       </html:table>
     </markup>
 
-    <markup ref="html:table" ruleset="htmltable"
-            id="markup6test">
-      <html:span id="l1" a11yname="lby_tst6_1">lby_tst6_1</html:span>
-      <html:span id="l2" a11yname="lby_tst6_2">lby_tst6_2</html:span>
-      <html:label for="t" a11yname="label_tst6">label_tst6</html:label>
+    <markup id="HTMLTableTest"
+            ref="html:table" ruleset="HTMLTable">
+      <html:span id="l1" textequiv="lby_tst6_1">lby_tst6_1</html:span>
+      <html:span id="l2" textequiv="lby_tst6_2">lby_tst6_2</html:span>
+      <html:label for="t" textequiv="label_tst6">label_tst6</html:label>
       <!-- layout frame are recreated due to varous reasons, here's text frame
           placed after caption frame triggres table frame recreation when
           caption element is removed from DOM; get rid text node after caption
           node to make the test working -->
       <html:table id="t" aria-label="arialabel_tst6"
                   aria-labelledby="l1 l2"
                   summary="summary_tst6"
                   title="title_tst6">
-        <html:caption a11yname="caption_tst6">caption_tst6</html:caption><html:tr>
+        <html:caption textequiv="caption_tst6">caption_tst6</html:caption><html:tr>
           <html:td>cell1</html:td>
           <html:td>cell2</html:td>
         </html:tr>
       </html:table>
     </markup>
 
   </rulesample>
 </rules>
deleted file mode 100644
--- a/accessible/tests/mochitest/name/test_button.html
+++ /dev/null
@@ -1,145 +0,0 @@
-<html>
-
-<head>
-  <title>nsIAccessible::name calculation for HTML buttons</title>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-
-  <script type="application/javascript"
-          src="../common.js"></script>
-  <script type="application/javascript"
-          src="../name.js"></script>
-
-  <script type="application/javascript">
-    function doTest()
-    {
-      // html:button, aria-label
-      testName("btn_aria_label", "button label");
-
-      // html:button, aria-labelledby
-      testName("btn_aria_labelledby_text", "text");
-
-      // html:button, html:label
-      testName("btn_labelled", "label");
-
-      // html:button, name from content
-      testName("btn_namefromcontent", "1");
-
-      // html:button, no name from content
-      testName("btn_nonamefromcontent", null);
-
-      // @html:button, title
-      testName("btn_title", "title");
-
-      // html:input, aria-label
-      testName("input_aria_label", "button label");
-
-      // html:input, aria-labelledby
-      testName("input_aria_labelledby_text", "text");
-
-      // html:input, html:label
-      testName("input_labelled", "label");
-
-      // html:input, @value
-      testName("input_value0", "1");
-
-      // html:input, @value
-      testName("input_value", "1");
-
-      // html:input, @alt
-      testName("input_alt", "alt");
-
-      // html:input, @src
-      testName("input_src", "src");
-
-      // html:input, @data
-      testName("input_data", "data");
-
-      // html:input, @title
-      testName("input_title", "title");
-
-      SimpleTest.finish();
-    }
-
-    SimpleTest.waitForExplicitFinish();
-    addA11yLoadEvent(doTest);
-  </script>
-
-</head>
-
-<body>
-
-  <a target="_blank"
-     href="https://bugzilla.mozilla.org/show_bug.cgi?id=459635"
-     title="nsIAccessible::name calculation for HTML buttons">
-    Mozilla Bug 459635
-  </a>
-  <p id="display"></p>
-  <div id="content" style="display: none"></div>
-  <pre id="test">
-  </pre>
-
-  <!-- aria-labelledby preferred to aria-label -->
-  <button id="btn_aria_label"
-          aria-label="button label">1</button>
-  <br/>
-
-  <!-- button, aria-labelledby, preferred to html:label -->
-  <span id="aria_labelledby_text">text</span>
-  <label for="btn_aria_labelledby_text">label</label>
-  <button id="btn_aria_labelledby_text"
-          aria-labelledby="aria_labelledby_text">1</button>
-  <br/>
-
-  <!-- button, label, preferred to name from content -->
-  <label for="btn_labelled">label</label>
-  <button id="btn_labelled">1</button>
-
-  <!-- button, name from content, preferred to @title -->
-  <button id="btn_namefromcontent" title="title">1</button>
-
-  <!-- button, no name from content, ARIA role overrides this rule -->
-  <button id="btn_nonamefromcontent" role="img">1</button>
-
-  <!-- button, no content, name from @title -->
-  <button id="btn_title" title="title"></button>
-
-  <!-- input, aria-label -->
-  <input type="button" id="input_aria_label"
-          aria-label="button label"
-          value="1"/>
-  <br/>
-
-  <!-- aria-labelledby, preferred to html:label -->
-  <span id="aria_labelledby_text_for_input">text</span>
-  <label for="input_aria_labelledby_text">label</label>
-  <input type="button" id="input_aria_labelledby_text"
-         aria-labelledby="aria_labelledby_text_for_input"
-         value="1"/>
-  <br/>
-
-  <!-- label, preferred to @title -->
-  <label for="input_labelled">label</label>
-  <input type="button" id="input_labelled" value="1" title="title"/>
-
-  <!-- name from @value, preferred to @title -->
-  <input type="button" id="input_value0" title="title" value="1"/>
-
-  <!-- name from @value, preferred to @alt -->
-  <input type="button" id="input_value" value="1" alt="alt"/>
-
-  <!-- name from @alt, preferred to @src -->
-  <input type="button" id="input_alt" alt="alt" @src="src"/>
-
-  <!-- name from @src, preferred to @data -->
-  <input type="button" id="input_src" src="src" data="data"/>
-
-  <!-- name from @data -->
-  <input type="button" id="input_data" data="data"/>
-
-  <!-- name from @title -->
-  <input type="button" id="input_title" title="title"/>
-</body>
-</html>
--- a/accessible/tests/mochitest/name/test_general.html
+++ b/accessible/tests/mochitest/name/test_general.html
@@ -120,16 +120,19 @@
 
       //////////////////////////////////////////////////////////////////////////
       // name from children
 
       // ARIA role button is presented allowing the name calculation from
       // children.
       testName("btn_children", "14");
 
+      // html:button, no name from content
+      testName("btn_nonamefromcontent", null);
+
       // ARIA role option is presented allowing the name calculation from
       // visible children (bug 443081).
       testName("lb_opt1_children_hidden", "i am visible");
 
       // Get the name from subtree of menuitem crossing role nothing to get
       // the name from its children.
       testName("tablemenuitem", "menuitem 1");
 
@@ -154,22 +157,16 @@
 
       // new textarea name should reflect the value change. 
       var elem = document.getElementById("textareawithchild");
       elem.value = "Bar";
 
       testName("textareawithchild", "Story Bar is ended.");
 
       //////////////////////////////////////////////////////////////////////////
-      // button name (specific cases not covered by test_name_markup.html)
-
-      testName("submit", "Submit Query");
-      testName("image_submit", "Submit Query");
-
-      //////////////////////////////////////////////////////////////////////////
       // controls having a value used as a part of computed name
 
       testName("ctrlvalue_progressbar:input", "foo 5 baz");
       testName("ctrlvalue_scrollbar:input", "foo 5 baz");
       testName("ctrlvalue_slider:input", "foo 5 baz");
       testName("ctrlvalue_spinbutton:input", "foo 5 baz");
 
 
@@ -218,52 +215,57 @@
 
 </head>
 
 <body>
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=428479"
      title="Bug 428479 - Support ARIA role=math">
-    Mozilla Bug 428479
-  </a><br>
+    Bug 428479
+  </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=429666"
      title="Expose ROLE_DOCUMENT for ARIA landmarks that inherit from document">
-    Mozilla Bug 429666
-  </a><br>
+    Bug 429666
+  </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279"
      title="mochitest for accessible name calculating">
-    Mozilla Bug 444279
-  </a><br>
+    Bug 444279
+  </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=459635"
+     title="nsIAccessible::name calculation for HTML buttons">
+    Bug 459635
+  </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=530081"
-     title="Clean up our tree walker ">
-    Mozilla Bug 530081
+     title="Clean up our tree walker">
+    Bug 530081
   </a><br>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=604391"
      title="Use placeholder as name if name is otherwise empty">
-    Mozilla Bug 604391
+    Bug 604391
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=669312"
      title="Accessible name is duplicated when input has a label associated uisng for/id and is wrapped around the input">
-    Mozilla Bug 669312
+    Bug 669312
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=704416"
      title="HTML acronym and abbr names should be provided by @title">
-    Mozilla Bug 704416
+    Bug 704416
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=812041"
      title="ARIA slider and spinbutton don't provide a value for name computation">
-    Mozilla Bug 812041
+    Bug 812041
   </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!-- aria-label, simple label -->
   <span id="btn_simple_aria_label" role="button" aria-label="I am a button"/>
@@ -413,16 +415,19 @@
   <!-- multiple label elements for single button -->
   <label for="btn_label_multi">label1</label>
   <label for="btn_label_multi">label2</label>
   <button id="btn_label_multi">button</button>
 
   <!-- name from children -->
   <span id="btn_children" role="button">14</span>
 
+  <!-- no name from content, ARIA role overrides this rule -->
+  <button id="btn_nonamefromcontent" role="img">1</button>
+
   <!-- name from children, hidden children -->
   <div role="listbox" tabindex="0">
     <div id="lb_opt1_children_hidden" role="option" tabindex="0">
       <span>i am visible</span>
       <span style="display:none">i am hidden</span>
     </div>
   </div>
 
@@ -450,20 +455,16 @@
   <!-- A textarea nested in a label with a text child (bug #453371). -->
   <form>
     <label>Story
       <textarea id="textareawithchild" name="name">Foo</textarea>
       is ended.
     </label>
   </form>
 
-  <!-- submit buttons -->
-  <input type="submit" id="submit">
-  <input type="image" id="image_submit">
-
   <!-- controls having a value used as part of computed name -->
   <input type="checkbox" id="ctrlvalue_progressbar:input">
   <label for="ctrlvalue_progressbar:input">
     foo <span role="progressbar"
                aria-valuenow="5" aria-valuemin="1"
                aria-valuemax="10">5</span> baz
   </label>
 
--- a/accessible/tests/mochitest/name/test_markup.html
+++ b/accessible/tests/mochitest/name/test_markup.html
@@ -32,22 +32,27 @@
 
 </head>
 
 <body>
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=459635"
      title="nsIAccessible::name calculation for elements">
-    Mozilla Bug 459635
+    Bug 459635
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=666212"
      title="summary attribute content mapped to accessible name in MSAA">
-    Mozilla Bug 666212
+    Bug 666212
+  </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=786163"
+     title=" Sort out name calculation for HTML input buttons">
+    Bug 786163
   </a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <div id="eventdump"></div>