Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE html>
2 <html lang="en">
3 <!--
4 BrowserScope richtext2 category tests
6 This test is originally based on the unit test example available as part of the
7 RichText2 suite:
8 http://code.google.com/p/browserscope/source/browse/trunk/categories/richtext2/unittestexample.html
9 -->
10 <head>
11 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
12 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
14 <title>BrowserScope Richtext2 Tests</title>
15 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
16 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
17 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
19 <!-- utility scripts -->
20 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/variables.js"></script>
21 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/canonicalize.js"></script>
22 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/compare.js"></script>
23 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/pad.js"></script>
24 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/range.js"></script>
25 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/units.js"></script>
26 <script type="text/javascript" src="lib/richtext2/richtext2/static/js/run.js"></script>
27 <!-- you do not need static/js/output.js -->
29 <!--
30 Tests - note that those have the extensions .py,
31 but can be used as JS files directly.
32 -->
33 <script type="text/javascript" src="lib/richtext2/richtext2/tests/selection.py"></script>
34 <script type="text/javascript" src="lib/richtext2/richtext2/tests/apply.py"></script>
35 <script type="text/javascript" src="lib/richtext2/richtext2/tests/applyCSS.py"></script>
36 <script type="text/javascript" src="lib/richtext2/richtext2/tests/change.py"></script>
37 <script type="text/javascript" src="lib/richtext2/richtext2/tests/changeCSS.py"></script>
38 <script type="text/javascript" src="lib/richtext2/richtext2/tests/unapply.py"></script>
39 <script type="text/javascript" src="lib/richtext2/richtext2/tests/unapplyCSS.py"></script>
40 <script type="text/javascript" src="lib/richtext2/richtext2/tests/delete.py"></script>
41 <script type="text/javascript" src="lib/richtext2/richtext2/tests/forwarddelete.py"></script>
42 <script type="text/javascript" src="lib/richtext2/richtext2/tests/insert.py"></script>
43 <script type="text/javascript" src="lib/richtext2/richtext2/tests/querySupported.py"></script>
44 <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryEnabled.py"></script>
45 <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryIndeterm.py"></script>
46 <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryState.py"></script>
47 <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryValue.py"></script>
49 <script type="text/javascript" src="lib/richtext2/currentStatus.js"></script>
51 <!-- Do something -->
52 <script type="text/javascript">
53 // Set this constant to true in order to get the current status of the test suite.
54 // This is useful for updating the currentStatus.js file when an editor bug is fixed.
55 const UPDATE_TEST_RESULTS = false;
57 // some tests (at least RTE2-QE_PASTE_TEXT-1) require clipboard data
58 function startTest() {
59 SimpleTest.waitForClipboard("foo",
60 function() {
61 SpecialPowers.clipboardCopyString("foo");
62 },
63 runTest,
64 function() {
65 ok(false, "Failed to copy a string to the clipboard");
66 SimpleTest.finish();
67 }
68 );
69 }
71 function runTest() {
72 initVariables();
73 initEditorDocs();
75 const tests = [
76 SELECTION_TESTS,
77 APPLY_TESTS,
78 APPLY_TESTS_CSS,
79 CHANGE_TESTS,
80 CHANGE_TESTS_CSS,
81 UNAPPLY_TESTS,
82 UNAPPLY_TESTS_CSS,
83 DELETE_TESTS,
84 FORWARDDELETE_TESTS,
85 INSERT_TESTS,
86 QUERYSUPPORTED_TESTS,
87 QUERYENABLED_TESTS,
88 QUERYINDETERM_TESTS,
89 QUERYSTATE_TESTS,
90 QUERYVALUE_TESTS,
91 ];
93 for (var i = 0; i < tests.length; ++i) {
94 runTestSuite(tests[i]);
95 }
97 // Below alert is just a simple demonstration on how to access the test results.
98 // Note that we only ran UNAPPLY tests above, so we have only results from that test set.
99 //
100 // The 'results' structure is as follows:
101 //
102 // results structure containing all results
103 // [<suite ID>] structure containing the results for the given suite *)
104 // .count number of tests in the given suite
105 // .valscore sum of all test value results (HTML or query value)
106 // .selscore sum of all selection results (HTML tests only)
107 // [<class ID>] structure containing the results for the given class **)
108 // .count number of tests in the given suite
109 // .valscore sum of all test value results (HTML or query value)
110 // .selscore sum of all selection results (HTML tests only)
111 // [<test ID>] structure containing the reults for a given test ***)
112 // .valscore value score (0 or 1), minimum over all containers
113 // .selscore selection score (0 or 1), minimum over all containers (HTML tests only)
114 // .valresult worst test value result (integer, see variables.js)
115 // .selresult worst selection result (integer, see variables.js)
116 // [<cont. ID>] structure containing the results of the test for a given container ****)
117 // .valscore value score (0 or 1)
118 // .selscore selection score (0 or 1)
119 // .valresult value result (integer, see variables.js)
120 // .selresult selection result (integer, see variables.js)
121 // .output output string (mainly for use by the online version)
122 // .innerHTML inner HTML of the testing container (<div> or <body>) after the test
123 // .outerHTML outer HTML of the testing container (<div> or <body>) after the test
124 // .bodyInnerHTML inner HTML of the <body> after the test
125 // .bodyOuterHTML outer HTML of the <body> after the test
126 //
127 // *) <suite ID>: a 1-3 character ID, e.g. UNAPPLY_TESTS.id, or 'U' (both referring the same suite)
128 // **) <class ID>: one of 'Proposed', 'RFC' or 'Finalized'
129 // ***) <test ID>: the ID of the test, without the leading 'RTE2-<suite ID>_' part
130 // ****) <container ID>: one of 'div' (test within a <div contenteditable="true">)
131 // 'dM' (test with designMode = 'on')
132 // 'body' (test within a <body contenteditable="true">)
134 if (UPDATE_TEST_RESULTS) {
135 var newKnownFailures = {value: {}, select: {}};
136 for (var i = 0; i < tests.length; ++i) {
137 var category = tests[i];
138 for (var group in results[category.id]) {
139 switch (group) {
140 // Skip the known properties
141 case "count":
142 case "valscore":
143 case "selscore":
144 case "time":
145 break;
146 default:
147 for (var test_id in results[category.id][group]) {
148 switch (test_id) {
149 // Skip the known properties
150 case "count":
151 case "valscore":
152 case "selscore":
153 break;
154 default:
155 for (var structure in results[category.id][group][test_id]) {
156 switch (structure) {
157 // Only look at each test structure
158 case "dM":
159 case "body":
160 case "div":
161 if (!results[category.id][group][test_id][structure].valscore) {
162 newKnownFailures.value[category.id + "-" + group + "-" + test_id + "-" + structure] = true;
163 }
164 if (!results[category.id][group][test_id][structure].selscore) {
165 newKnownFailures.select[category.id + "-" + group + "-" + test_id + "-" + structure] = true;
166 }
167 }
168 }
169 }
170 }
171 }
172 }
173 }
174 var resultContainer = document.getElementById("results");
175 resultContainer.style.display = "";
176 resultContainer.textContent = JSON.stringify(newKnownFailures);
177 } else {
178 for (var i = 0; i < tests.length; ++i) {
179 var category = tests[i];
180 for (var group in results[category.id]) {
181 switch (group) {
182 // Skip the known properties
183 case "count":
184 case "valscore":
185 case "selscore":
186 case "time":
187 break;
188 default:
189 for (var test_id in results[category.id][group]) {
190 switch (test_id) {
191 // Skip the known properties
192 case "count":
193 case "valscore":
194 case "selscore":
195 break;
196 default:
197 for (var structure in results[category.id][group][test_id]) {
198 switch (structure) {
199 // Only look at each test structure
200 case "dM":
201 case "body":
202 case "div":
203 var row = results[category.id][group][test_id][structure];
204 var testName = [category.id, group, test_id, structure].join("-");
205 (testName in knownFailures.value ? todo_is : is)(
206 row.valscore, 1, "Browserscope richtext2 value: " + testName);
207 (testName in knownFailures.select ? todo_is : is)(
208 row.selscore, 1, "Browserscope richtext2 selection: " + testName);
209 }
210 }
211 }
212 }
213 }
214 }
215 }
216 }
218 SimpleTest.finish();
219 }
221 SimpleTest.waitForExplicitFinish();
222 // Running all of the tests can take a long time, try to account for it
223 SimpleTest.requestLongerTimeout(5);
224 </script>
225 </head>
227 <body onload="startTest()">
228 <iframe name="iframe-dM" id="iframe-dM" src="lib/richtext2/richtext2/static/editable-dM.html"></iframe>
229 <iframe name="iframe-body" id="iframe-body" src="lib/richtext2/richtext2/static/editable-body.html"></iframe>
230 <iframe name="iframe-div" id="iframe-div" src="lib/richtext2/richtext2/static/editable-div.html"></iframe>
231 <pre id="results" style="display: none"></pre>
232 </body>
233 </html>