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