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