1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/browserscope/test_richtext2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,233 @@ 1.4 +<!DOCTYPE html> 1.5 +<html lang="en"> 1.6 +<!-- 1.7 +BrowserScope richtext2 category tests 1.8 + 1.9 +This test is originally based on the unit test example available as part of the 1.10 +RichText2 suite: 1.11 +http://code.google.com/p/browserscope/source/browse/trunk/categories/richtext2/unittestexample.html 1.12 +--> 1.13 +<head> 1.14 + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 1.15 + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 1.16 + 1.17 + <title>BrowserScope Richtext2 Tests</title> 1.18 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.19 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.20 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.21 + 1.22 + <!-- utility scripts --> 1.23 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/variables.js"></script> 1.24 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/canonicalize.js"></script> 1.25 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/compare.js"></script> 1.26 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/pad.js"></script> 1.27 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/range.js"></script> 1.28 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/units.js"></script> 1.29 + <script type="text/javascript" src="lib/richtext2/richtext2/static/js/run.js"></script> 1.30 + <!-- you do not need static/js/output.js --> 1.31 + 1.32 + <!-- 1.33 + Tests - note that those have the extensions .py, 1.34 + but can be used as JS files directly. 1.35 + --> 1.36 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/selection.py"></script> 1.37 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/apply.py"></script> 1.38 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/applyCSS.py"></script> 1.39 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/change.py"></script> 1.40 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/changeCSS.py"></script> 1.41 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/unapply.py"></script> 1.42 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/unapplyCSS.py"></script> 1.43 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/delete.py"></script> 1.44 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/forwarddelete.py"></script> 1.45 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/insert.py"></script> 1.46 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/querySupported.py"></script> 1.47 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryEnabled.py"></script> 1.48 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryIndeterm.py"></script> 1.49 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryState.py"></script> 1.50 + <script type="text/javascript" src="lib/richtext2/richtext2/tests/queryValue.py"></script> 1.51 + 1.52 + <script type="text/javascript" src="lib/richtext2/currentStatus.js"></script> 1.53 + 1.54 + <!-- Do something --> 1.55 + <script type="text/javascript"> 1.56 + // Set this constant to true in order to get the current status of the test suite. 1.57 + // This is useful for updating the currentStatus.js file when an editor bug is fixed. 1.58 + const UPDATE_TEST_RESULTS = false; 1.59 + 1.60 + // some tests (at least RTE2-QE_PASTE_TEXT-1) require clipboard data 1.61 + function startTest() { 1.62 + SimpleTest.waitForClipboard("foo", 1.63 + function() { 1.64 + SpecialPowers.clipboardCopyString("foo"); 1.65 + }, 1.66 + runTest, 1.67 + function() { 1.68 + ok(false, "Failed to copy a string to the clipboard"); 1.69 + SimpleTest.finish(); 1.70 + } 1.71 + ); 1.72 + } 1.73 + 1.74 + function runTest() { 1.75 + initVariables(); 1.76 + initEditorDocs(); 1.77 + 1.78 + const tests = [ 1.79 + SELECTION_TESTS, 1.80 + APPLY_TESTS, 1.81 + APPLY_TESTS_CSS, 1.82 + CHANGE_TESTS, 1.83 + CHANGE_TESTS_CSS, 1.84 + UNAPPLY_TESTS, 1.85 + UNAPPLY_TESTS_CSS, 1.86 + DELETE_TESTS, 1.87 + FORWARDDELETE_TESTS, 1.88 + INSERT_TESTS, 1.89 + QUERYSUPPORTED_TESTS, 1.90 + QUERYENABLED_TESTS, 1.91 + QUERYINDETERM_TESTS, 1.92 + QUERYSTATE_TESTS, 1.93 + QUERYVALUE_TESTS, 1.94 + ]; 1.95 + 1.96 + for (var i = 0; i < tests.length; ++i) { 1.97 + runTestSuite(tests[i]); 1.98 + } 1.99 + 1.100 + // Below alert is just a simple demonstration on how to access the test results. 1.101 + // Note that we only ran UNAPPLY tests above, so we have only results from that test set. 1.102 + // 1.103 + // The 'results' structure is as follows: 1.104 + // 1.105 + // results structure containing all results 1.106 + // [<suite ID>] structure containing the results for the given suite *) 1.107 + // .count number of tests in the given suite 1.108 + // .valscore sum of all test value results (HTML or query value) 1.109 + // .selscore sum of all selection results (HTML tests only) 1.110 + // [<class ID>] structure containing the results for the given class **) 1.111 + // .count number of tests in the given suite 1.112 + // .valscore sum of all test value results (HTML or query value) 1.113 + // .selscore sum of all selection results (HTML tests only) 1.114 + // [<test ID>] structure containing the reults for a given test ***) 1.115 + // .valscore value score (0 or 1), minimum over all containers 1.116 + // .selscore selection score (0 or 1), minimum over all containers (HTML tests only) 1.117 + // .valresult worst test value result (integer, see variables.js) 1.118 + // .selresult worst selection result (integer, see variables.js) 1.119 + // [<cont. ID>] structure containing the results of the test for a given container ****) 1.120 + // .valscore value score (0 or 1) 1.121 + // .selscore selection score (0 or 1) 1.122 + // .valresult value result (integer, see variables.js) 1.123 + // .selresult selection result (integer, see variables.js) 1.124 + // .output output string (mainly for use by the online version) 1.125 + // .innerHTML inner HTML of the testing container (<div> or <body>) after the test 1.126 + // .outerHTML outer HTML of the testing container (<div> or <body>) after the test 1.127 + // .bodyInnerHTML inner HTML of the <body> after the test 1.128 + // .bodyOuterHTML outer HTML of the <body> after the test 1.129 + // 1.130 + // *) <suite ID>: a 1-3 character ID, e.g. UNAPPLY_TESTS.id, or 'U' (both referring the same suite) 1.131 + // **) <class ID>: one of 'Proposed', 'RFC' or 'Finalized' 1.132 + // ***) <test ID>: the ID of the test, without the leading 'RTE2-<suite ID>_' part 1.133 + // ****) <container ID>: one of 'div' (test within a <div contenteditable="true">) 1.134 + // 'dM' (test with designMode = 'on') 1.135 + // 'body' (test within a <body contenteditable="true">) 1.136 + 1.137 + if (UPDATE_TEST_RESULTS) { 1.138 + var newKnownFailures = {value: {}, select: {}}; 1.139 + for (var i = 0; i < tests.length; ++i) { 1.140 + var category = tests[i]; 1.141 + for (var group in results[category.id]) { 1.142 + switch (group) { 1.143 + // Skip the known properties 1.144 + case "count": 1.145 + case "valscore": 1.146 + case "selscore": 1.147 + case "time": 1.148 + break; 1.149 + default: 1.150 + for (var test_id in results[category.id][group]) { 1.151 + switch (test_id) { 1.152 + // Skip the known properties 1.153 + case "count": 1.154 + case "valscore": 1.155 + case "selscore": 1.156 + break; 1.157 + default: 1.158 + for (var structure in results[category.id][group][test_id]) { 1.159 + switch (structure) { 1.160 + // Only look at each test structure 1.161 + case "dM": 1.162 + case "body": 1.163 + case "div": 1.164 + if (!results[category.id][group][test_id][structure].valscore) { 1.165 + newKnownFailures.value[category.id + "-" + group + "-" + test_id + "-" + structure] = true; 1.166 + } 1.167 + if (!results[category.id][group][test_id][structure].selscore) { 1.168 + newKnownFailures.select[category.id + "-" + group + "-" + test_id + "-" + structure] = true; 1.169 + } 1.170 + } 1.171 + } 1.172 + } 1.173 + } 1.174 + } 1.175 + } 1.176 + } 1.177 + var resultContainer = document.getElementById("results"); 1.178 + resultContainer.style.display = ""; 1.179 + resultContainer.textContent = JSON.stringify(newKnownFailures); 1.180 + } else { 1.181 + for (var i = 0; i < tests.length; ++i) { 1.182 + var category = tests[i]; 1.183 + for (var group in results[category.id]) { 1.184 + switch (group) { 1.185 + // Skip the known properties 1.186 + case "count": 1.187 + case "valscore": 1.188 + case "selscore": 1.189 + case "time": 1.190 + break; 1.191 + default: 1.192 + for (var test_id in results[category.id][group]) { 1.193 + switch (test_id) { 1.194 + // Skip the known properties 1.195 + case "count": 1.196 + case "valscore": 1.197 + case "selscore": 1.198 + break; 1.199 + default: 1.200 + for (var structure in results[category.id][group][test_id]) { 1.201 + switch (structure) { 1.202 + // Only look at each test structure 1.203 + case "dM": 1.204 + case "body": 1.205 + case "div": 1.206 + var row = results[category.id][group][test_id][structure]; 1.207 + var testName = [category.id, group, test_id, structure].join("-"); 1.208 + (testName in knownFailures.value ? todo_is : is)( 1.209 + row.valscore, 1, "Browserscope richtext2 value: " + testName); 1.210 + (testName in knownFailures.select ? todo_is : is)( 1.211 + row.selscore, 1, "Browserscope richtext2 selection: " + testName); 1.212 + } 1.213 + } 1.214 + } 1.215 + } 1.216 + } 1.217 + } 1.218 + } 1.219 + } 1.220 + 1.221 + SimpleTest.finish(); 1.222 + } 1.223 + 1.224 + SimpleTest.waitForExplicitFinish(); 1.225 + // Running all of the tests can take a long time, try to account for it 1.226 + SimpleTest.requestLongerTimeout(5); 1.227 + </script> 1.228 +</head> 1.229 + 1.230 +<body onload="startTest()"> 1.231 + <iframe name="iframe-dM" id="iframe-dM" src="lib/richtext2/richtext2/static/editable-dM.html"></iframe> 1.232 + <iframe name="iframe-body" id="iframe-body" src="lib/richtext2/richtext2/static/editable-body.html"></iframe> 1.233 + <iframe name="iframe-div" id="iframe-div" src="lib/richtext2/richtext2/static/editable-div.html"></iframe> 1.234 + <pre id="results" style="display: none"></pre> 1.235 +</body> 1.236 +</html>