accessible/tests/mochitest/treeupdate/test_gencontent.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <html>
michael@0 2
michael@0 3 <head>
michael@0 4 <title>Elements with CSS generated content</title>
michael@0 5
michael@0 6 <link rel="stylesheet" type="text/css"
michael@0 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 8
michael@0 9 <style>
michael@0 10 .gentext:before {
michael@0 11 content: "START"
michael@0 12 }
michael@0 13 .gentext:after {
michael@0 14 content: "END"
michael@0 15 }
michael@0 16 </style>
michael@0 17
michael@0 18 <script type="application/javascript"
michael@0 19 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 20
michael@0 21 <script type="application/javascript"
michael@0 22 src="../common.js"></script>
michael@0 23 <script type="application/javascript"
michael@0 24 src="../role.js"></script>
michael@0 25 <script type="application/javascript"
michael@0 26 src="../events.js"></script>
michael@0 27
michael@0 28 <script type="application/javascript">
michael@0 29
michael@0 30 ////////////////////////////////////////////////////////////////////////////
michael@0 31 // Invokers
michael@0 32 ////////////////////////////////////////////////////////////////////////////
michael@0 33
michael@0 34 /**
michael@0 35 * Insert new node with CSS generated content style applied to container.
michael@0 36 */
michael@0 37 function insertNodeHavingGenContent(aContainerID)
michael@0 38 {
michael@0 39 this.containerNode = getNode(aContainerID);
michael@0 40 this.container = getAccessible(this.containerNode);
michael@0 41
michael@0 42 this.eventSeq = [
michael@0 43 new invokerChecker(EVENT_SHOW, getFirstChild, this.container),
michael@0 44 new invokerChecker(EVENT_REORDER, this.container)
michael@0 45 ];
michael@0 46
michael@0 47 this.invoke = function insertNodeHavingGenContent_invoke()
michael@0 48 {
michael@0 49 var node = document.createElement("div");
michael@0 50 node.textContent = "text";
michael@0 51 node.setAttribute("class", "gentext");
michael@0 52 this.containerNode.appendChild(node);
michael@0 53 }
michael@0 54
michael@0 55 this.finalCheck = function insertNodeHavingGenContent_finalCheck()
michael@0 56 {
michael@0 57 var accTree =
michael@0 58 { SECTION: [ // container
michael@0 59 { SECTION: [ // inserted node
michael@0 60 { STATICTEXT: [] }, // :before
michael@0 61 { TEXT_LEAF: [] }, // primary text
michael@0 62 { STATICTEXT: [] } // :after
michael@0 63 ] }
michael@0 64 ] };
michael@0 65 testAccessibleTree(this.container, accTree);
michael@0 66 }
michael@0 67
michael@0 68 this.getID = function insertNodeHavingGenContent_getID()
michael@0 69 {
michael@0 70 return "insert node having generated content to " + prettyName(aContainerID);
michael@0 71 }
michael@0 72 }
michael@0 73
michael@0 74 /**
michael@0 75 * Add CSS generated content to the given node contained by container node.
michael@0 76 */
michael@0 77 function addGenContent(aContainerID, aNodeID)
michael@0 78 {
michael@0 79 this.container = getAccessible(aContainerID);
michael@0 80 this.node = getNode(aNodeID);
michael@0 81
michael@0 82 this.eventSeq = [
michael@0 83 new invokerChecker(EVENT_HIDE, this.container.firstChild),
michael@0 84 new invokerChecker(EVENT_SHOW, getFirstChild, this.container),
michael@0 85 new invokerChecker(EVENT_REORDER, this.container)
michael@0 86 ];
michael@0 87
michael@0 88 this.invoke = function addGenContent_invoke()
michael@0 89 {
michael@0 90 this.node.setAttribute("class", "gentext");
michael@0 91 }
michael@0 92
michael@0 93 this.finalCheck = function insertNodeHavingGenContent_finalCheck()
michael@0 94 {
michael@0 95 var accTree =
michael@0 96 { SECTION: [ // container
michael@0 97 { SECTION: [ // inserted node
michael@0 98 { STATICTEXT: [] }, // :before
michael@0 99 { TEXT_LEAF: [] }, // primary text
michael@0 100 { STATICTEXT: [] } // :after
michael@0 101 ] }
michael@0 102 ] };
michael@0 103 testAccessibleTree(this.container, accTree);
michael@0 104 }
michael@0 105
michael@0 106 this.getID = function addGenContent_getID()
michael@0 107 {
michael@0 108 return "add generated content to" + prettyName(aNodeID);
michael@0 109 }
michael@0 110 }
michael@0 111
michael@0 112 /**
michael@0 113 * Target getters.
michael@0 114 */
michael@0 115 function getFirstChild(aAcc)
michael@0 116 {
michael@0 117 try { return aAcc.getChildAt(0); }
michael@0 118 catch (e) { return null; }
michael@0 119 }
michael@0 120
michael@0 121 ////////////////////////////////////////////////////////////////////////////
michael@0 122 // Do tests
michael@0 123 ////////////////////////////////////////////////////////////////////////////
michael@0 124
michael@0 125 var gQueue = null;
michael@0 126 //gA11yEventDumpID = "eventdump"; // debug stuff
michael@0 127 //gA11yEventDumpToConsole = true;
michael@0 128
michael@0 129 function doTests()
michael@0 130 {
michael@0 131 gQueue = new eventQueue();
michael@0 132
michael@0 133 gQueue.push(new insertNodeHavingGenContent("container1"));
michael@0 134 gQueue.push(new addGenContent("container2", "container2_child"));
michael@0 135
michael@0 136 gQueue.invoke(); // Will call SimpleTest.finish();
michael@0 137 }
michael@0 138
michael@0 139 SimpleTest.waitForExplicitFinish();
michael@0 140 addA11yLoadEvent(doTests);
michael@0 141 </script>
michael@0 142 </head>
michael@0 143
michael@0 144 <body>
michael@0 145
michael@0 146 <a target="_blank"
michael@0 147 href="https://bugzilla.mozilla.org/show_bug.cgi?id=646350"
michael@0 148 title="Add a test for dynamic chnages of CSS generated content">
michael@0 149 Mozilla Bug 646350</a>
michael@0 150
michael@0 151 <p id="display"></p>
michael@0 152 <div id="content" style="display: none"></div>
michael@0 153 <pre id="test">
michael@0 154 </pre>
michael@0 155 <div id="eventdump"></div>
michael@0 156
michael@0 157 <div id="container1"></div>
michael@0 158 <div id="container2"><div id="container2_child">text</div></div>
michael@0 159 </body>
michael@0 160 </html>

mercurial