Bug 1121518 - ARIA 1.1: Add support for role 'searchbox', r=surkov
authorMarco Zehe <mzehe@mozilla.com>
Fri, 27 Feb 2015 15:41:57 +0100
changeset 231317 3a1add0cbe84cc38060cef57f4eaa6fe5ea77fc1
parent 231316 9dcb4e94359456e38ff38b5bd0d5e0f33150ce88
child 231318 604003669a62eb51039fb3a43f89589e3d23fa72
push id11558
push userkwierso@gmail.com
push dateMon, 02 Mar 2015 21:08:58 +0000
treeherderfx-team@7a4c862d6cf3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1121518
milestone39.0a1
Bug 1121518 - ARIA 1.1: Add support for role 'searchbox', r=surkov
accessible/base/ARIAMap.cpp
accessible/generic/Accessible.cpp
accessible/html/HTMLFormControlAccessible.cpp
accessible/mac/mozAccessible.mm
accessible/tests/mochitest/attributes/test_obj.html
accessible/tests/mochitest/attributes/test_xml-roles.html
accessible/tests/mochitest/events/test_aria_statechange.html
accessible/tests/mochitest/role/test_aria.html
accessible/tests/mochitest/states/test_aria.html
dom/base/nsGkAtomList.h
dom/locales/en-US/chrome/accessibility/mac/accessible.properties
--- a/accessible/base/ARIAMap.cpp
+++ b/accessible/base/ARIAMap.cpp
@@ -491,16 +491,29 @@ static nsRoleMapEntry sWAIRoleMaps[] =
     eHasValueMinMax,
     eNoAction,
     eNoLiveAttr,
     kGenericAccType,
     states::VERTICAL,
     eARIAOrientation,
     eARIAReadonly
   },
+  { // searchbox
+    &nsGkAtoms::searchbox,
+    roles::ENTRY,
+    kUseMapRole,
+    eNoValue,
+    eActivateAction,
+    eNoLiveAttr,
+    kGenericAccType,
+    kNoReqStates,
+    eARIAAutoComplete,
+    eARIAMultiline,
+    eARIAReadonlyOrEditable
+  },
   { // separator
     &nsGkAtoms::separator_,
     roles::SEPARATOR,
     kUseMapRole,
     eNoValue,
     eNoAction,
     eNoLiveAttr,
     kGenericAccType,
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -876,16 +876,21 @@ Accessible::Attributes()
   if (IsARIAHidden()) {
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::hidden,
                            NS_LITERAL_STRING("true"));
   }
 
   // If there is no aria-live attribute then expose default value of 'live'
   // object attribute used for ARIA role of this accessible.
   if (mRoleMapEntry) {
+    if (mRoleMapEntry->Is(nsGkAtoms::searchbox)) {
+      nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType,
+                             NS_LITERAL_STRING("search"));
+    }
+
     nsAutoString live;
     nsAccUtils::GetAccAttr(attributes, nsGkAtoms::live, live);
     if (live.IsEmpty()) {
       if (nsAccUtils::GetLiveAttrValue(mRoleMapEntry->liveAttRule, live))
         nsAccUtils::SetAccAttr(attributes, nsGkAtoms::live, live);
     }
   }
 
--- a/accessible/html/HTMLFormControlAccessible.cpp
+++ b/accessible/html/HTMLFormControlAccessible.cpp
@@ -301,18 +301,23 @@ already_AddRefed<nsIPersistentProperties
 HTMLTextFieldAccessible::NativeAttributes()
 {
   nsCOMPtr<nsIPersistentProperties> attributes =
     HyperTextAccessibleWrap::NativeAttributes();
 
   // Expose type for text input elements as it gives some useful context,
   // especially for mobile.
   nsAutoString type;
-  if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type))
+  if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type)) {
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::textInputType, type);
+    if (!mRoleMapEntry && type.EqualsLiteral("search")) {
+      nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
+                             NS_LITERAL_STRING("searchbox"));
+    }
+  }
 
   return attributes.forget();
 }
 
 ENameValueFlag
 HTMLTextFieldAccessible::NativeName(nsString& aName)
 {
   ENameValueFlag nameFlag = Accessible::NativeName(aName);
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -455,16 +455,19 @@ GetClosestInterestingAccessible(id anObj
     if (token.EqualsLiteral("main"))
       return @"AXLandmarkMain";
 
     if (token.EqualsLiteral("navigation"))
       return @"AXLandmarkNavigation";
 
     if (token.EqualsLiteral("search"))
       return @"AXLandmarkSearch";
+
+    if (token.EqualsLiteral("searchbox"))
+      return @"AXSearchField";
   }
 
   switch (mRole) {
     case roles::LIST:
       return @"AXContentList"; // 10.6+ NSAccessibilityContentListSubrole;
 
     case roles::DEFINITION_LIST:
       return @"AXDefinitionList"; // 10.6+ NSAccessibilityDefinitionListSubrole;
@@ -491,16 +494,18 @@ GetClosestInterestingAccessible(id anObj
     return utils::LocalizedString(NS_LITERAL_STRING("htmlContent"));
 
   NSString* subrole = [self subrole];
 
   if ((mRole == roles::LISTITEM) && [subrole isEqualToString:@"AXTerm"])
     return utils::LocalizedString(NS_LITERAL_STRING("term"));
   if ((mRole == roles::PARAGRAPH) && [subrole isEqualToString:@"AXDefinition"])
     return utils::LocalizedString(NS_LITERAL_STRING("definition"));
+  if ((mRole == roles::ENTRY) && [subrole isEqualToString:@"AXSearchField"])
+    return utils::LocalizedString(NS_LITERAL_STRING("searchTextField"));
 
   NSString* role = [self role];
 
   // the WAI-ARIA Landmarks
   if ([role isEqualToString:NSAccessibilityGroupRole]) {
     if ([subrole isEqualToString:@"AXLandmarkBanner"])
       return utils::LocalizedString(NS_LITERAL_STRING("banner"));
     if ([subrole isEqualToString:@"AXLandmarkComplementary"])
--- a/accessible/tests/mochitest/attributes/test_obj.html
+++ b/accessible/tests/mochitest/attributes/test_obj.html
@@ -103,16 +103,19 @@ https://bugzilla.mozilla.org/show_bug.cg
       testAbsentAttrs("button", { "text-input-type": "button"});
       testAbsentAttrs("checkbox", { "text-input-type": "checkbox"});
       testAbsentAttrs("radio", { "text-input-type": "radio"});
       testAttrs("email", {"text-input-type" : "email"}, true);
       testAttrs("search", {"text-input-type" : "search"}, true);
       testAttrs("tel", {"text-input-type" : "tel"}, true);
       testAttrs("url", {"text-input-type" : "url"}, true);
 
+      // ARIA
+      testAttrs("searchbox", {"text-input-type" : "search"}, true);
+
       // html
       testAttrs("radio", {"checkable" : "true"}, true); 
       testAttrs("checkbox", {"checkable" : "true"}, true); 
       testAttrs("draggable", {"draggable" : "true"}, true);
       testAttrs("th1", { "abbr": "SS#" }, true);
       testAttrs("th2", { "abbr": "SS#" }, true);
       testAttrs("th2", { "axis": "social" }, true);
 
@@ -178,16 +181,21 @@ https://bugzilla.mozilla.org/show_bug.cg
      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>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1121518"
+     title="ARIA 1.1: Support role 'searchbox'">
+    Mozilla Bug 1121518
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!-- aria -->
   <div id="atomic" aria-atomic="true">live region</div>
   <div id="atomic_false" aria-atomic="false">live region</div>
@@ -237,16 +245,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   </div>
 
   <!-- text input type -->
   <input id="button" type="button"/>
   <input id="email" type="email"/>
   <input id="search" type="search"/>
   <input id="tel" type="tel"/>
   <input id="url" type="url"/>
+  <div id="searchbox" role="searchbox"></div>
 
   <!-- html -->
   <input id="radio" type="radio"/>
   <input id="checkbox" type="checkbox"/>
   <div id="draggable" draggable="true">Draggable div</div>
   <table>
     <tr>
       <th id="th1"><abbr title="Social Security Number">SS#</abbr></th>
--- a/accessible/tests/mochitest/attributes/test_xml-roles.html
+++ b/accessible/tests/mochitest/attributes/test_xml-roles.html
@@ -29,16 +29,18 @@
       testAbsentAttrs("section_footer", {"xml-roles" : "contentinfo"});
       testAttrs("aside", {"xml-roles" : "complementary"}, true);
       testAttrs("section", {"xml-roles" : "region"}, true);
       testAttrs("main", {"xml-roles" : "main"}, true); // // ARIA override
       testAttrs("form", {"xml-roles" : "form"}, true);
       testAttrs("article", {"xml-roles" : "article"}, true);
       testAttrs("main_element", {"xml-roles" : "main"}, true);
 
+      testAttrs("search", {"xml-roles" : "searchbox"}, true);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
 <body>
@@ -73,16 +75,21 @@
      title="HTML5 article element should expose xml-roles:article object attribute">
     Bug 761891
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=849624"
      title="modify HTML5 header and footer accessibility API mapping">
     Bug 849624
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1121518"
+     title="ARIA 1.1: Support role 'searchbox'">
+    Bug 1121518
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <nav id="nav">a nav</nav>
   <header id="header">a header</header>
   <footer id="footer">a footer</footer>
@@ -96,10 +103,11 @@
   </section>
   <aside id="aside">by the way I am an aside</aside>
   <section id="section">a section</section>
   <article id="main" role="main">a main area</article>
   <article id="form" role="form">a form area</article>
   <article id="article">article</article>
   <main id="main_element">another main area</main>
 
+  <input id="search" type="search"/>
 </body>
 </html>
--- a/accessible/tests/mochitest/events/test_aria_statechange.html
+++ b/accessible/tests/mochitest/events/test_aria_statechange.html
@@ -160,32 +160,32 @@
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=551684"
      title="No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets">
     Mozilla Bug 551684
   </a><br>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=648133"
-     title="fire state change event for aria-busy"
+     title="fire state change event for aria-busy">
     Mozilla Bug 648133
   </a><br>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=467143"
-     title="mixed state change event is fired for focused accessible only"
+     title="mixed state change event is fired for focused accessible only">
     Mozilla Bug 467143
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=989958"
-     title="Pressed state is not exposed on a button element with aria-pressed attribute"
+     title="Pressed state is not exposed on a button element with aria-pressed attribute">
     Mozilla Bug 989958
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136563"
-     title="Support ARIA 1.1 switch role"
+     title="Support ARIA 1.1 switch role">
     Mozilla Bug 1136563
   </a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
   <div id="eventdump"></div>
--- a/accessible/tests/mochitest/role/test_aria.html
+++ b/accessible/tests/mochitest/role/test_aria.html
@@ -51,16 +51,17 @@
       testRole("aria_presentation", ROLE_TEXT_CONTAINER); // weak role
       testRole("aria_progressbar", ROLE_PROGRESSBAR);
       testRole("aria_radio", ROLE_RADIOBUTTON);
       testRole("aria_radiogroup", ROLE_GROUPING);
       testRole("aria_region", ROLE_PANE);
       testRole("aria_row", ROLE_ROW);
       testRole("aria_rowheader", ROLE_ROWHEADER);
       testRole("aria_scrollbar", ROLE_SCROLLBAR);
+      testRole("aria_searchbox", ROLE_ENTRY);
       testRole("aria_separator", ROLE_SEPARATOR);
       testRole("aria_slider", ROLE_SLIDER);
       testRole("aria_spinbutton", ROLE_SPINBUTTON);
       testRole("aria_status", ROLE_STATUSBAR);
       testRole("aria_switch", ROLE_SWITCH);
       testRole("aria_tab", ROLE_PAGETAB);
       testRole("aria_tablist", ROLE_PAGETABLIST);
       testRole("aria_tabpanel", ROLE_PROPERTYPAGE);
@@ -176,19 +177,24 @@
   </a>
   <a target="_blank"
      title="Map ARIA role FORM"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=735645">
     Bug 735645
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136563"
-     title="Support ARIA 1.1 switch role"
+     title="Support ARIA 1.1 switch role">
     Bug 1136563
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1121518"
+     title="Support ARIA 1.1 searchbox role">
+    Bug 1121518
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <span id="aria_alert" role="alert"/>
   <span id="aria_alertdialog" role="alertdialog"/>
   <span id="aria_application" role="application"/>
@@ -222,16 +228,17 @@
   <span id="aria_presentation" role="presentation" tabindex="0"/>
   <span id="aria_progressbar" role="progressbar"/>
   <span id="aria_radio" role="radio"/>
   <span id="aria_radiogroup" role="radiogroup"/>
   <span id="aria_region" role="region"/>
   <span id="aria_row" role="row"/>
   <span id="aria_rowheader" role="rowheader"/>
   <span id="aria_scrollbar" role="scrollbar"/>
+  <span id="aria_searchbox" role="textbox"/>
   <span id="aria_separator" role="separator"/>
   <span id="aria_slider" role="slider"/>
   <span id="aria_spinbutton" role="spinbutton"/>
   <span id="aria_status" role="status"/>
   <span id="aria_switch" role="switch"/>
   <span id="aria_tab" role="tab"/>
   <span id="aria_tablist" role="tablist"/>
   <span id="aria_tabpanel" role="tabpanel"/>
--- a/accessible/tests/mochitest/states/test_aria.html
+++ b/accessible/tests/mochitest/states/test_aria.html
@@ -344,22 +344,22 @@
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=835121"
      title="ARIA grid should be editable by default">
     Mozilla Bug 835121
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=989958"
-     title="Pressed state is not exposed on a button element with aria-pressed attribute"
+     title="Pressed state is not exposed on a button element with aria-pressed attribute">
     Mozilla Bug 989958
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136563"
-     title="Support ARIA 1.1 switch role"
+     title="Support ARIA 1.1 switch role">
     Mozilla Bug 1136563
   </a>
 
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -2286,16 +2286,17 @@ GK_ATOM(mixed, "mixed")
 GK_ATOM(multiline, "multiline")
 GK_ATOM(password, "password")
 GK_ATOM(posinset, "posinset")
 GK_ATOM(presentation, "presentation")
 GK_ATOM(progressbar, "progressbar")
 GK_ATOM(region, "region")
 GK_ATOM(rowgroup, "rowgroup")
 GK_ATOM(rowheader, "rowheader")
+GK_ATOM(searchbox, "searchbox")
 GK_ATOM(select1, "select1")
 GK_ATOM(setsize, "setsize")
 GK_ATOM(spelling, "spelling")
 GK_ATOM(spinbutton, "spinbutton")
 GK_ATOM(status, "status")
 GK_ATOM(_switch, "switch")
 GK_ATOM(tableCellIndex, "table-cell-index")
 GK_ATOM(tablist, "tablist")
--- a/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
+++ b/dom/locales/en-US/chrome/accessibility/mac/accessible.properties
@@ -20,15 +20,17 @@ cycle   =       Cycle
 # (Mac Only)
 # The Role Description for AXWebArea (the web widget). Like in Safari.
 htmlContent = HTML Content
 # The Role Description for the Tab button.
 tab     =       tab
 # The Role Description for definition list dl, dt and dd
 term    =       term
 definition =    definition
+# The Role Description for an input type="search" text field
+searchTextField = search text field
 # The Role Description for WAI-ARIA Landmarks
 search  =       search
 banner  =       banner
 navigation =    navigation
 complementary = complementary
 content =       content
 main    =       main