Bug 838407 - aria-hidden false value shouldn't be exposed via object attributes, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 11 Feb 2013 09:54:14 +0900
changeset 131356 80fa2c61df149c573ac85dd82e5c0ae9387fff14
parent 131355 a4ce303cca2f9c4581530c80666d8041fdd53809
child 131357 f8beba959a1c96466c407496018143bfcf66b0de
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs838407
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 838407 - aria-hidden false value shouldn't be exposed via object attributes, r=tbsaunde
accessible/src/base/nsARIAMap.cpp
accessible/src/base/nsARIAMap.h
accessible/tests/mochitest/attributes/test_obj.html
--- a/accessible/src/base/nsARIAMap.cpp
+++ b/accessible/src/base/nsARIAMap.cpp
@@ -674,17 +674,17 @@ nsAttributeCharacteristics nsARIAMap::gW
   {&nsGkAtoms::aria_controls,          ATTR_BYPASSOBJ                 | ATTR_GLOBAL },
   {&nsGkAtoms::aria_describedby,       ATTR_BYPASSOBJ                 | ATTR_GLOBAL },
   {&nsGkAtoms::aria_disabled,          ATTR_BYPASSOBJ | ATTR_VALTOKEN | ATTR_GLOBAL },
   {&nsGkAtoms::aria_dropeffect,                         ATTR_VALTOKEN | ATTR_GLOBAL },
   {&nsGkAtoms::aria_expanded,          ATTR_BYPASSOBJ | ATTR_VALTOKEN               },
   {&nsGkAtoms::aria_flowto,            ATTR_BYPASSOBJ                 | ATTR_GLOBAL },
   {&nsGkAtoms::aria_grabbed,                            ATTR_VALTOKEN | ATTR_GLOBAL },
   {&nsGkAtoms::aria_haspopup,          ATTR_BYPASSOBJ | ATTR_VALTOKEN | ATTR_GLOBAL },
-  {&nsGkAtoms::aria_hidden,                             ATTR_VALTOKEN | ATTR_GLOBAL },/* always expose obj attr */
+  {&nsGkAtoms::aria_hidden,   ATTR_BYPASSOBJ_IF_FALSE | ATTR_VALTOKEN | ATTR_GLOBAL },
   {&nsGkAtoms::aria_invalid,           ATTR_BYPASSOBJ | ATTR_VALTOKEN | ATTR_GLOBAL },
   {&nsGkAtoms::aria_label,             ATTR_BYPASSOBJ                 | ATTR_GLOBAL },
   {&nsGkAtoms::aria_labelledby,        ATTR_BYPASSOBJ                 | ATTR_GLOBAL },
   {&nsGkAtoms::aria_level,             ATTR_BYPASSOBJ                               }, /* handled via groupPosition */
   {&nsGkAtoms::aria_live,                               ATTR_VALTOKEN | ATTR_GLOBAL },
   {&nsGkAtoms::aria_multiline,         ATTR_BYPASSOBJ | ATTR_VALTOKEN               },
   {&nsGkAtoms::aria_multiselectable,   ATTR_BYPASSOBJ | ATTR_VALTOKEN               },
   {&nsGkAtoms::aria_owns,              ATTR_BYPASSOBJ                 | ATTR_GLOBAL },
@@ -771,16 +771,22 @@ AttrIterator::Next(nsAString& aAttrName,
       uint8_t attrFlags = nsAccUtils::GetAttributeCharacteristics(attrAtom);
       if (attrFlags & ATTR_BYPASSOBJ)
         continue; // No need to handle exposing as obj attribute here
 
       if ((attrFlags & ATTR_VALTOKEN) &&
            !nsAccUtils::HasDefinedARIAToken(mContent, attrAtom))
         continue; // only expose token based attributes if they are defined
 
+      if ((attrFlags & ATTR_BYPASSOBJ_IF_FALSE) &&
+          mContent->AttrValueIs(kNameSpaceID_None, attrAtom,
+                                nsGkAtoms::_false, eCaseMatters)) {
+        continue; // only expose token based attribute if value is not 'false'.
+      }
+
       nsAutoString value;
       if (mContent->GetAttr(kNameSpaceID_None, attrAtom, value)) {
         aAttrName.Assign(Substring(attrStr, 5));
         aAttrValue.Assign(value);
         return true;
       }
     }
   }
--- a/accessible/src/base/nsARIAMap.h
+++ b/accessible/src/base/nsARIAMap.h
@@ -93,28 +93,29 @@ const bool kUseNativeRole = false;
 
 /**
  * This mask indicates the attribute should not be exposed as an object
  * attribute via the catch-all logic in Accessible::Attributes().
  * This means it either isn't mean't to be exposed as an object attribute, or
  * that it should, but is already handled in other code.
  */
 const uint8_t ATTR_BYPASSOBJ = 0x1 << 0;
+const uint8_t ATTR_BYPASSOBJ_IF_FALSE = 0x1 << 1;
 
 /**
  * This mask indicates the attribute is expected to have an NMTOKEN or bool value.
  * (See for example usage in Accessible::Attributes())
  */
-const uint8_t ATTR_VALTOKEN = 0x1 << 1;
+const uint8_t ATTR_VALTOKEN = 0x1 << 2;
 
 /**
  * Indicate the attribute is global state or property (refer to
  * http://www.w3.org/TR/wai-aria/states_and_properties#global_states).
  */
-const uint8_t ATTR_GLOBAL = 0x1 << 2;
+const uint8_t ATTR_GLOBAL = 0x1 << 3;
 
 /**
  * Small footprint storage of persistent aria attribute characteristics.
  */
 struct nsAttributeCharacteristics
 {
   nsIAtom** attributeName;
   const uint8_t characteristics;
--- a/accessible/tests/mochitest/attributes/test_obj.html
+++ b/accessible/tests/mochitest/attributes/test_obj.html
@@ -28,16 +28,17 @@ https://bugzilla.mozilla.org/show_bug.cg
       testAttrs("checkedCheckbox", {"checkable" : "true"}, true); 
       testAttrs("checkedMenuitem", {"checkable" : "true"}, true); 
       testAttrs("checkedOption", {"checkable" : "true"}, true); 
       testAttrs("checkedRadio", {"checkable" : "true"}, true); 
       testAttrs("checkedTreeitem", {"checkable" : "true"}, true); 
       testAttrs("dropeffect", {"dropeffect" : "copy"}, true);
       testAttrs("grabbed", {"grabbed" : "true"}, true);
       testAttrs("hidden", {"hidden" : "true"}, true);
+      testAbsentAttrs("hidden_false", { "hidden": "false" });
       testAttrs("sortAscending", {"sort" : "ascending"}, true);
       testAttrs("sortDescending", {"sort" : "descending"}, true);
       testAttrs("sortNone", {"sort" : "none"}, true);
       testAttrs("sortOther", {"sort" : "other"}, true);
 
       // inherited attributes by subdocuments
       var subdoc = getAccessible("iframe").firstChild;
       testAttrs(subdoc, {"busy" : "true"}, true);
@@ -157,16 +158,21 @@ https://bugzilla.mozilla.org/show_bug.cg
      title="Expand support for nsIAccessibleEvent::OBJECT_ATTRIBUTE_CHANGE">
     Mozilla Bug 563862
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=819303"
      title="crash in nsTextEquivUtils::AppendTextEquivFromTextContent">
     Mozilla Bug 819303
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=838407"
+     title="aria-hidden false value shouldn't be exposed via object attributes">
+    Mozilla Bug 838407
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!-- aria -->
   <div id="atomic" aria-atomic="true"></div>
   <div id="autocomplete" role="textbox" aria-autocomplete="true"></div>
@@ -174,16 +180,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <div id="checkedCheckbox" role="checkbox" aria-checked="true"></div>
   <div id="checkedMenuitem" role="menuitem" aria-checked="true"></div>
   <div id="checkedOption" role="option" aria-checked="true"></div>
   <div id="checkedRadio" role="radio" aria-checked="true"></div>
   <div id="checkedTreeitem" role="treeitem" aria-checked="true"></div>
   <div id="dropeffect" aria-dropeffect="copy"></div>
   <div id="grabbed" aria-grabbed="true"></div>
   <div id="hidden" aria-hidden="true"></div>
+  <div id="hidden_false" aria-hidden="false"></div>
   <div id="sortAscending" role="columnheader" aria-sort="ascending"></div>
   <div id="sortDescending" role="columnheader" aria-sort="descending"></div>
   <div id="sortNone" role="columnheader" aria-sort="none"></div>
   <div id="sortOther" role="columnheader" aria-sort="other"></div>
 
   <!-- inherited from iframe -->
   <iframe id="iframe" src="data:text/html,<html><body></body></html>"
           aria-busy="true"></iframe>