Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: editor/libeditor/tests/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body style="font-family: serif">
<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">
var commandEnabledResults = [
["copy", "false"],
["createlink", "true"],
["cut", "false"],
["delete", "true"],
["fontname", "true"],
["fontsize", "true"],
["formatblock", "true"],
["hilitecolor", "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 = [
["copy", "false"],
["createlink", "false"],
["cut", "false"],
["delete", "false"],
["fontname", "false"],
["fontsize", "false"],
["formatblock", "false"],
["hilitecolor", "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 = [
["copy", "false"],
["createlink", "false"],
["cut", "false"],
["delete", "false"],
["fontname", "false"],
["fontsize", "false"],
["formatblock", "false"],
["hilitecolor", "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 = [
["copy", ""],
["createlink", ""],
["cut", ""],
["delete", ""],
["fontname", "serif"],
["fontsize", ""],
["formatblock", ""],
["hilitecolor", "transparent"],
["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 (let 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>