editor/libeditor/html/tests/browserscope/test_richtext2.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial