tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_general.xhtml (13030B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
      4                 type="text/css"?>
      5 
      6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      7        xmlns:html="http://www.w3.org/1999/xhtml"
      8        title="Accessibility Name Calculating Test.">
      9 
     10  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     11  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
     12 
     13  <script type="application/javascript"
     14          src="../common.js"></script>
     15  <script type="application/javascript"
     16          src="../role.js"></script>
     17  <script type="application/javascript"
     18          src="../name.js"></script>
     19  <script src="../promisified-events.js"></script>
     20 
     21  <script type="application/javascript">
     22  <![CDATA[
     23    async function doTest()
     24    {
     25      // aria-label
     26 
     27      // Simple label provided via ARIA
     28      testName("btn_simple_aria_label", "I am a button");
     29 
     30      // aria-label and aria-labelledby, expect aria-labelledby
     31      testName("btn_both_aria_labels", "text I am a button, two");
     32 
     33      //////////////////////////////////////////////////////////////////////////
     34      // aria-labelledby
     35 
     36      // Single relation. The value of 'aria-labelledby' contains the ID of
     37      // an element. Gets the name from text node of that element.
     38      testName("btn_labelledby_text", "text");
     39 
     40      // Multiple relations. The value of 'aria-labelledby' contains the IDs
     41      // of elements. Gets the name from text nodes of those elements.
     42      testName("btn_labelledby_texts", "text1 text2");
     43 
     44      // Trick cases. Self and recursive referencing.
     45      testName("rememberHistoryDays", "Remember 3 days");
     46      testName("historyDays", "Remember days");
     47      testName("rememberAfter", "days");
     48 
     49      //////////////////////////////////////////////////////////////////////////
     50      // Name from subtree (single relation labelled_by).
     51 
     52      // Gets the name from text nodes contained by nested elements.
     53      testName("btn_labelledby_mixed", "no more text");
     54 
     55      // Gets the name from text nodes and selected item of menulist
     56      // (other items are ignored).
     57      testName("btn_labelledby_mixed_menulist",
     58               "no more text selected item more text");
     59 
     60      // Gets the name from text nodes contained by nested elements, ignores
     61      // hidden elements (bug 443081).
     62      testName("btn_labelledby_mixed_hidden_child", "no more text2");
     63 
     64      // Gets the name from hidden text nodes contained by nested elements,
     65      // (label element is hidden entirely), (bug 443081)
     66      testName("btn_labelledby_mixed_hidden", "lala more hidden text");
     67 
     68 
     69      //////////////////////////////////////////////////////////////////////////
     70      // Name from @label attribute.
     71 
     72      // Gets the name from @label attribute.
     73      testName("btn_labelattr", "labeled element");
     74 
     75 
     76      //////////////////////////////////////////////////////////////////////////
     77      // Name for nsIDOMXULSelectControlItemElement.
     78 
     79      // Gets the name from @label attribute.
     80      testName("li_nsIDOMXULSelectControlItemElement", "select control item");
     81 
     82 
     83      //////////////////////////////////////////////////////////////////////////
     84      // Name if the XUL element doesn't implement nsIDOMXULSelectControlElement
     85      // and has @label attribute.
     86 
     87      testName("box_not_nsIDOMXULSelectControlElement", "box");
     88 
     89 
     90      //////////////////////////////////////////////////////////////////////////
     91      // Name from the label element.
     92 
     93      // The label and button are placed on 2nd level relative common parent.
     94      testName("btn_label_1", "label1");
     95 
     96      // The label is on 1st, the button is on 5th level relative common parent.
     97      testName("btn_label_2", "label2");
     98 
     99      // The label and button are siblings.
    100      testName("btn_label_3", "label3");
    101 
    102      // Multiple labels for single button: XUL button takes the last one.
    103      testName("btn_label_4", "label5");
    104 
    105      // Label associated with HTML element.
    106      testName("input_label", "input label");
    107 
    108 
    109      //////////////////////////////////////////////////////////////////////////
    110      // tooltiptext (if nothing above isn't presented then tooltiptext is used)
    111      testName("box_tooltiptext", "tooltiptext label");
    112 
    113 
    114      //////////////////////////////////////////////////////////////////////////
    115      // Name from the @title attribute of <toolbaritem/> (original bug 237249).
    116 
    117      // Direct child of toolbaritem.
    118      testName("toolbaritem_child", null);
    119 
    120      // Child from subtree of toolbaritem.
    121      testName("toolbaritem_hboxbutton", "button");
    122 
    123 
    124      //////////////////////////////////////////////////////////////////////////
    125      // name from label inside toolbar button
    126      testName("toolbarbuttonwithlabel", "I am the button");
    127 
    128 
    129      //////////////////////////////////////////////////////////////////////////
    130      // Name from children
    131 
    132      // ARIA role button is presented allowing the name calculation from
    133      // children.
    134      testName("box_children", "14");
    135 
    136      // Button labelled by a text child.
    137      testName("button_text", "Text");
    138      testName("toolbarbutton_text", "Text");
    139 
    140      // ARIA role option is presented allowing the name calculation from
    141      // the visible children (bug 443081)
    142      testName("lb_opt1_children_hidden", "i am visible");
    143 
    144 
    145      //////////////////////////////////////////////////////////////////////////
    146      // Name from aria-labelledby: menuitem label+ listitem label
    147      testName("li_labelledby", "Show an Alert The moment the event starts");
    148 
    149      //////////////////////////////////////////////////////////////////////////
    150      // groupbox labeling from first label
    151      testName("groupbox", "Some caption");
    152 
    153      //////////////////////////////////////////////////////////////////////////
    154      // menuitem tests
    155      const menu = getNode("menu");
    156      info("Opening menu");
    157      let opened = waitForEvent(EVENT_MENUPOPUP_START, menu);
    158      menu.openPopup(null, "after_start", 0, 0, true, false, null);
    159      await opened;
    160      testName("menuitemLabel", "menuitemLabel");
    161      testName("menuitemAriaLabel", "menuitemAriaLabel");
    162      testName("menuitemLabelBadge", "menuitemLabelBadge New");
    163      testName("menuitemAriaLabelBadge", "menuitemAriaLabelBadge New");
    164      info("Closing menu");
    165      let closed = waitForEvent(EVENT_MENUPOPUP_END, menu);
    166      synthesizeKey("KEY_Escape");
    167      await closed;
    168 
    169      SimpleTest.finish();
    170    }
    171 
    172    SimpleTest.waitForExplicitFinish();
    173    addA11yLoadEvent(doTest);
    174  ]]>
    175  </script>
    176 
    177  <hbox flex="1" style="overflow: auto;">
    178 
    179  <body xmlns="http://www.w3.org/1999/xhtml">
    180    <a target="_blank"
    181       href="https://bugzilla.mozilla.org/show_bug.cgi?id=444279"
    182       title="mochitest for accessible name calculating">
    183      Mozilla Bug 444279
    184    </a>
    185    <a target="_blank"
    186      href="https://bugzilla.mozilla.org/show_bug.cgi?id=441991"
    187      title="nsXULListitemAccessible::GetName prefers label \
    188      		   attribute over aria-labelledby and doesn't allow recursion">
    189      Mozilla Bug 441991
    190    </a>
    191  <p id="display"></p>
    192    <div id="content" style="display: none">
    193    </div>
    194    <pre id="test">
    195    </pre>
    196  </body>
    197 
    198  <vbox flex="1">
    199 
    200  <!-- aria-label, simple label -->
    201  <button id="btn_simple_aria_label" aria-label="I am a button"/>
    202 
    203  <!-- aria-label plus aria-labelledby -->
    204  <button id="btn_both_aria_labels" aria-label="I am a button, two"
    205          aria-labelledby="labelledby_text btn_both_aria_labels"/>
    206 
    207  <!-- aria-labelledby, single relation -->
    208  <description id="labelledby_text">text</description>
    209  <button id="btn_labelledby_text"
    210          aria-labelledby="labelledby_text"/>
    211 
    212  <!-- aria-labelledby, multiple relations -->
    213  <description id="labelledby_text1">text1</description>
    214  <description id="labelledby_text2">text2</description>
    215  <button id="btn_labelledby_texts"
    216          aria-labelledby="labelledby_text1 labelledby_text2"/>
    217 
    218  <!-- trick aria-labelledby -->
    219  <checkbox id="rememberHistoryDays"
    220            label="Remember "
    221            aria-labelledby="rememberHistoryDays historyDays rememberAfter"/>
    222  <html:input id="historyDays" value="3"
    223              aria-labelledby="rememberHistoryDays historyDays rememberAfter"/>
    224  <label id="rememberAfter">days</label>
    225 
    226  <!-- the name from subtree, mixed content -->
    227  <description id="labelledby_mixed">
    228    no<description>more text</description>
    229  </description>
    230  <button id="btn_labelledby_mixed"
    231          aria-labelledby="labelledby_mixed"/>
    232 
    233  <!-- the name from subtree, mixed/hidden content -->
    234  <description id="labelledby_mixed_hidden_child">no<description>more <description hidden="true">hidden</description>text2</description></description>
    235  <button id="btn_labelledby_mixed_hidden_child"
    236          aria-labelledby="labelledby_mixed_hidden_child"/>
    237 
    238  <!-- the name from subtree, mixed/completely hidden content -->
    239  <description id="labelledby_mixed_hidden"
    240               hidden="true">lala <description>more hidden </description>text</description>
    241  <button id="btn_labelledby_mixed_hidden"
    242          aria-labelledby="labelledby_mixed_hidden"/>
    243  <br/>
    244 
    245  <!-- the name from subtree, mixed content, ignore items of menulist -->
    246  <description id="labelledby_mixed_menulist">
    247    no<description>more text</description>
    248    <menulist>
    249      <menupopup>
    250        <menuitem label="selected item"/>
    251        <menuitem label="item"/>
    252      </menupopup>
    253    </menulist>
    254    more text
    255  </description>
    256  <button id="btn_labelledby_mixed_menulist"
    257          aria-labelledby="labelledby_mixed_menulist"/>
    258 
    259  <!-- @label -->
    260  <button id="btn_labelattr"
    261          label="labeled element"/>
    262 
    263  <!-- nsIDOMXULSelectControlItemElement -->
    264  <richlistbox>
    265    <richlistitem id="li_nsIDOMXULSelectControlItemElement">
    266      <label value="select control item"/>
    267    </richlistitem>
    268  </richlistbox>
    269 
    270  <!-- not nsIDOMXULSelectControlElement -->
    271  <box id="box_not_nsIDOMXULSelectControlElement" role="group" label="box"/>
    272 
    273  <!-- label element  -->
    274  <hbox>
    275    <box>
    276      <label control="btn_label_1">label1</label>
    277    </box>
    278    <label control="btn_label_2">label2</label>
    279    <box>
    280      <button id="btn_label_1"/>
    281      <box>
    282        <box>
    283          <box>
    284            <button id="btn_label_2"/>
    285          </box>
    286        </box>
    287      </box>
    288    </box>
    289    <label control="btn_label_3">label3</label>
    290    <button id="btn_label_3"/>
    291 
    292    <label control="btn_label_4">label4</label>
    293    <label control="btn_label_4">label5</label>
    294    <button id="btn_label_4"/>
    295 
    296    <label control="input_label">input label</label>
    297    <html:input id="input_label"/>
    298  </hbox>
    299 
    300  <!-- tooltiptext -->
    301  <box id="box_tooltiptext"
    302       role="group"
    303       tooltiptext="tooltiptext label"/>
    304 
    305  <!-- the name from @title of toolbaritem -->
    306  <!-- and the name from label of a toolbarbutton -->
    307  <toolbar>
    308    <toolbaritem title="ooospspss">
    309      <box id="toolbaritem_child"
    310           role="group"
    311           flex="1">
    312        <hbox role="button" id="toolbaritem_hboxbutton">
    313          <description value="button"/>
    314        </hbox>
    315      </box>
    316    </toolbaritem>
    317    <toolbarbutton id="toolbarbuttonwithlabel">
    318      <label flex="1">I am the button</label>
    319    </toolbarbutton>
    320  </toolbar>
    321 
    322  <!-- name from children -->
    323  <box id="box_children" role="button">14</box>
    324  <button id="button_text">Text</button>
    325  <toolbarbutton id="toolbarbutton_text">Text</toolbarbutton>
    326 
    327  <!-- name from children, hidden children -->
    328  <vbox role="listbox" tabindex="0">
    329    <hbox id="lb_opt1_children_hidden" role="option" tabindex="0">
    330      <description>i am visible</description>
    331      <description style="display:none">i am hidden</description>
    332    </hbox>
    333 
    334    <!-- Name from caption sub tree -->
    335    <groupbox id="groupbox">
    336      <label>Some caption</label>
    337      <checkbox label="some checkbox label" />
    338    </groupbox>
    339  </vbox>
    340 
    341  <!-- bug 441991; create name from other menuitem label listitem's own label -->
    342  <hbox>
    343    <richlistbox>
    344      <richlistitem id="li_labelledby"
    345                    aria-labelledby="menuitem-DISPLAY li_labelledby">
    346        <label value="The moment the event starts"/>
    347      </richlistitem>
    348    </richlistbox>
    349    <menulist>
    350      <menupopup>
    351        <menuitem id="menuitem-DISPLAY"
    352                  value="DISPLAY"
    353                  label="Show an Alert"/>
    354        <menuitem id="menuitem-EMAIL"
    355                  value="EMAIL"
    356                  label="Send an E-mail"/>
    357      </menupopup>
    358    </menulist>
    359  </hbox>
    360 
    361  <menupopup id="menu">
    362    <menuitem id="menuitemLabel" label="menuitemLabel"/>
    363    <menuitem id="menuitemAriaLabel" aria-label="menuitemAriaLabel"/>
    364    <menuitem id="menuitemLabelBadge" label="menuitemLabelBadge" badge="New"/>
    365    <menuitem id="menuitemAriaLabelBadge" aria-label="menuitemAriaLabelBadge" badge="New"/>
    366  </menupopup>
    367 
    368  </vbox> <!-- close tests area -->
    369  </hbox> <!-- close main area -->
    370 </window>