accessible/tests/mochitest/role/test_aria.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/role/test_aria.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,329 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test weak ARIA roles</title>
     1.8 +
     1.9 +  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.10 +
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +
    1.14 +  <script type="application/javascript"
    1.15 +          src="../common.js"></script>
    1.16 +  <script type="application/javascript"
    1.17 +          src="../role.js"></script>
    1.18 +
    1.19 +  <script type="application/javascript">
    1.20 +
    1.21 +    function doTest()
    1.22 +    {
    1.23 +      // ARIA role map.
    1.24 +      testRole("aria_alert", ROLE_ALERT);
    1.25 +      testRole("aria_alertdialog", ROLE_DIALOG);
    1.26 +      testRole("aria_application", ROLE_APPLICATION);
    1.27 +      testRole("aria_article", ROLE_DOCUMENT);
    1.28 +      testRole("aria_button", ROLE_PUSHBUTTON);
    1.29 +      testRole("aria_checkbox", ROLE_CHECKBUTTON);
    1.30 +      testRole("aria_columnheader", ROLE_COLUMNHEADER);
    1.31 +      testRole("aria_combobox", ROLE_COMBOBOX);
    1.32 +      testRole("aria_dialog", ROLE_DIALOG);
    1.33 +      testRole("aria_directory", ROLE_LIST);
    1.34 +      testRole("aria_document", ROLE_DOCUMENT);
    1.35 +      testRole("aria_form", ROLE_FORM);
    1.36 +      testRole("aria_grid", ROLE_TABLE);
    1.37 +      testRole("aria_gridcell", ROLE_GRID_CELL);
    1.38 +      testRole("aria_group", ROLE_GROUPING);
    1.39 +      testRole("aria_heading", ROLE_HEADING);
    1.40 +      testRole("aria_img", ROLE_GRAPHIC);
    1.41 +      testRole("aria_link", ROLE_LINK);
    1.42 +      testRole("aria_list", ROLE_LIST);
    1.43 +      testRole("aria_listbox", ROLE_LISTBOX);
    1.44 +      testRole("aria_listitem", ROLE_LISTITEM);
    1.45 +      testRole("aria_log", ROLE_TEXT_CONTAINER); // weak role
    1.46 +      testRole("aria_marquee", ROLE_ANIMATION);
    1.47 +      testRole("aria_math", ROLE_FLAT_EQUATION);
    1.48 +      testRole("aria_menu", ROLE_MENUPOPUP);
    1.49 +      testRole("aria_menubar", ROLE_MENUBAR);
    1.50 +      testRole("aria_menuitem", ROLE_MENUITEM);
    1.51 +      testRole("aria_menuitemcheckbox", ROLE_CHECK_MENU_ITEM);
    1.52 +      testRole("aria_menuitemradio", ROLE_RADIO_MENU_ITEM);
    1.53 +      testRole("aria_note", ROLE_NOTE);
    1.54 +      testRole("aria_presentation", ROLE_TEXT_CONTAINER); // weak role
    1.55 +      testRole("aria_progressbar", ROLE_PROGRESSBAR);
    1.56 +      testRole("aria_radio", ROLE_RADIOBUTTON);
    1.57 +      testRole("aria_radiogroup", ROLE_GROUPING);
    1.58 +      testRole("aria_region", ROLE_PANE);
    1.59 +      testRole("aria_row", ROLE_ROW);
    1.60 +      testRole("aria_rowheader", ROLE_ROWHEADER);
    1.61 +      testRole("aria_scrollbar", ROLE_SCROLLBAR);
    1.62 +      testRole("aria_separator", ROLE_SEPARATOR);
    1.63 +      testRole("aria_slider", ROLE_SLIDER);
    1.64 +      testRole("aria_spinbutton", ROLE_SPINBUTTON);
    1.65 +      testRole("aria_status", ROLE_STATUSBAR);
    1.66 +      testRole("aria_tab", ROLE_PAGETAB);
    1.67 +      testRole("aria_tablist", ROLE_PAGETABLIST);
    1.68 +      testRole("aria_tabpanel", ROLE_PROPERTYPAGE);
    1.69 +      testRole("aria_textbox", ROLE_ENTRY);
    1.70 +      testRole("aria_timer", ROLE_TEXT_CONTAINER); // weak role
    1.71 +      testRole("aria_toolbar", ROLE_TOOLBAR);
    1.72 +      testRole("aria_tooltip", ROLE_TOOLTIP);
    1.73 +      testRole("aria_tree", ROLE_OUTLINE);
    1.74 +      testRole("aria_treegrid", ROLE_TREE_TABLE);
    1.75 +      testRole("aria_treeitem", ROLE_OUTLINEITEM);
    1.76 +
    1.77 +      // Note:
    1.78 +      // The phrase "weak foo" here means that there is no good foo-to-platform
    1.79 +      // role mapping. Similarly "strong foo" means there is a good foo-to-
    1.80 +      // platform role mapping.
    1.81 +
    1.82 +      testRole("articlemain", ROLE_DOCUMENT);
    1.83 +      testRole("articleform", ROLE_FORM);
    1.84 +
    1.85 +      // Test article exposed as document
    1.86 +      testRole("testArticle", ROLE_DOCUMENT);
    1.87 +
    1.88 +      // weak roles that are forms of "live regions"
    1.89 +      testRole("log_table", ROLE_TABLE);
    1.90 +      testRole("timer_div", ROLE_SECTION);
    1.91 +
    1.92 +      // other roles that are forms of "live regions"
    1.93 +      testRole("marquee_h1", ROLE_ANIMATION);
    1.94 +
    1.95 +      // strong landmark
    1.96 +      testRole("application", ROLE_APPLICATION);
    1.97 +      testRole("form", ROLE_FORM);
    1.98 +      testRole("application_table", ROLE_APPLICATION);
    1.99 +
   1.100 +      // weak landmarks
   1.101 +      var weak_landmarks = ["banner", "complementary", "contentinfo",
   1.102 +          "main", "navigation", "search"];
   1.103 +      for (l in weak_landmarks)
   1.104 +        testRole(weak_landmarks[l], ROLE_SECTION);
   1.105 +
   1.106 +      for (l in weak_landmarks) {
   1.107 +        var id = weak_landmarks[l] + "_table";
   1.108 +        testRole(id, ROLE_TABLE);
   1.109 +        
   1.110 +        var accessibleTable = getAccessible(id, [nsIAccessibleTable], null,
   1.111 +                                            DONOTFAIL_IF_NO_INTERFACE);
   1.112 +        ok(accessibleTable ? true : false,
   1.113 +           "landmarked table should have nsIAccessibleTable");
   1.114 +        
   1.115 +        if (accessibleTable)
   1.116 +          is(accessibleTable.getCellAt(0,0).firstChild.name, "hi", "no cell");
   1.117 +      }
   1.118 +
   1.119 +      //////////////////////////////////////////////////////////////////////////
   1.120 +      // test gEmptyRoleMap
   1.121 +      testRole("buttontable_row", ROLE_NOTHING);
   1.122 +      testRole("buttontable_cell", ROLE_NOTHING);
   1.123 +
   1.124 +      // abstract roles
   1.125 +      var abstract_roles = ["composite", "landmark", "structure", "widget",
   1.126 +                            "window", "input", "range", "select", "section",
   1.127 +                            "sectionhead"];
   1.128 +      for (a in abstract_roles)
   1.129 +        testRole(abstract_roles[a], ROLE_SECTION);
   1.130 +
   1.131 +      //////////////////////////////////////////////////////////////////////////
   1.132 +      // roles transformed by ARIA state attributes
   1.133 +      testRole("togglebutton", ROLE_TOGGLE_BUTTON);
   1.134 +
   1.135 +      //////////////////////////////////////////////////////////////////////////
   1.136 +      // ignore unknown roles, take first known
   1.137 +      testRole("unknown_roles", ROLE_PUSHBUTTON);
   1.138 +
   1.139 +      //////////////////////////////////////////////////////////////////////////
   1.140 +      // misc roles
   1.141 +      testRole("note", ROLE_NOTE);
   1.142 +      testRole("scrollbar", ROLE_SCROLLBAR);
   1.143 +      testRole("dir", ROLE_LIST);
   1.144 +
   1.145 +      //////////////////////////////////////////////////////////////////////////
   1.146 +      // test document role map update
   1.147 +      var testDoc = getAccessible(document, [nsIAccessibleDocument]);
   1.148 +      testRole(testDoc, ROLE_DOCUMENT);
   1.149 +      document.body.setAttribute("role", "application");
   1.150 +      testRole(testDoc, ROLE_APPLICATION);
   1.151 +
   1.152 +      // Test equation image
   1.153 +      testRole("img_eq", ROLE_FLAT_EQUATION);
   1.154 +
   1.155 +      // Test textual equation
   1.156 +      testRole("txt_eq", ROLE_FLAT_EQUATION);
   1.157 +
   1.158 +      SimpleTest.finish();
   1.159 +    }
   1.160 +
   1.161 +    SimpleTest.waitForExplicitFinish();
   1.162 +    addA11yLoadEvent(doTest);
   1.163 +  </script>
   1.164 +</head>
   1.165 +<body>
   1.166 +
   1.167 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=428479">Mozilla Bug 428479</a>
   1.168 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=429666">Mozilla Bug 429666</a>
   1.169 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=481114">Mozilla Bug 481114</a>
   1.170 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469688">Mozilla Bug 469688</a>
   1.171 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469688">Mozilla Bug 520188</a>
   1.172 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529289">Mozilla Bug 529289</a>
   1.173 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529289">Mozilla Bug 607219</a>
   1.174 +  <a target="_blank"
   1.175 +     title="HTML buttons with aria-pressed not exposing IA2 TOGGLE_BUTTON role"
   1.176 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=725432">
   1.177 +    Bug 725432
   1.178 +  </a>
   1.179 +  <a target="_blank"
   1.180 +     title="Map ARIA role FORM"
   1.181 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=735645">
   1.182 +    Bug 735645
   1.183 +  </a>
   1.184 +  <p id="display"></p>
   1.185 +  <div id="content" style="display: none"></div>
   1.186 +  <pre id="test">
   1.187 +  </pre>
   1.188 +
   1.189 +  <span id="aria_alert" role="alert"/>
   1.190 +  <span id="aria_alertdialog" role="alertdialog"/>
   1.191 +  <span id="aria_application" role="application"/>
   1.192 +  <span id="aria_article" role="article"/>
   1.193 +  <span id="aria_button" role="button"/>
   1.194 +  <span id="aria_checkbox" role="checkbox"/>
   1.195 +  <span id="aria_columnheader" role="columnheader"/>
   1.196 +  <span id="aria_combobox" role="combobox"/>
   1.197 +  <span id="aria_dialog" role="dialog"/>
   1.198 +  <span id="aria_directory" role="directory"/>
   1.199 +  <span id="aria_document" role="document"/>
   1.200 +  <span id="aria_form" role="form"/>
   1.201 +  <span id="aria_grid" role="grid"/>
   1.202 +  <span id="aria_gridcell" role="gridcell"/>
   1.203 +  <span id="aria_group" role="group"/>
   1.204 +  <span id="aria_heading" role="heading"/>
   1.205 +  <span id="aria_img" role="img"/>
   1.206 +  <span id="aria_link" role="link"/>
   1.207 +  <span id="aria_list" role="list"/>
   1.208 +  <span id="aria_listbox" role="listbox"/>
   1.209 +  <span id="aria_listitem" role="listitem"/>
   1.210 +  <span id="aria_log" role="log"/>
   1.211 +  <span id="aria_marquee" role="marquee"/>
   1.212 +  <span id="aria_math" role="math"/>
   1.213 +  <span id="aria_menu" role="menu"/>
   1.214 +  <span id="aria_menubar" role="menubar"/>
   1.215 +  <span id="aria_menuitem" role="menuitem"/>
   1.216 +  <span id="aria_menuitemcheckbox" role="menuitemcheckbox"/>
   1.217 +  <span id="aria_menuitemradio" role="menuitemradio"/>
   1.218 +  <span id="aria_note" role="note"/>
   1.219 +  <span id="aria_presentation" role="presentation" tabindex="0"/>
   1.220 +  <span id="aria_progressbar" role="progressbar"/>
   1.221 +  <span id="aria_radio" role="radio"/>
   1.222 +  <span id="aria_radiogroup" role="radiogroup"/>
   1.223 +  <span id="aria_region" role="region"/>
   1.224 +  <span id="aria_row" role="row"/>
   1.225 +  <span id="aria_rowheader" role="rowheader"/>
   1.226 +  <span id="aria_scrollbar" role="scrollbar"/>
   1.227 +  <span id="aria_separator" role="separator"/>
   1.228 +  <span id="aria_slider" role="slider"/>
   1.229 +  <span id="aria_spinbutton" role="spinbutton"/>
   1.230 +  <span id="aria_status" role="status"/>
   1.231 +  <span id="aria_tab" role="tab"/>
   1.232 +  <span id="aria_tablist" role="tablist"/>
   1.233 +  <span id="aria_tabpanel" role="tabpanel"/>
   1.234 +  <span id="aria_textbox" role="textbox"/>
   1.235 +  <span id="aria_timer" role="timer"/>
   1.236 +  <span id="aria_toolbar" role="toolbar"/>
   1.237 +  <span id="aria_tooltip" role="tooltip"/>
   1.238 +  <span id="aria_tree" role="tree"/>
   1.239 +  <span id="aria_treegrid" role="treegrid"/>
   1.240 +  <span id="aria_treeitem" role="treeitem"/>
   1.241 +
   1.242 +  <article id="articlemain" role="main">a main area</article>
   1.243 +  <article id="articleform" role="form">a form area</article>
   1.244 +
   1.245 +  <div id="testArticle" role="article" title="Test article">
   1.246 +    <p>This is a paragraph inside the article.</p>
   1.247 +  </div>
   1.248 +
   1.249 +  <!-- "live" roles -->
   1.250 +  <table role="log" id="log_table">
   1.251 +    <tr><td>Table based log</td></tr>
   1.252 +  </table>
   1.253 +  <h1 role="marquee" id="marquee_h1">marquee</h1>
   1.254 +  <div role="timer" id="timer_div">timer</div>
   1.255 +
   1.256 +  <!-- landmarks -->
   1.257 +  <div role="application" id="application">application</div>
   1.258 +  <div role="form" id="form">form</div>
   1.259 +
   1.260 +  <!-- weak landmarks -->
   1.261 +  <div role="banner" id="banner">banner</div>
   1.262 +  <div role="complementary" id="complementary">complementary</div>
   1.263 +  <div role="contentinfo" id="contentinfo">contentinfo</div>
   1.264 +  <div role="main" id="main">main</div>
   1.265 +  <div role="navigation" id="navigation">navigation</div>
   1.266 +  <div role="search" id="search">search</div>
   1.267 +
   1.268 +  <!-- landmarks are tables -->
   1.269 +  <table role="application" id="application_table">application table
   1.270 +    <tr><td>hi<td></tr></table>
   1.271 +  <table role="banner" id="banner_table">banner table
   1.272 +    <tr><td>hi<td></tr></table>
   1.273 +  <table role="complementary" id="complementary_table">complementary table
   1.274 +    <tr><td>hi<td></tr></table>
   1.275 +  <table role="contentinfo" id="contentinfo_table">contentinfo table
   1.276 +    <tr><td>hi<td></tr></table>
   1.277 +  <table role="main" id="main_table">main table
   1.278 +    <tr><td>hi<td></tr></table>
   1.279 +  <table role="navigation" id="navigation_table">navigation table
   1.280 +    <tr><td>hi<td></tr></table>
   1.281 +  <table role="search" id="search_table">search table
   1.282 +    <tr><td>hi<td></tr></table>
   1.283 +
   1.284 +  <!-- test gEmptyRoleMap -->
   1.285 +  <table role="button">
   1.286 +    <tr id="buttontable_row">
   1.287 +      <td id="buttontable_cell">cell</td>
   1.288 +    </tr>
   1.289 +  </table>
   1.290 +
   1.291 +  <!-- user agents must not map abstract roles to platform API -->
   1.292 +  <!-- test abstract base type roles -->
   1.293 +  <div role="composite" id="composite">composite</div>
   1.294 +  <div role="landmark" id="landmark">landmark</div>
   1.295 +  <div role="roletype" id="roletype">roletype</div>
   1.296 +  <div role="structure" id="structure">structure</div>
   1.297 +  <div role="widget" id="widget">widget</div>
   1.298 +  <div role="window" id="window">window</div>
   1.299 +  <!-- test abstract input roles -->
   1.300 +  <div role="input" id="input">input</div>
   1.301 +  <div role="range" id="range">range</div>
   1.302 +  <div role="select" id="select">select</div>
   1.303 +  <!-- test abstract structure roles -->
   1.304 +  <div role="section" id="section">section</div>
   1.305 +  <div role="sectionhead" id="sectionhead">sectionhead</div>
   1.306 +
   1.307 +  <!-- roles transformed by ARIA state attributes -->
   1.308 +  <button aria-pressed="true" id="togglebutton">
   1.309 +
   1.310 +  <!-- take the first known mappable role -->
   1.311 +  <div role="wiggly:worm abc123 button" id="unknown_roles">worm button</div>
   1.312 +
   1.313 +  <!-- misc roles -->
   1.314 +  <div role="note" id="note">note</div>
   1.315 +  <div role="scrollbar" id="scrollbar">scrollbar</div>
   1.316 +
   1.317 +  <div id="dir" role="directory">
   1.318 +    <div role="listitem">A</div>
   1.319 +    <div role="listitem">B</div>
   1.320 +    <div role="listitem">C</div>
   1.321 +  </div>
   1.322 +
   1.323 +  <p>Image: 
   1.324 +    <img id="img_eq" role="math" src="foo" alt="x^2 + y^2 + z^2">
   1.325 +  </p>
   1.326 +
   1.327 +  <p>Text: 
   1.328 +    <span id="txt_eq" role="math" title="x^2 + y^2 + z^2">x<sup>2</sup> + 
   1.329 +      y<sup>2</sup> + z<sup>2</sup></span>
   1.330 +
   1.331 +</body>
   1.332 +</html>

mercurial