browser/devtools/sourceeditor/test/codemirror.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!doctype html>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta charset="utf-8">
michael@0 5 <title>CodeMirror: Basic Tests</title>
michael@0 6 <link rel="stylesheet" href="chrome://browser/content/devtools/codemirror/codemirror.css">
michael@0 7 <link rel="stylesheet" href="cm_mode_test.css">
michael@0 8 <!--<link rel="stylesheet" href="../doc/docs.css">-->
michael@0 9
michael@0 10 <script src="chrome://browser/content/devtools/codemirror/codemirror.js"></script>
michael@0 11 <script src="chrome://browser/content/devtools/codemirror/searchcursor.js"></script>
michael@0 12 <script src="chrome://browser/content/devtools/codemirror/dialog.js"></script>
michael@0 13 <script src="chrome://browser/content/devtools/codemirror/matchbrackets.js"></script>
michael@0 14 <script src="chrome://browser/content/devtools/codemirror/comment.js"></script>
michael@0 15 <script src="chrome://browser/content/devtools/codemirror/javascript.js"></script>
michael@0 16 <script src="chrome://browser/content/devtools/codemirror/vim.js"></script>
michael@0 17 <script src="chrome://browser/content/devtools/codemirror/emacs.js"></script>
michael@0 18 <script src="chrome://browser/content/devtools/codemirror/sublime.js"></script>
michael@0 19
michael@0 20 <!--<script src="../addon/mode/overlay.js"></script>
michael@0 21 <script src="../addon/mode/multiplex.js"></script>
michael@0 22 <script src="../mode/xml/xml.js"></script>-->
michael@0 23
michael@0 24 <style type="text/css">
michael@0 25 .ok {color: #090;}
michael@0 26 .fail {color: #e00;}
michael@0 27 .error {color: #c90;}
michael@0 28 .done {font-weight: bold;}
michael@0 29 #progress {
michael@0 30 background: #45d;
michael@0 31 color: white;
michael@0 32 text-shadow: 0 0 1px #45d, 0 0 2px #45d, 0 0 3px #45d;
michael@0 33 font-weight: bold;
michael@0 34 white-space: pre;
michael@0 35 }
michael@0 36 #testground {
michael@0 37 visibility: hidden;
michael@0 38 }
michael@0 39 #testground.offscreen {
michael@0 40 visibility: visible;
michael@0 41 position: absolute;
michael@0 42 left: -10000px;
michael@0 43 top: -10000px;
michael@0 44 }
michael@0 45 .CodeMirror { border: 1px solid black; }
michael@0 46 </style>
michael@0 47 </head>
michael@0 48 <body>
michael@0 49 <h1>CodeMirror: Basic Tests</h1>
michael@0 50
michael@0 51 <p>A limited set of programmatic sanity tests for CodeMirror.</p>
michael@0 52
michael@0 53 <div style="border: 1px solid black; padding: 1px; max-width: 700px;">
michael@0 54 <div style="width: 0px;" id=progress><div style="padding: 3px;">Ran <span id="progress_ran">0</span><span id="progress_total"> of 0</span> tests</div></div>
michael@0 55 </div>
michael@0 56 <p id=status>Please enable JavaScript...</p>
michael@0 57 <div id=output></div>
michael@0 58
michael@0 59 <div id=testground></div>
michael@0 60
michael@0 61 <script src="cm_driver.js"></script>
michael@0 62 <script src="cm_test.js"></script>
michael@0 63 <script src="cm_comment_test.js"></script>
michael@0 64 <script src="cm_doc_test.js"></script>
michael@0 65 <script src="cm_driver.js"></script>
michael@0 66 <script src="cm_emacs_test.js"></script>
michael@0 67 <script src="cm_mode_test.js"></script>
michael@0 68 <script src="cm_mode_javascript_test.js"></script>
michael@0 69 <script src="cm_multi_test.js"></script>
michael@0 70 <script src="cm_search_test.js"></script>
michael@0 71
michael@0 72 <!-- VIM and Emacs mode tests are in vimemacs.html
michael@0 73 <script src="cm_sublime_test.js"></script>
michael@0 74 <script src="cm_vim_test.js"></script>
michael@0 75 <script src="cm_emacs_test.js"></script>
michael@0 76 -->
michael@0 77
michael@0 78 <!-- These modes/addons are not used by Editor
michael@0 79 <script src="doc_test.js"></script>
michael@0 80 <script src="../mode/css/css.js"></script>
michael@0 81 <script src="../mode/css/test.js"></script>
michael@0 82 <script src="../mode/css/scss_test.js"></script>
michael@0 83 <script src="../mode/xml/xml.js"></script>
michael@0 84 <script src="../mode/htmlmixed/htmlmixed.js"></script>
michael@0 85 <script src="../mode/ruby/ruby.js"></script>
michael@0 86 <script src="../mode/haml/haml.js"></script>
michael@0 87 <script src="../mode/haml/test.js"></script>
michael@0 88 <script src="../mode/markdown/markdown.js"></script>
michael@0 89 <script src="../mode/markdown/test.js"></script>
michael@0 90 <script src="../mode/gfm/gfm.js"></script>
michael@0 91 <script src="../mode/gfm/test.js"></script>
michael@0 92 <script src="../mode/stex/stex.js"></script>
michael@0 93 <script src="../mode/stex/test.js"></script>
michael@0 94 <script src="../mode/xquery/xquery.js"></script>
michael@0 95 <script src="../mode/xquery/test.js"></script>
michael@0 96 <script src="../addon/mode/multiplex_test.js"></script>-->
michael@0 97
michael@0 98 <script>
michael@0 99 window.onload = runHarness;
michael@0 100 CodeMirror.on(window, 'hashchange', runHarness);
michael@0 101
michael@0 102 function esc(str) {
michael@0 103 return str.replace(/[<&]/, function(ch) { return ch == "<" ? "&lt;" : "&amp;"; });
michael@0 104 }
michael@0 105
michael@0 106 var output = document.getElementById("output"),
michael@0 107 progress = document.getElementById("progress"),
michael@0 108 progressRan = document.getElementById("progress_ran").childNodes[0],
michael@0 109 progressTotal = document.getElementById("progress_total").childNodes[0];
michael@0 110
michael@0 111 var count = 0,
michael@0 112 failed = 0,
michael@0 113 skipped = 0,
michael@0 114 bad = "",
michael@0 115 running = false, // Flag that states tests are running
michael@0 116 quit = false, // Flag to quit tests ASAP
michael@0 117 verbose = false, // Adds message for *every* test to output
michael@0 118 phantom = false;
michael@0 119
michael@0 120 function runHarness(){
michael@0 121 if (running) {
michael@0 122 quit = true;
michael@0 123 setStatus("Restarting tests...", '', true);
michael@0 124 setTimeout(function(){runHarness();}, 500);
michael@0 125 return;
michael@0 126 }
michael@0 127 filters = [];
michael@0 128 verbose = false;
michael@0 129 if (window.location.hash.substr(1)){
michael@0 130 var strings = window.location.hash.substr(1).split(",");
michael@0 131 while (strings.length) {
michael@0 132 var s = strings.shift();
michael@0 133 if (s === "verbose")
michael@0 134 verbose = true;
michael@0 135 else
michael@0 136 filters.push(parseTestFilter(decodeURIComponent(s)));
michael@0 137 }
michael@0 138 }
michael@0 139 quit = false;
michael@0 140 running = true;
michael@0 141 setStatus("Loading tests...");
michael@0 142 count = 0;
michael@0 143 failed = 0;
michael@0 144 skipped = 0;
michael@0 145 bad = "";
michael@0 146 totalTests = countTests();
michael@0 147 progressTotal.nodeValue = " of " + totalTests;
michael@0 148 progressRan.nodeValue = count;
michael@0 149 output.innerHTML = '';
michael@0 150 document.getElementById("testground").innerHTML = "<form>" +
michael@0 151 "<textarea id=\"code\" name=\"code\"></textarea>" +
michael@0 152 "<input type=submit value=ok name=submit>" +
michael@0 153 "</form>";
michael@0 154 runTests(displayTest);
michael@0 155 }
michael@0 156
michael@0 157 function setStatus(message, className, force){
michael@0 158 if (quit && !force) return;
michael@0 159 if (!message) throw("must provide message");
michael@0 160 var status = document.getElementById("status").childNodes[0];
michael@0 161 status.nodeValue = message;
michael@0 162 status.parentNode.className = className;
michael@0 163 }
michael@0 164 function addOutput(name, className, code){
michael@0 165 var newOutput = document.createElement("dl");
michael@0 166 var newTitle = document.createElement("dt");
michael@0 167 newTitle.className = className;
michael@0 168 newTitle.appendChild(document.createTextNode(name));
michael@0 169 newOutput.appendChild(newTitle);
michael@0 170 var newMessage = document.createElement("dd");
michael@0 171 newMessage.innerHTML = code;
michael@0 172 newOutput.appendChild(newTitle);
michael@0 173 newOutput.appendChild(newMessage);
michael@0 174 output.appendChild(newOutput);
michael@0 175 }
michael@0 176 function displayTest(type, name, customMessage) {
michael@0 177 var message = "???";
michael@0 178 if (type != "done" && type != "skipped") ++count;
michael@0 179 progress.style.width = (count * (progress.parentNode.clientWidth - 2) / totalTests) + "px";
michael@0 180 progressRan.nodeValue = count;
michael@0 181 if (type == "ok") {
michael@0 182 message = "Test '" + name + "' succeeded";
michael@0 183 if (!verbose) customMessage = false;
michael@0 184 } else if (type == "skipped") {
michael@0 185 message = "Test '" + name + "' skipped";
michael@0 186 ++skipped;
michael@0 187 if (!verbose) customMessage = false;
michael@0 188 } else if (type == "expected") {
michael@0 189 message = "Test '" + name + "' failed as expected";
michael@0 190 if (!verbose) customMessage = false;
michael@0 191 } else if (type == "error" || type == "fail") {
michael@0 192 ++failed;
michael@0 193 message = "Test '" + name + "' failed";
michael@0 194 } else if (type == "done") {
michael@0 195 if (failed) {
michael@0 196 type += " fail";
michael@0 197 message = failed + " failure" + (failed > 1 ? "s" : "");
michael@0 198 } else if (count < totalTests) {
michael@0 199 failed = totalTests - count;
michael@0 200 type += " fail";
michael@0 201 message = failed + " failure" + (failed > 1 ? "s" : "");
michael@0 202 } else {
michael@0 203 type += " ok";
michael@0 204 message = "All passed";
michael@0 205 if (skipped) {
michael@0 206 message += " (" + skipped + " skipped)";
michael@0 207 }
michael@0 208 }
michael@0 209 progressTotal.nodeValue = '';
michael@0 210 customMessage = true; // Hack to avoid adding to output
michael@0 211 }
michael@0 212 if (window.mozilla_setStatus)
michael@0 213 mozilla_setStatus(message, type, customMessage);
michael@0 214 if (verbose && !customMessage) customMessage = message;
michael@0 215 setStatus(message, type);
michael@0 216 if (customMessage && customMessage.length > 0) {
michael@0 217 addOutput(name, type, customMessage);
michael@0 218 }
michael@0 219 }
michael@0 220 </script>
michael@0 221 </body>
michael@0 222 </html>

mercurial