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