// The <br> after the foobar is unfortunate but is behaviour that hasn't changed in bug 772796.
// FYI: Those tests were ported to join-pre-and-other-block.html
/* 05*/[ "<div>test</div><pre>foobar<br>baz</pre>", "<div>testfoobar</div><pre>baz</pre>", // expected
],
/* 06*/[ "<div>test</div><pre><b>foobar<br>baz</b></pre>", "<div>test<b>foobar</b></div><pre><b>baz</b></pre>", // expected
],
// Some tests with lists. These exercise the MoveBlock "left in right".
/* 65*/[ "<ul><pre><li>test</li>foobar\nbaz</pre></ul>", "<ul><pre><li>testfoobar</li>baz</pre></ul>", // expected
],
/* 66*/[ "<ul><pre><li>test</li><b>foobar\nbaz</b></pre></ul>", "<ul><pre><li>test<b>foobar</b></li><b>baz</b></pre></ul>", // expected
],
/* 67*/[ "<ul><pre><li>test</li><b>foo</b>bar\nbaz</pre></ul>", "<ul><pre><li>test<b>foo</b>bar</li>baz</pre></ul>", // expected
],
/* 68*/[ "<ul><pre><li>test</li><b>foo</b>\nbar</pre></ul>", "<ul><pre><li>test<b>foo</b></li>bar</pre></ul>", // expected
],
/* 69*/[ "<ul><pre><li>test</li><b>foo\n</b>bar\nbaz</pre></ul>", "<ul><pre><li>test<b>foo</b></li>bar\nbaz</pre></ul>", // expected
],
// Last not least, some simple edge case tests.
// FYI: Those tests were ported to join-pre-and-other-block.html
/* 70*/[ "<div>test</div><pre>foobar\n</pre>baz", "<div>testfoobar</div>baz", // expected
],
/* 71*/[ "<div>test</div><pre>\nfoo\nbar</pre>", "<div>testfoo</div><pre>bar</pre>", // expected
],
/* 72*/[ "<div>test</div><pre>\n\nfoo\nbar</pre>", "<div>test</div><pre>foo\nbar</pre>", // expected
],
];
/** Test for Bug 772796 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() { var sel = window.getSelection(); var theEdit = document.getElementById("editable"); var testName; var theDiv;
for (let i = 0; i < tests.length; i++) {
testName = "test" + i.toString();
/* Set up the selection. */
theEdit.innerHTML = "<div id=\"" + testName + "\">" + tests[i][0] + "</div>";
theDiv = document.getElementById(testName);
theDiv.focus();
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
function normalizeStyeAttributeValues(aElement) {
for (const element of Array.from(
aElement.querySelectorAll("[style]")
)) {
element.setAttribute( "style",
element
.getAttribute("style")
// Random spacing differences
.replace(/$/, ";")
.replace(/;;$/, ";")
// Gecko likes "transparent"
.replace(/transparent/g, "rgba(0, 0, 0, 0)")
// WebKit likes to look overly precise
.replace(/, 0.496094\)/g, ", 0.5)")
// Gecko converts anything with full alpha to "transparent" which
// then becomes "rgba(0, 0, 0, 0)", so we have to make other
// browsers match
.replace(/rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/g, "rgba(0, 0, 0, 0)")
);
}
}
let todoCount = 0;
/** First round: Forward delete. **/
synthesizeKey("KEY_Delete");
normalizeStyeAttributeValues(theDiv);
if (tests[i].length == 2 || theDiv.innerHTML == tests[i][1]) {
is(theDiv.innerHTML, tests[i][1], "delete(collapsed): inner HTML for " + testName);
} else {
todoCount++;
todo_is(theDiv.innerHTML, tests[i][1], "delete(should be): inner HTML for " + testName);
is(theDiv.innerHTML, tests[i][2], "delete(currently is): inner HTML for " + testName);
}
/* Set up the selection. */
theEdit.innerHTML = "<div id=\"" + testName + "\">" + tests[i][0] + "</div>";
theDiv = document.getElementById(testName);
theDiv.focus();
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
/** Second round: Backspace. **/
synthesizeKey("KEY_ArrowRight");
synthesizeKey("KEY_Backspace");
normalizeStyeAttributeValues(theDiv);
if (tests[i].length == 2 || theDiv.innerHTML == tests[i][1]) {
is(theDiv.innerHTML, tests[i][1], "backspace: inner HTML for " + testName);
} else {
todoCount++;
todo_is(theDiv.innerHTML, tests[i][1], "backspace(should be): inner HTML for " + testName);
is(theDiv.innerHTML, tests[i][2], "backspace(currently is): inner HTML for " + testName);
}
/* Set up the selection. */
theEdit.innerHTML = "<div id=\"" + testName + "\">" + tests[i][0] + "</div>";
theDiv = document.getElementById(testName);
theDiv.focus();
sel.collapse(theDiv, 0);
synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
/** Third round: Delete with non-collapsed selection. **/
if (i == 72) {
if (tests[i].length == 3) {
ok(!!todoCount, `All tests unexpectedly passed in ${testName}`);
}
// This test doesn't work, since we can't select only one newline using the right arrow key.
continue;
}
synthesizeKey("KEY_ArrowLeft");
/* Strangely enough we need to hit "right arrow" three times to select two characters. */
synthesizeKey("KEY_ArrowRight", {shiftKey: true});
synthesizeKey("KEY_ArrowRight", {shiftKey: true});
synthesizeKey("KEY_ArrowRight", {shiftKey: true});
synthesizeKey("KEY_Delete");
normalizeStyeAttributeValues(theDiv);
/* We always expect to the delete the "tf" in "testfoo". */
function makeNonCollapsedExpectation(aExpected) {
return aExpected
.replace("testfoo", "tesoo")
.replace("test<b>foo", "tes<b>oo")
.replace("test<b style=\"white-space: pre;\">foo", "tes<b style=\"white-space: pre;\">oo")
.replace("test<span style=\"white-space: pre;\">foo", "tes<span style=\"white-space: pre;\">oo")
.replace("test<span style=\"white-space: pre;\"><b>foo", "tes<span style=\"white-space: pre;\"><b>oo")
.replace("test<span style=\"white-space: pre;\"><div>foo", "tes<span style=\"white-space: pre;\"><div>oo")
.replace("test<span class=\"pre\" style=\"white-space: pre;\">foo", "tes<span class=\"pre\" style=\"white-space: pre;\">oo")
.replace("test<span class=\"pre\" style=\"white-space: pre;\"><b>foo", "tes<span class=\"pre\" style=\"white-space: pre;\"><b>oo")
.replace("test<span class=\"pre\" style=\"white-space: pre;\"><div>foo", "tes<span class=\"pre\" style=\"white-space: pre;\"><div>oo");
}
const expected = makeNonCollapsedExpectation(tests[i][1]);
if (tests[i].length == 2 || theDiv.innerHTML == expected) {
is(theDiv.innerHTML, expected, "delete(non-collapsed): inner HTML for " + testName);
} else {
todoCount++;
todo_is(theDiv.innerHTML, expected, "delete(non-collapsed, should be): inner HTML for " + testName);
is(
theDiv.innerHTML,
makeNonCollapsedExpectation(tests[i][2]), "delete(non-collapsed, currently is): inner HTML for " + testName
);
}
if (tests[i].length == 3) {
ok(!!todoCount, `All tests unexpectedly passed in ${testName}`);
}
}
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.32 Sekunden
(vorverarbeitet am 2026-05-02)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.