tor-browser

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

test_scroll.xhtml (3653B)


      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 
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     10  <script src="chrome://mochikit/content/chrome-harness.js"/>
     11 
     12  <script type="application/javascript"
     13          src="../common.js" />
     14  <script type="application/javascript"
     15          src="../role.js" />
     16  <script type="application/javascript"
     17          src="../states.js" />
     18  <script type="application/javascript"
     19          src="../promisified-events.js" />
     20  <script type="application/javascript"
     21          src="../browser.js"></script>
     22 
     23  <script type="application/javascript">
     24  <![CDATA[
     25 
     26    ////////////////////////////////////////////////////////////////////////////
     27    // Tests
     28 
     29    function matchesAnchorJumpInTabDocument(aTabIdx) {
     30      return evt => {
     31        let tabDoc = aTabIdx ? tabDocumentAt(aTabIdx) : currentTabDocument();
     32        let anchorAcc = getAccessible(tabDoc.querySelector("a[name='link1']"));
     33        return anchorAcc == evt.accessible;
     34      }
     35    }
     36 
     37    function matchesTabDocumentAt(aTabIdx) {
     38      return evt => {
     39        let tabDoc = aTabIdx ? tabDocumentAt(aTabIdx) : currentTabDocument();
     40        return getAccessible(tabDoc) == evt.accessible;
     41      }
     42    }
     43 
     44    async function doTest() {
     45      const kURL = "http://mochi.test:8888/a11y/accessible/tests/mochitest/events/scroll.html#link1";
     46      let evtProm = waitForEvents([
     47        [EVENT_DOCUMENT_LOAD_COMPLETE, currentTabDocument],
     48        [EVENT_SCROLLING_START, matchesAnchorJumpInTabDocument()],
     49      ], "Load foreground tab then scroll to anchor");
     50 
     51      tabBrowser().loadURI(Services.io.newURI(kURL), {
     52        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
     53      });
     54      // Flush layout, so as to guarantee that the a11y tree is constructed.
     55      browserDocument().documentElement.getBoundingClientRect();
     56      await evtProm;
     57 
     58 
     59      evtProm = waitForEvents({
     60        expected: [[EVENT_DOCUMENT_LOAD_COMPLETE, matchesTabDocumentAt(1)]],
     61        unexpected: [[EVENT_SCROLLING_START, matchesAnchorJumpInTabDocument(1)]],
     62      }, "Load background tab, don't dispatch scroll to anchor event");
     63 
     64      tabBrowser().addTab(kURL, {
     65        referrerURI: null,
     66        charset: "",
     67        postData: null,
     68        inBackground: true,
     69        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
     70      });
     71      // Flush layout, so as to guarantee that the a11y tree is constructed.
     72      browserDocument().documentElement.getBoundingClientRect();
     73      await evtProm;
     74 
     75      evtProm = waitForEvent(EVENT_SCROLLING_START,
     76        matchesAnchorJumpInTabDocument(),
     77        "Scroll to anchor event dispatched when switching to loaded doc.");
     78      tabBrowser().selectTabAtIndex(1);
     79      await evtProm;
     80 
     81      closeBrowserWindow();
     82      SimpleTest.finish();
     83    }
     84 
     85    SimpleTest.waitForExplicitFinish();
     86    openBrowserWindow(doTest);
     87  ]]>
     88  </script>
     89 
     90  <vbox flex="1" style="overflow: auto;">
     91    <body xmlns="http://www.w3.org/1999/xhtml">
     92      <a target="_blank"
     93         href="https://bugzilla.mozilla.org/show_bug.cgi?id=691734"
     94         title="Make sure scrolling start event is fired when document receive focus">
     95        Mozilla Bug 691734
     96      </a>
     97 
     98      <p id="display"></p>
     99      <div id="content" style="display: none">
    100      </div>
    101      <pre id="test">
    102      </pre>
    103    </body>
    104 
    105    <vbox id="eventdump"></vbox>
    106  </vbox>
    107 </window>