blob: 4f9851f97e4c8b7de5d1b352321a8dc24bc238bb [file] [log] [blame]
<script>
function log(message)
{
var li = document.createElement("li");
li.appendChild(document.createTextNode(message));
var console = document.getElementById("console");
console.appendChild(li);
}
function assert(func, args, expected)
{
var f = func + '("' + args + '")';
var result = eval(f);
if (result != expected)
log('Failure: ' + f + ' was ' + result + ', expected: ' + expected);
else
log('Success: ' + f + ' == ' + result);
}
</script>
<input id="textfield" type="text" style="width: 300" value="hello world">
<ol id="console"></ol>
<script>
if (window.testRunner)
window.testRunner.dumpAsText();
var e = document.getElementById("textfield");
e.focus();
e.setSelectionRange(0, 5);
assert("document.queryCommandEnabled", "BackColor", false);
assert("document.queryCommandEnabled", "Bold", false);
assert("document.queryCommandEnabled", "Copy", true);
assert("document.queryCommandEnabled", "CreateLink", false);
assert("document.queryCommandEnabled", "Cut", true);
assert("document.queryCommandEnabled", "Delete", true);
assert("document.queryCommandEnabled", "FontName", true); // Shouldn't this be false?
assert("document.queryCommandEnabled", "FontSize", true); // Shouldn't this be false?
assert("document.queryCommandEnabled", "FontSizeDelta", true); // Shouldn't this be false?
assert("document.queryCommandEnabled", "ForeColor", false);
assert("document.queryCommandEnabled", "ForwardDelete", true);
assert("document.queryCommandEnabled", "Indent", false);
assert("document.queryCommandEnabled", "InsertHTML", true);
assert("document.queryCommandEnabled", "InsertImage", false);
assert("document.queryCommandEnabled", "InsertLineBreak", true);
assert("document.queryCommandEnabled", "InsertParagraph", true);
assert("document.queryCommandEnabled", "InsertNewlineInQuotedContent", false);
assert("document.queryCommandEnabled", "InsertText", true);
assert("document.queryCommandEnabled", "Italic", false);
assert("document.queryCommandEnabled", "JustifyCenter", false);
assert("document.queryCommandEnabled", "JustifyFull", false);
assert("document.queryCommandEnabled", "JustifyLeft", false);
assert("document.queryCommandEnabled", "JustifyNone", false);
assert("document.queryCommandEnabled", "JustifyRight", false);
assert("document.queryCommandEnabled", "Outdent", false);
assert("document.queryCommandEnabled", "Paste", true);
assert("document.queryCommandEnabled", "PasteAndMatchStyle", true);
assert("document.queryCommandEnabled", "SelectAll", true);
assert("document.queryCommandEnabled", "Strikethrough", false);
assert("document.queryCommandEnabled", "Subscript", false);
assert("document.queryCommandEnabled", "Superscript", false);
assert("document.queryCommandEnabled", "Underline", false);
assert("document.queryCommandEnabled", "Unlink", false);
assert("document.queryCommandEnabled", "Unselect", true);
e.setSelectionRange(3, 3);
assert("document.queryCommandEnabled", "Transpose", true);
e.setSelectionRange(0, 5);
assert("document.execCommand", "Cut", true);
assert("document.queryCommandEnabled", "Undo", true);
assert("document.execCommand", "Undo", true);
assert("document.queryCommandEnabled", "Redo", true);
</script>