accessible/tests/mochitest/treeupdate/test_gencontent.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/treeupdate/test_gencontent.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,160 @@
     1.4 +<html>
     1.5 +
     1.6 +<head>
     1.7 +  <title>Elements with CSS generated content</title>
     1.8 +
     1.9 +  <link rel="stylesheet" type="text/css"
    1.10 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.11 +
    1.12 +  <style>
    1.13 +    .gentext:before {
    1.14 +      content: "START"
    1.15 +    }
    1.16 +    .gentext:after {
    1.17 +      content: "END"
    1.18 +    }
    1.19 +  </style>
    1.20 +
    1.21 +  <script type="application/javascript"
    1.22 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.23 +
    1.24 +  <script type="application/javascript"
    1.25 +          src="../common.js"></script>
    1.26 +  <script type="application/javascript"
    1.27 +          src="../role.js"></script>
    1.28 +  <script type="application/javascript"
    1.29 +          src="../events.js"></script>
    1.30 +
    1.31 +  <script type="application/javascript">
    1.32 +
    1.33 +    ////////////////////////////////////////////////////////////////////////////
    1.34 +    // Invokers
    1.35 +    ////////////////////////////////////////////////////////////////////////////
    1.36 +
    1.37 +    /**
    1.38 +     * Insert new node with CSS generated content style applied to container.
    1.39 +     */
    1.40 +    function insertNodeHavingGenContent(aContainerID)
    1.41 +    {
    1.42 +      this.containerNode = getNode(aContainerID);
    1.43 +      this.container = getAccessible(this.containerNode);
    1.44 +
    1.45 +      this.eventSeq = [
    1.46 +        new invokerChecker(EVENT_SHOW, getFirstChild, this.container),
    1.47 +        new invokerChecker(EVENT_REORDER, this.container)
    1.48 +      ];
    1.49 +
    1.50 +      this.invoke = function insertNodeHavingGenContent_invoke()
    1.51 +      {
    1.52 +        var node = document.createElement("div");
    1.53 +        node.textContent = "text";
    1.54 +        node.setAttribute("class", "gentext");
    1.55 +        this.containerNode.appendChild(node);
    1.56 +      }
    1.57 +
    1.58 +      this.finalCheck = function insertNodeHavingGenContent_finalCheck()
    1.59 +      {
    1.60 +        var accTree =
    1.61 +          { SECTION: [ // container
    1.62 +            { SECTION: [ // inserted node
    1.63 +              { STATICTEXT: [] }, // :before
    1.64 +              { TEXT_LEAF: [] }, // primary text
    1.65 +              { STATICTEXT: [] } // :after
    1.66 +            ] }
    1.67 +          ] };
    1.68 +        testAccessibleTree(this.container, accTree);
    1.69 +      }
    1.70 +
    1.71 +      this.getID = function insertNodeHavingGenContent_getID()
    1.72 +      {
    1.73 +        return "insert node having generated content to " + prettyName(aContainerID);
    1.74 +      }
    1.75 +    }
    1.76 +
    1.77 +    /**
    1.78 +     * Add CSS generated content to the given node contained by container node.
    1.79 +     */
    1.80 +    function addGenContent(aContainerID, aNodeID)
    1.81 +    {
    1.82 +      this.container = getAccessible(aContainerID);
    1.83 +      this.node = getNode(aNodeID);
    1.84 +
    1.85 +      this.eventSeq = [
    1.86 +        new invokerChecker(EVENT_HIDE, this.container.firstChild),
    1.87 +        new invokerChecker(EVENT_SHOW, getFirstChild, this.container),
    1.88 +        new invokerChecker(EVENT_REORDER, this.container)
    1.89 +      ];
    1.90 +
    1.91 +      this.invoke = function addGenContent_invoke()
    1.92 +      {
    1.93 +        this.node.setAttribute("class", "gentext");
    1.94 +      }
    1.95 +
    1.96 +      this.finalCheck = function insertNodeHavingGenContent_finalCheck()
    1.97 +      {
    1.98 +        var accTree =
    1.99 +          { SECTION: [ // container
   1.100 +            { SECTION: [ // inserted node
   1.101 +              { STATICTEXT: [] }, // :before
   1.102 +              { TEXT_LEAF: [] }, // primary text
   1.103 +              { STATICTEXT: [] } // :after
   1.104 +            ] }
   1.105 +          ] };
   1.106 +        testAccessibleTree(this.container, accTree);
   1.107 +      }
   1.108 +
   1.109 +      this.getID = function addGenContent_getID()
   1.110 +      {
   1.111 +        return "add generated content to" + prettyName(aNodeID);
   1.112 +      }
   1.113 +    }
   1.114 +
   1.115 +    /**
   1.116 +     * Target getters.
   1.117 +     */
   1.118 +    function getFirstChild(aAcc)
   1.119 +    {
   1.120 +      try { return aAcc.getChildAt(0); }
   1.121 +      catch (e) { return null; }
   1.122 +    }
   1.123 +
   1.124 +    ////////////////////////////////////////////////////////////////////////////
   1.125 +    // Do tests
   1.126 +    ////////////////////////////////////////////////////////////////////////////
   1.127 +
   1.128 +    var gQueue = null;
   1.129 +    //gA11yEventDumpID = "eventdump"; // debug stuff
   1.130 +    //gA11yEventDumpToConsole = true;
   1.131 +
   1.132 +    function doTests()
   1.133 +    {
   1.134 +      gQueue = new eventQueue();
   1.135 +
   1.136 +      gQueue.push(new insertNodeHavingGenContent("container1"));
   1.137 +      gQueue.push(new addGenContent("container2", "container2_child"));
   1.138 +
   1.139 +      gQueue.invoke(); // Will call SimpleTest.finish();
   1.140 +    }
   1.141 +
   1.142 +    SimpleTest.waitForExplicitFinish();
   1.143 +    addA11yLoadEvent(doTests);
   1.144 +  </script>
   1.145 +</head>
   1.146 +
   1.147 +<body>
   1.148 +
   1.149 +  <a target="_blank"
   1.150 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=646350"
   1.151 +     title="Add a test for dynamic chnages of CSS generated content">
   1.152 +    Mozilla Bug 646350</a>
   1.153 +
   1.154 +  <p id="display"></p>
   1.155 +  <div id="content" style="display: none"></div>
   1.156 +  <pre id="test">
   1.157 +  </pre>
   1.158 +  <div id="eventdump"></div>
   1.159 +
   1.160 +  <div id="container1"></div>
   1.161 +  <div id="container2"><div id="container2_child">text</div></div>
   1.162 +</body>
   1.163 +</html>

mercurial