tor-browser

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

test_tabbrowser.xhtml (12685B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 
      4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
      5                 type="text/css"?>
      6 
      7 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      8        title="Accessible XUL tabbrowser hierarchy tests">
      9 
     10  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     11  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
     12 
     13  <script type="application/javascript"
     14          src="../common.js" />
     15  <script type="application/javascript"
     16          src="../role.js" />
     17  <script type="application/javascript"
     18          src="../events.js" />
     19  <script type="application/javascript"
     20          src="../browser.js"></script>
     21 
     22  <script type="application/javascript">
     23  <![CDATA[
     24    ////////////////////////////////////////////////////////////////////////////
     25    // invoker
     26    function testTabHierarchy()
     27    {
     28      this.eventSeq = [
     29        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 0),
     30        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 1),
     31        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 2),
     32        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 3),
     33        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 4),
     34      ];
     35 
     36      this.invoke = function testTabHierarchy_invoke()
     37      {
     38        const docURIs = [
     39          "about:license",
     40          "about:mozilla",
     41          "about:robots",
     42          "about:about",
     43          "about:credits",
     44        ];
     45        tabBrowser().loadTabs(docURIs, {
     46          inBackground: false,
     47          replace: true,
     48          triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
     49        });
     50 
     51        // SeaMonkey does not support tab groups nor hidden tabs.
     52        if (!SEAMONKEY) {
     53          // Tabs in expanded tab groups should be present in the tab strip
     54          // accessibility tree and the tab  panels accessibility tree.
     55          const tab3 = tabBrowser().tabs[2];
     56          tabBrowser().addTabGroup([tab3], {
     57            label: "Tab Group 1",
     58            insertBefore: tab3
     59          });
     60 
     61          // Tabs in collapsed tab groups should not be present in the tab strip
     62          // accessibility tree but they should be present in the tab panels
     63          // accessibility tree.
     64          const tab4 = tabBrowser().tabs[3];
     65          const tabGroupToCollapse = tabBrowser().addTabGroup([tab4], {
     66            label: "Tab Group 2",
     67            insertBefore: tab4,
     68          });
     69          tabGroupToCollapse.collapsed = true;
     70 
     71          // Hidden tabs should not be present in the tab strip accessibility
     72          // tree but they should be present in the tab panels accessibility
     73          // tree.
     74          const tab5 = tabBrowser().tabs[4];
     75          tabBrowser().hideTab(tab5, "test_tabbrowser.xhtml");
     76        }
     77 
     78        // Flush layout, so as to guarantee that the a11y tree is constructed.
     79        browserDocument().documentElement.getBoundingClientRect();
     80      }
     81 
     82      this.finalCheck = function testTabHierarchy_finalCheck()
     83      {
     84        ////////////////////
     85        // Tab bar
     86        ////////////////////
     87        var tabsAccTree = {
     88          // xul:tabs
     89          role: ROLE_PAGETABLIST,
     90          children: [
     91            // Children depend on application (UI): see below.
     92          ]
     93        };
     94 
     95        // SeaMonkey and Firefox tabbrowser UIs differ.
     96        if (SEAMONKEY) {
     97          SimpleTest.ok(true, "Testing SeaMonkey tabbrowser UI.");
     98 
     99          tabsAccTree.children.push(
    100            {
    101              // xul:toolbarbutton ("Open a new tab")
    102              role: ROLE_PUSHBUTTON,
    103              children: []
    104            },
    105            {
    106              // xul:tab ("about:license")
    107              role: ROLE_PAGETAB,
    108              children: []
    109            },
    110            {
    111              // tab ("about:mozilla")
    112              role: ROLE_PAGETAB,
    113              children: []
    114            },
    115            {
    116              // tab ("about:robots")
    117              role: ROLE_PAGETAB,
    118              children: []
    119            },
    120            {
    121              // tab ("about:meta")
    122              role: ROLE_PAGETAB,
    123              children: []
    124            },
    125            {
    126              // tab ("about:credits")
    127              role: ROLE_PAGETAB,
    128              children: []
    129            },
    130            {
    131              // xul:toolbarbutton ("List all tabs")
    132              role: ROLE_PUSHBUTTON,
    133              children: [
    134                {
    135                  // xul:menupopup
    136                  role: ROLE_MENUPOPUP,
    137                  children: []
    138                }
    139              ]
    140            },
    141            {
    142              // xul:toolbarbutton ("Close current tab")
    143              role: ROLE_PUSHBUTTON,
    144              children: []
    145            }
    146            );
    147        } else {
    148          SimpleTest.ok(true, "Testing Firefox tabbrowser UI.");
    149          let newTabChildren = [];
    150          if (SpecialPowers.getBoolPref("privacy.userContext.enabled")) {
    151            newTabChildren = [
    152              {
    153                role: ROLE_MENUPOPUP,
    154                children: []
    155              }
    156            ];
    157          }
    158 
    159          if (!SpecialPowers.getBoolPref("sidebar.revamp")) {
    160            tabsAccTree.children.push({
    161              role: ROLE_TEXT_CONTAINER,
    162              children: []
    163            });
    164          }
    165 
    166          // NB: The (3) buttons are not visible, unless manually hovered,
    167          //     probably due to size reduction in this test.
    168          tabsAccTree.children.push(
    169            {
    170              // xul:tab ("about:license")
    171              role: ROLE_PAGETAB,
    172              children: [
    173                {
    174                  // xul:text, i.e. the tab label text
    175                  role: ROLE_TEXT_LEAF,
    176                  children: []
    177                },
    178                {
    179                  // xul:toolbarbutton ("Close tab")
    180                  role: ROLE_PUSHBUTTON,
    181                  children: []
    182                }
    183              ]
    184            },
    185            {
    186              // tab ("about:mozilla")
    187              role: ROLE_PAGETAB,
    188              children: [
    189                {
    190                  // xul:text, i.e. the tab label text
    191                  role: ROLE_TEXT_LEAF,
    192                  children: []
    193                },
    194                {
    195                  // xul:toolbarbutton ("Close tab")
    196                  role: ROLE_PUSHBUTTON,
    197                  children: []
    198                }
    199              ]
    200            },
    201            {
    202              // tab group label ("Tab Group 1")
    203              role: ROLE_PUSHBUTTON,
    204              name: "Tab Group 1",
    205            },
    206            {
    207              // tab ("about:robots")
    208              role: ROLE_PAGETAB,
    209              children: [
    210                {
    211                  // xul:text, i.e. the tab label text
    212                  role: ROLE_TEXT_LEAF,
    213                  children: []
    214                },
    215                {
    216                  // xul:toolbarbutton ("Close tab")
    217                  role: ROLE_PUSHBUTTON,
    218                  children: []
    219                }
    220              ]
    221            },
    222            {
    223              // tab group label ("Tab Group 2")
    224              role: ROLE_PUSHBUTTON,
    225              name: "Tab Group 2",
    226            },
    227            {
    228              // xul:toolbarbutton ("Open a new tab")
    229              role: ROLE_PUSHBUTTON,
    230              children: newTabChildren
    231            }
    232            // "List all tabs" dropdown
    233            // XXX: This child(?) is not present in this test.
    234            //      I'm not sure why (though probably expected).
    235            );
    236        }
    237 
    238        testAccessibleTree(tabBrowser().tabContainer, tabsAccTree);
    239 
    240        ////////////////////
    241        // Tab contents
    242        ////////////////////
    243        var tabboxAccTree = {
    244          // xul:tabpanels
    245          role: ROLE_PANE,
    246          children: [
    247            {
    248              // xul:notificationbox
    249              role: ROLE_PROPERTYPAGE,
    250              children: [
    251                {
    252                  // xul:browser
    253                  role: ROLE_INTERNAL_FRAME,
    254                  children: [
    255                    {
    256                      // #document ("about:license")
    257                      role: ROLE_DOCUMENT
    258                      // children: [ ... ] // Ignore document content.
    259                    }
    260                  ]
    261                }
    262              ]
    263            },
    264            {
    265              // notificationbox
    266              role: ROLE_PROPERTYPAGE,
    267              children: [
    268                {
    269                  // browser
    270                  role: ROLE_INTERNAL_FRAME,
    271                  children: [
    272                    {
    273                      // #document ("about:mozilla")
    274                      role: ROLE_DOCUMENT
    275                      // children: [ ... ] // Ignore document content.
    276                    }
    277                  ]
    278                }
    279              ]
    280            },
    281            {
    282              // notificationbox
    283              role: ROLE_PROPERTYPAGE,
    284              children: [
    285                {
    286                  // browser
    287                  role: ROLE_INTERNAL_FRAME,
    288                  children: [
    289                    {
    290                      // #document ("about:robots")
    291                      role: ROLE_DOCUMENT
    292                      // children: [ ... ] // Ignore document content.
    293                    }
    294                  ]
    295                }
    296              ]
    297            },
    298            {
    299              // notificationbox
    300              role: ROLE_PROPERTYPAGE,
    301              children: [
    302                {
    303                  // browser
    304                  role: ROLE_INTERNAL_FRAME,
    305                  children: [
    306                    {
    307                      // #document ("about:meta")
    308                      role: ROLE_DOCUMENT
    309                      // children: [ ... ] // Ignore document content.
    310                    }
    311                  ]
    312                }
    313              ]
    314            },
    315            {
    316              // notificationbox
    317              role: ROLE_PROPERTYPAGE,
    318              children: [
    319                {
    320                  // browser
    321                  role: ROLE_INTERNAL_FRAME,
    322                  children: [
    323                    {
    324                      // #document ("about:credits")
    325                      role: ROLE_DOCUMENT
    326                      // children: [ ... ] // Ignore document content.
    327                    }
    328                  ]
    329                }
    330              ]
    331            },
    332            {
    333              // notificationbox
    334              role: ROLE_PROPERTYPAGE,
    335              children: [
    336                {
    337                  // browser
    338                  role: ROLE_INTERNAL_FRAME,
    339                  children: [
    340                    {
    341                      // #document ("about:newtab" preloaded)
    342                      role: ROLE_DOCUMENT
    343                      // children: [ ... ] // Ignore document content.
    344                    }
    345                  ]
    346                }
    347              ]
    348            }
    349          ]
    350        };
    351 
    352        testAccessibleTree(tabBrowser().tabbox.tabpanels, tabboxAccTree);
    353      }
    354 
    355      this.getID = function testTabHierarchy_getID()
    356      {
    357        return "hierarchy of tabs";
    358      }
    359    }
    360 
    361    ////////////////////////////////////////////////////////////////////////////
    362    // Test
    363    gA11yEventDumpToConsole = true;
    364    //enableLogging("tree,verbose,stack");
    365 
    366    var gQueue = null;
    367    function doTest()
    368    {
    369      SimpleTest.requestCompleteLog();
    370 
    371      // Load documents into tabs and wait for docLoadComplete events caused by these
    372      // documents load before we start the test.
    373      gQueue = new eventQueue();
    374 
    375      gQueue.push(new testTabHierarchy());
    376      gQueue.onFinish = function() { closeBrowserWindow(); }
    377      gQueue.invoke(); // Will call SimpleTest.finish();
    378    }
    379 
    380    SimpleTest.waitForExplicitFinish();
    381    openBrowserWindow(doTest);
    382  ]]>
    383  </script>
    384 
    385  <vbox flex="1" style="overflow: auto;">
    386    <body xmlns="http://www.w3.org/1999/xhtml">
    387      <a target="_blank"
    388         href="https://bugzilla.mozilla.org/show_bug.cgi?id=540389"
    389         title=" WARNING: Bad accessible tree!: [tabbrowser tab] ">
    390        Mozilla Bug 540389
    391      </a><br/>
    392      <a target="_blank"
    393         href="https://bugzilla.mozilla.org/show_bug.cgi?id=552944"
    394         title="No relationship between tabs and associated property page in new tabbrowser construct">
    395        Mozilla Bug 552944
    396      </a><br/>
    397      <p id="display"></p>
    398      <div id="content" style="display: none">
    399      </div>
    400      <pre id="test">
    401      </pre>
    402    </body>
    403 
    404    <vbox id="eventdump"></vbox>
    405  </vbox>
    406 
    407 </window>