unittestexample.html (6249B)
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 6 7 <title>Rich Text 2 Unit Test Example</title> 8 9 <!-- utility scripts --> 10 <script type="text/javascript" src="static/js/variables.js"></script> 11 <script type="text/javascript" src="static/js/canonicalize.js"></script> 12 <script type="text/javascript" src="static/js/compare.js"></script> 13 <script type="text/javascript" src="static/js/pad.js"></script> 14 <script type="text/javascript" src="static/js/range.js"></script> 15 <script type="text/javascript" src="static/js/units.js"></script> 16 <script type="text/javascript" src="static/js/run.js"></script> 17 <!-- you do not need static/js/output.js --> 18 19 <!-- 20 Tests - note that those have the extensions .py, 21 but can be used as JS files directly. 22 --> 23 <script type="text/javascript" src="tests/selection.py"></script> 24 <script type="text/javascript" src="tests/apply.py"></script> 25 <script type="text/javascript" src="tests/applyCSS.py"></script> 26 <script type="text/javascript" src="tests/change.py"></script> 27 <script type="text/javascript" src="tests/changeCSS.py"></script> 28 <script type="text/javascript" src="tests/unapply.py"></script> 29 <script type="text/javascript" src="tests/unapplyCSS.py"></script> 30 <script type="text/javascript" src="tests/delete.py"></script> 31 <script type="text/javascript" src="tests/forwarddelete.py"></script> 32 <script type="text/javascript" src="tests/insert.py"></script> 33 <script type="text/javascript" src="tests/querySupported.py"></script> 34 <script type="text/javascript" src="tests/queryEnabled.py"></script> 35 <script type="text/javascript" src="tests/queryIndeterm.py"></script> 36 <script type="text/javascript" src="tests/queryState.py"></script> 37 <script type="text/javascript" src="tests/queryValue.py"></script> 38 39 <!-- Do something --> 40 <script type="text/javascript"> 41 function runTest() { 42 initVariables(); 43 initEditorDocs(); 44 45 runTestSuite(UNAPPLY_TESTS); 46 47 // Below alert is just a simple demonstration on how to access the test results. 48 // Note that we only ran UNAPPLY tests above, so we have only results from that test set. 49 // 50 // The 'results' structure is as follows: 51 // 52 // results structure containing all results 53 // [<suite ID>] structure containing the results for the given suite *) 54 // .count number of tests in the given suite 55 // .valscore sum of all test value results (HTML or query value) 56 // .selscore sum of all selection results (HTML tests only) 57 // [<class ID>] structure containing the results for the given class **) 58 // .count number of tests in the given suite 59 // .valscore sum of all test value results (HTML or query value) 60 // .selscore sum of all selection results (HTML tests only) 61 // [<test ID>] structure containing the reults for a given test ***) 62 // .valscore value score (0 or 1), minimum over all containers 63 // .selscore selection score (0 or 1), minimum over all containers (HTML tests only) 64 // .valresult worst test value result (integer, see variables.js) 65 // .selresult worst selection result (integer, see variables.js) 66 // [<cont. ID>] structure containing the results of the test for a given container ****) 67 // .valscore value score (0 or 1) 68 // .selscore selection score (0 or 1) 69 // .valresult value result (integer, see variables.js) 70 // .selresult selection result (integer, see variables.js) 71 // .output output string (mainly for use by the online version) 72 // .innerHTML inner HTML of the testing container (<div> or <body>) after the test 73 // .outerHTML outer HTML of the testing container (<div> or <body>) after the test 74 // .bodyInnerHTML inner HTML of the <body> after the test 75 // .bodyOuterHTML outer HTML of the <body> after the test 76 // 77 // *) <suite ID>: a 1-3 character ID, e.g. UNAPPLY_TESTS.id, or 'U' (both referring the same suite) 78 // **) <class ID>: one of 'Proposed', 'RFC' or 'Finalized' 79 // ***) <test ID>: the ID of the test, without the leading 'RTE2-<suite ID>_' part 80 // ****) <container ID>: one of 'div' (test within a <div contenteditable="true">) 81 // 'dM' (test with designMode = 'on') 82 // 'body' (test within a <body contenteditable="true">) 83 84 alert("Result of 'Apply' tests:\nOut of " + 85 results[UNAPPLY_TESTS.id].count + " tests\n" + 86 results[UNAPPLY_TESTS.id].valscore + " had correct HTML, and\n" + 87 results[UNAPPLY_TESTS.id].selscore + " had a correct result selection\n(in all testing containers)." + 88 "\n\n" + 89 "Test RTE2-U_B_B-1_SW results with a contenteditable <body>:\n" + 90 results['U']['Proposed']['B_B-1_SW']['body'].valscore + " points for the value result, and\n" + 91 results['U']['Proposed']['B_B-1_SW']['body'].selscore + " points for the selection" + 92 "" 93 ); 94 } 95 </script> 96 </head> 97 98 <body onload="runTest()"> 99 <iframe name="iframe-dM" id="iframe-dM" src="static/editable-dM.html"></iframe> 100 <iframe name="iframe-body" id="iframe-body" src="static/editable-body.html"></iframe> 101 <iframe name="iframe-div" id="iframe-div" src="static/editable-div.html"></iframe> 102 </body> 103 </html>