зеркало из https://github.com/mozilla/gecko-dev.git
251 строка
7.1 KiB
HTML
251 строка
7.1 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 408231</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408231">Mozilla Bug 408231</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
/** Test for Bug 408231 **/
|
|
|
|
var commandEnabledResults = [
|
|
["contentReadOnly", "true"],
|
|
["copy", "false"],
|
|
["createlink", "true"],
|
|
["cut", "false"],
|
|
["decreasefontsize", "true"],
|
|
["delete", "true"],
|
|
["fontname", "true"],
|
|
["fontsize", "true"],
|
|
["formatblock", "true"],
|
|
["heading", "true"],
|
|
["hilitecolor", "true"],
|
|
["increasefontsize", "true"],
|
|
["indent", "true"],
|
|
["inserthorizontalrule", "true"],
|
|
["inserthtml", "true"],
|
|
["insertimage", "true"],
|
|
["insertorderedlist", "true"],
|
|
["insertunorderedlist", "true"],
|
|
["insertparagraph", "true"],
|
|
["italic", "true"],
|
|
["justifycenter", "true"],
|
|
["justifyfull", "true"],
|
|
["justifyleft", "true"],
|
|
["justifyright", "true"],
|
|
["outdent", "true"],
|
|
["paste", "false"],
|
|
["redo", "false"],
|
|
["removeformat", "true"],
|
|
["selectall", "true"],
|
|
["strikethrough", "true"],
|
|
["styleWithCSS", "true"],
|
|
["subscript", "true"],
|
|
["superscript", "true"],
|
|
["underline", "true"],
|
|
["undo", "false"],
|
|
["unlink", "true"],
|
|
["not-a-command", "false"]
|
|
];
|
|
|
|
var commandIndetermResults = [
|
|
["contentReadOnly", "false"],
|
|
["copy", "false"],
|
|
["createlink", "false"],
|
|
["cut", "false"],
|
|
["decreasefontsize", "false"],
|
|
["delete", "false"],
|
|
["fontname", "false"],
|
|
["fontsize", "false"],
|
|
["formatblock", "false"],
|
|
["heading", "false"],
|
|
["hilitecolor", "false"],
|
|
["increasefontsize", "false"],
|
|
["indent", "false"],
|
|
["inserthorizontalrule", "false"],
|
|
["inserthtml", "false"],
|
|
["insertimage", "false"],
|
|
["insertorderedlist", "false"],
|
|
["insertunorderedlist", "false"],
|
|
["insertparagraph", "false"],
|
|
["italic", "false"],
|
|
["justifycenter", "false"],
|
|
["justifyfull", "false"],
|
|
["justifyleft", "false"],
|
|
["justifyright", "false"],
|
|
["outdent", "false"],
|
|
//["paste", "false"],
|
|
["redo", "false"],
|
|
["removeformat", "false"],
|
|
["selectall", "false"],
|
|
["strikethrough", "false"],
|
|
["styleWithCSS", "false"],
|
|
["subscript", "false"],
|
|
["superscript", "false"],
|
|
["underline", "false"],
|
|
["undo", "false"],
|
|
["unlink", "false"],
|
|
["not-a-command", "false"]
|
|
];
|
|
|
|
var commandStateResults = [
|
|
["contentReadOnly", "false"],
|
|
["copy", "false"],
|
|
["createlink", "false"],
|
|
["cut", "false"],
|
|
["decreasefontsize", "false"],
|
|
["delete", "false"],
|
|
["fontname", "false"],
|
|
["fontsize", "false"],
|
|
["formatblock", "false"],
|
|
["heading", "false"],
|
|
["hilitecolor", "false"],
|
|
["increasefontsize", "false"],
|
|
["indent", "false"],
|
|
["inserthorizontalrule", "false"],
|
|
["inserthtml", "false"],
|
|
["insertimage", "false"],
|
|
["insertorderedlist", "false"],
|
|
["insertunorderedlist", "false"],
|
|
["insertparagraph", "false"],
|
|
["italic", "false"],
|
|
["justifycenter", "false"],
|
|
["justifyfull", "false"],
|
|
["justifyleft", "true"],
|
|
["justifyright", "false"],
|
|
["outdent", "false"],
|
|
//["paste", "false"],
|
|
["redo", "false"],
|
|
["removeformat", "false"],
|
|
["selectall", "false"],
|
|
["strikethrough", "false"],
|
|
["styleWithCSS", "false"],
|
|
["subscript", "false"],
|
|
["superscript", "false"],
|
|
["underline", "false"],
|
|
["undo", "false"],
|
|
["unlink", "false"],
|
|
["not-a-command", "false"]
|
|
];
|
|
|
|
var commandValueResults = [
|
|
["contentReadOnly", ""],
|
|
["copy", ""],
|
|
["createlink", ""],
|
|
["cut", ""],
|
|
["decreasefontsize", ""],
|
|
["delete", ""],
|
|
["fontname", "serif"],
|
|
["fontsize", ""],
|
|
["formatblock", ""],
|
|
["heading", ""],
|
|
["hilitecolor", "transparent"],
|
|
["increasefontsize", ""],
|
|
["indent", ""],
|
|
["inserthorizontalrule", ""],
|
|
["inserthtml", ""],
|
|
["insertimage", ""],
|
|
["insertorderedlist", ""],
|
|
["insertunorderedlist", ""],
|
|
["insertparagraph", ""],
|
|
["italic", ""],
|
|
["justifycenter", "left"],
|
|
["justifyfull", "left"],
|
|
["justifyleft", "left"],
|
|
["justifyright", "left"],
|
|
["outdent", ""],
|
|
//["paste", ""],
|
|
["redo", ""],
|
|
["removeformat", ""],
|
|
["selectall", ""],
|
|
["strikethrough", ""],
|
|
["styleWithCSS", ""],
|
|
["subscript", ""],
|
|
["superscript", ""],
|
|
["underline", ""],
|
|
["undo", ""],
|
|
["unlink", ""],
|
|
["not-a-command", ""],
|
|
];
|
|
|
|
|
|
function callQueryCommandEnabled(cmdName) {
|
|
var result;
|
|
try {
|
|
result = '' + document.queryCommandEnabled( cmdName );
|
|
} catch( error ) {
|
|
result = 'name' in error ? error.name : 'exception';
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function callQueryCommandIndeterm(cmdName) {
|
|
var result;
|
|
try {
|
|
result = '' + document.queryCommandIndeterm( cmdName );
|
|
} catch( error ) {
|
|
result = 'name' in error ? error.name : 'exception';
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function callQueryCommandState(cmdName) {
|
|
var result;
|
|
try {
|
|
result = '' + document.queryCommandState( cmdName );
|
|
} catch( error ) {
|
|
result = 'name' in error ? error.name : 'exception';
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function callQueryCommandValue(cmdName) {
|
|
var result;
|
|
try {
|
|
result = '' + document.queryCommandValue( cmdName );
|
|
} catch( error ) {
|
|
result = 'name' in error ? error.name : 'exception';
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function testQueryCommand(expectedResults, fun, funName) {
|
|
for (i=0; i<expectedResults.length; i++) {
|
|
var commandName = expectedResults[i][0];
|
|
var expectedResult = expectedResults[i][1];
|
|
var result = fun(commandName);
|
|
ok(result == expectedResult, funName + '('+commandName+') result=' +result+ ' expected=' + expectedResult);
|
|
}
|
|
}
|
|
|
|
function runTests() {
|
|
document.designMode='on';
|
|
window.getSelection().collapse(document.body, 0);
|
|
testQueryCommand(commandEnabledResults, callQueryCommandEnabled, "queryCommandEnabled");
|
|
testQueryCommand(commandIndetermResults, callQueryCommandIndeterm, "queryCommandIndeterm");
|
|
testQueryCommand(commandStateResults, callQueryCommandState, "queryCommandState");
|
|
testQueryCommand(commandValueResults, callQueryCommandValue, "queryCommandValue");
|
|
document.designMode='off';
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
window.onload = runTests;
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|