tor-browser

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

test_dynamic.html (2586B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <title>nsIAccessibleText getText related function tests for tree mutations</title>
      5  <link rel="stylesheet" type="text/css"
      6        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
      7 
      8  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      9  <script type="application/javascript"
     10          src="../common.js"></script>
     11  <script type="application/javascript"
     12          src="../text.js"></script>
     13  <script type="application/javascript"
     14          src="../events.js"></script>
     15 
     16  <script type="application/javascript">
     17    function insertBefore(aId, aEl, aTextBefore, aTextAfter, aStartIdx, aEndIdx) {
     18      this.eventSeq = [
     19        new invokerChecker(EVENT_REORDER, aId),
     20      ];
     21 
     22      this.invoke = function insertBefore_invoke() {
     23        testText(aId, 0, -1, aTextBefore);
     24        getNode(aId).insertBefore(aEl, getNode(aId).firstChild);
     25      };
     26 
     27      this.finalCheck = function insertBefore_finalCheck() {
     28        testText(aId, aStartIdx, aEndIdx, aTextAfter);
     29      };
     30 
     31      this.getID = function insertTextBefore_getID() {
     32        return "insert " + prettyName(aEl) + " before";
     33      };
     34    }
     35 
     36    function insertTextBefore(aId, aTextBefore, aText) {
     37      var el = document.createTextNode(aText);
     38      this.__proto__ = new insertBefore(aId, el, aTextBefore,
     39                                        aText + aTextBefore, 0, -1);
     40    }
     41 
     42    function insertImgBefore(aId, aTextBefore) {
     43      var el = document.createElement("img");
     44      el.setAttribute("src", "../moz.png");
     45      el.setAttribute("alt", "mozilla");
     46 
     47      this.__proto__ = new insertBefore(aId, el, aTextBefore,
     48                                        kEmbedChar + aTextBefore, 0, -1);
     49    }
     50 
     51    function insertTextBefore2(aId) {
     52      var el = document.createTextNode("hehe");
     53      this.__proto__ = new insertBefore(aId, el, "ho", "ho", 4, -1);
     54    }
     55 
     56    var gQueue = null;
     57    function doTest() {
     58      gQueue = new eventQueue();
     59      gQueue.push(new insertTextBefore("c1", "ho", "ha"));
     60      gQueue.push(new insertImgBefore("c1", "haho"));
     61      gQueue.push(new insertImgBefore("c2", kEmbedChar));
     62      gQueue.push(new insertTextBefore2("c3"));
     63      gQueue.invoke(); // will call SimpleTest.finish();
     64    }
     65 
     66    SimpleTest.waitForExplicitFinish();
     67    addA11yLoadEvent(doTest);
     68  </script>
     69 </head>
     70 <body>
     71  <p id="display"></p>
     72  <div id="content" style="display: none"></div>
     73  <pre id="test">
     74  </pre>
     75 
     76  <div id="c1">ho</div>
     77  <div id="c2"><img src="../moz.png" alt="mozilla"></div>
     78  <div id="c3">ho</div>
     79 </body>
     80 </html>