зеркало из https://github.com/mozilla/gecko-dev.git
122 строки
4.0 KiB
HTML
122 строки
4.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=430392
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 430392</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=430392">Mozilla Bug 430392</a>
|
|
<p id="display"></p>
|
|
<div id="content">
|
|
<div contenteditable="true" id="edit"> <span contenteditable="false">A</span> ; <span contenteditable="false">B</span> ; <span contenteditable="false">C</span> </div>
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
/** Test for Bug 430392 **/
|
|
|
|
function test() {
|
|
var edit = document.getElementById("edit");
|
|
var html = edit.innerHTML;
|
|
var expectedText = edit.textContent;
|
|
document.getElementById("edit").focus();
|
|
|
|
// Each test is [desc, callback]. callback() is called and we check that the
|
|
// textContent didn't change. For expected failures, the format is [desc,
|
|
// callback, expectedValue], and the test will be marked as an expected fail
|
|
// if the textContent changes to expectedValue, and an unexpected fail if
|
|
// it's neither the original value nor expectedValue.
|
|
var tests = [["adding returns", () => {
|
|
getSelection().collapse(edit.firstChild, 0);
|
|
synthesizeKey("VK_RIGHT", {});
|
|
synthesizeKey("VK_RETURN", {});
|
|
synthesizeKey("VK_RETURN", {});
|
|
synthesizeKey("VK_BACK_SPACE", {});
|
|
synthesizeKey("VK_BACK_SPACE", {});
|
|
// For some reason this test fails if the separator is not "br"
|
|
}, () => document.queryCommandValue("defaultParagraphSeparator") == "br"
|
|
? undefined : " A; B ; C "],
|
|
["adding shift-returns", () => {
|
|
getSelection().collapse(edit.firstChild, 0);
|
|
synthesizeKey("VK_RIGHT", {});
|
|
synthesizeKey("VK_RETURN", {shiftKey: true});
|
|
synthesizeKey("VK_RETURN", {shiftKey: true});
|
|
synthesizeKey("VK_BACK_SPACE", {});
|
|
synthesizeKey("VK_BACK_SPACE", {});
|
|
}, "A ; B ; C "]];
|
|
[
|
|
"insertorderedlist",
|
|
"insertunorderedlist",
|
|
["formatblock", "p"],
|
|
]
|
|
.forEach(item => {
|
|
var cmd = Array.isArray(item) ? item[0] : item;
|
|
var param = Array.isArray(item) ? item[1] : "";
|
|
tests.push([cmd, () => { document.execCommand(cmd, false, param) }]);
|
|
});
|
|
// These are all TODO -- they don't move the non-editable elements
|
|
[
|
|
"bold",
|
|
"italic",
|
|
"underline",
|
|
"strikethrough",
|
|
"subscript",
|
|
"superscript",
|
|
["forecolor", "blue"],
|
|
["backcolor", "blue"],
|
|
["hilitecolor", "blue"],
|
|
["fontname", "monospace"],
|
|
["fontsize", "1"],
|
|
"justifyright",
|
|
"justifycenter",
|
|
"justifyfull"
|
|
]
|
|
.forEach(item => {
|
|
var cmd = Array.isArray(item) ? item[0] : item;
|
|
var param = Array.isArray(item) ? item[1] : "";
|
|
tests.push([cmd, () => { document.execCommand(cmd, false, param) },
|
|
" A ; ; BC "]);
|
|
});
|
|
tests.push(["indent", () => { document.execCommand("indent") },
|
|
" ; ; ABC"]);
|
|
tests.forEach(arr => {
|
|
["div", "br", "p"].forEach(sep => {
|
|
document.execCommand("defaultParagraphSeparator", false, sep);
|
|
|
|
var expectedFailText = typeof arr[2] == "function" ? arr[2]() : arr[2];
|
|
|
|
edit.innerHTML = html;
|
|
edit.focus();
|
|
getSelection().selectAllChildren(edit);
|
|
arr[1]();
|
|
if (typeof expectedFailText != "undefined") {
|
|
todo_is(edit.textContent, expectedText,
|
|
arr[0] + " should not change text (" + sep + ")");
|
|
if (edit.textContent !== expectedText &&
|
|
edit.textContent !== expectedFailText) {
|
|
is(edit.textContent, expectedFailText,
|
|
arr[0] + " changed to different failure (" + sep + ")");
|
|
}
|
|
} else {
|
|
is(edit.textContent, expectedText,
|
|
arr[0] + " should not change text (" + sep + ")");
|
|
}
|
|
});
|
|
});
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
SimpleTest.waitForFocus(test);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|