editor/libeditor/base/tests/test_bug408231.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/tests/test_bug408231.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,250 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=408231
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 408231</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408231">Mozilla Bug 408231</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +/** Test for Bug 408231 **/
    1.24 +
    1.25 +    var commandEnabledResults = [
    1.26 +      ["contentReadOnly", "true"],
    1.27 +      ["copy", "false"],
    1.28 +      ["createlink", "true"],
    1.29 +      ["cut", "false"],
    1.30 +      ["decreasefontsize", "true"],
    1.31 +      ["delete", "true"],
    1.32 +      ["fontname", "true"],
    1.33 +      ["fontsize", "true"],
    1.34 +      ["formatblock", "true"],
    1.35 +      ["heading", "true"],
    1.36 +      ["hilitecolor", "true"],
    1.37 +      ["increasefontsize", "true"],
    1.38 +      ["indent", "true"],
    1.39 +      ["inserthorizontalrule", "true"],
    1.40 +      ["inserthtml", "true"],
    1.41 +      ["insertimage", "true"],
    1.42 +      ["insertorderedlist", "true"],
    1.43 +      ["insertunorderedlist", "true"],
    1.44 +      ["insertparagraph", "true"],
    1.45 +      ["italic", "true"],
    1.46 +      ["justifycenter", "true"],
    1.47 +      ["justifyfull", "true"],
    1.48 +      ["justifyleft", "true"],
    1.49 +      ["justifyright", "true"],
    1.50 +      ["outdent", "true"],
    1.51 +      //["paste", "true"],
    1.52 +      ["redo", "false"],
    1.53 +      ["removeformat", "true"],
    1.54 +      ["selectall", "true"],
    1.55 +      ["strikethrough", "true"],
    1.56 +      ["styleWithCSS", "true"],
    1.57 +      ["subscript", "true"],
    1.58 +      ["superscript", "true"],
    1.59 +      ["underline", "true"],
    1.60 +      ["undo", "false"],
    1.61 +      ["unlink", "true"],
    1.62 +      ["not-a-command", "false"]
    1.63 +    ];
    1.64 +
    1.65 +    var commandIndetermResults = [
    1.66 +      ["contentReadOnly", "false"],
    1.67 +      ["copy", "false"],
    1.68 +      ["createlink", "false"],
    1.69 +      ["cut", "false"],
    1.70 +      ["decreasefontsize", "false"],
    1.71 +      ["delete", "false"],
    1.72 +      ["fontname", "false"],
    1.73 +      ["fontsize", "false"],
    1.74 +      ["formatblock", "false"],
    1.75 +      ["heading", "false"],
    1.76 +      ["hilitecolor", "false"],
    1.77 +      ["increasefontsize", "false"],
    1.78 +      ["indent", "false"],
    1.79 +      ["inserthorizontalrule", "false"],
    1.80 +      ["inserthtml", "false"],
    1.81 +      ["insertimage", "false"],
    1.82 +      ["insertorderedlist", "false"],
    1.83 +      ["insertunorderedlist", "false"],
    1.84 +      ["insertparagraph", "false"],
    1.85 +      ["italic", "false"],
    1.86 +      ["justifycenter", "false"],
    1.87 +      ["justifyfull", "false"],
    1.88 +      ["justifyleft", "false"],
    1.89 +      ["justifyright", "false"],
    1.90 +      ["outdent", "false"],
    1.91 +      //["paste", "false"],
    1.92 +      ["redo", "false"],
    1.93 +      ["removeformat", "false"],
    1.94 +      ["selectall", "false"],
    1.95 +      ["strikethrough", "false"],
    1.96 +      ["styleWithCSS", "false"],
    1.97 +      ["subscript", "false"],
    1.98 +      ["superscript", "false"],
    1.99 +      ["underline", "false"],
   1.100 +      ["undo", "false"],
   1.101 +      ["unlink", "false"],
   1.102 +      ["not-a-command", "false"]
   1.103 +    ];
   1.104 +    
   1.105 +    var commandStateResults = [
   1.106 +      ["contentReadOnly", "false"],
   1.107 +      ["copy", "false"],
   1.108 +      ["createlink", "false"],
   1.109 +      ["cut", "false"],
   1.110 +      ["decreasefontsize", "false"],
   1.111 +      ["delete", "false"],
   1.112 +      ["fontname", "false"],
   1.113 +      ["fontsize", "false"],
   1.114 +      ["formatblock", "false"],
   1.115 +      ["heading", "false"],
   1.116 +      ["hilitecolor", "false"],
   1.117 +      ["increasefontsize", "false"],
   1.118 +      ["indent", "false"],
   1.119 +      ["inserthorizontalrule", "false"],
   1.120 +      ["inserthtml", "false"],
   1.121 +      ["insertimage", "false"],
   1.122 +      ["insertorderedlist", "false"],
   1.123 +      ["insertunorderedlist", "false"],
   1.124 +      ["insertparagraph", "false"],
   1.125 +      ["italic", "false"],
   1.126 +      ["justifycenter", "false"],
   1.127 +      ["justifyfull", "false"],
   1.128 +      ["justifyleft", "true"],
   1.129 +      ["justifyright", "false"],
   1.130 +      ["outdent", "false"],
   1.131 +      //["paste", "false"],
   1.132 +      ["redo", "false"],
   1.133 +      ["removeformat", "false"],
   1.134 +      ["selectall", "false"],
   1.135 +      ["strikethrough", "false"],
   1.136 +      ["styleWithCSS", "false"],
   1.137 +      ["subscript", "false"],
   1.138 +      ["superscript", "false"],
   1.139 +      ["underline", "false"],
   1.140 +      ["undo", "false"],
   1.141 +      ["unlink", "false"],
   1.142 +      ["not-a-command", "false"]
   1.143 +    ];
   1.144 +    
   1.145 +    var commandValueResults = [
   1.146 +      ["contentReadOnly", ""],
   1.147 +      ["copy", ""],
   1.148 +      ["createlink", ""],
   1.149 +      ["cut", ""],
   1.150 +      ["decreasefontsize", ""],
   1.151 +      ["delete", ""],
   1.152 +      ["fontname", ""],
   1.153 +      ["fontsize", ""],
   1.154 +      ["formatblock", ""],
   1.155 +      ["heading", ""],
   1.156 +      ["hilitecolor", "transparent"],
   1.157 +      ["increasefontsize", ""],
   1.158 +      ["indent", ""],
   1.159 +      ["inserthorizontalrule", ""],
   1.160 +      ["inserthtml", ""],
   1.161 +      ["insertimage", ""],
   1.162 +      ["insertorderedlist", ""],
   1.163 +      ["insertunorderedlist", ""],
   1.164 +      ["insertparagraph", ""],
   1.165 +      ["italic", ""],
   1.166 +      ["justifycenter", "left"],
   1.167 +      ["justifyfull", "left"],
   1.168 +      ["justifyleft", "left"],
   1.169 +      ["justifyright", "left"],
   1.170 +      ["outdent", ""],
   1.171 +      //["paste", ""],
   1.172 +      ["redo", ""],
   1.173 +      ["removeformat", ""],
   1.174 +      ["selectall", ""],
   1.175 +      ["strikethrough", ""],
   1.176 +      ["styleWithCSS", ""],
   1.177 +      ["subscript", ""],
   1.178 +      ["superscript", ""],
   1.179 +      ["underline", ""],
   1.180 +      ["undo", ""],
   1.181 +      ["unlink", ""],
   1.182 +      ["not-a-command", ""],
   1.183 +    ];
   1.184 +    
   1.185 +  
   1.186 +    function callQueryCommandEnabled(cmdName) {
   1.187 +      var result;
   1.188 +      try {
   1.189 +        result = '' + document.queryCommandEnabled( cmdName );
   1.190 +      } catch( error ) {
   1.191 +        result = 'name' in error ? error.name : 'exception';
   1.192 +      }
   1.193 +      return result;
   1.194 +    }
   1.195 +
   1.196 +    function callQueryCommandIndeterm(cmdName) {
   1.197 +      var result;
   1.198 +      try {
   1.199 +        result = '' + document.queryCommandIndeterm( cmdName );
   1.200 +      } catch( error ) {
   1.201 +        result = 'name' in error ? error.name : 'exception';
   1.202 +      }
   1.203 +      return result;
   1.204 +    }
   1.205 +    
   1.206 +    function callQueryCommandState(cmdName) {
   1.207 +      var result;
   1.208 +      try {
   1.209 +        result = '' + document.queryCommandState( cmdName );
   1.210 +      } catch( error ) {
   1.211 +        result = 'name' in error ? error.name : 'exception';
   1.212 +      }
   1.213 +      return result;
   1.214 +    }
   1.215 +
   1.216 +    function callQueryCommandValue(cmdName) {
   1.217 +      var result;
   1.218 +      try {
   1.219 +        result = '' + document.queryCommandValue( cmdName );
   1.220 +      } catch( error ) {
   1.221 +        result = 'name' in error ? error.name : 'exception';
   1.222 +      }
   1.223 +      return result;    
   1.224 +    }
   1.225 +
   1.226 +    function testQueryCommand(expectedResults, fun, funName) {
   1.227 +      for (i=0; i<expectedResults.length; i++) {
   1.228 +        var commandName = expectedResults[i][0];
   1.229 +        var expectedResult = expectedResults[i][1];
   1.230 +        var result = fun(commandName);
   1.231 +        ok(result == expectedResult, funName + '('+commandName+') result=' +result+ ' expected=' + expectedResult);
   1.232 +      }
   1.233 +    }
   1.234 +
   1.235 +    function runTests() {
   1.236 +      document.designMode='on';
   1.237 +      window.getSelection().collapse(document.body, 0);
   1.238 +      testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled");
   1.239 +      testQueryCommand(commandIndetermResults, callQueryCommandIndeterm, "queryCommandIndeterm");
   1.240 +      testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState");
   1.241 +      testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue");
   1.242 +      document.designMode='off';
   1.243 +      SimpleTest.finish();
   1.244 +    }
   1.245 +    
   1.246 +    window.onload = runTests;
   1.247 +    SimpleTest.waitForExplicitFinish();
   1.248 +
   1.249 +</script>
   1.250 +</pre>
   1.251 +</body>
   1.252 +</html>
   1.253 +

mercurial