зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1355886 - fix regression when undoing delete node next to a whitespace sibling;r=pbro
MozReview-Commit-ID: GDYzsbCiQcI --HG-- extra : rebase_source : 731b51aa56a31f9cc8e65628bc158278c2287582
This commit is contained in:
Родитель
1c24f24b92
Коммит
7500121261
|
@ -11,26 +11,20 @@
|
|||
const HTML =
|
||||
`<div>
|
||||
<p id="container">
|
||||
<span>1</span> <span id="after-whitespace">2</span>
|
||||
<span id="before-whitespace">1</span> <span id="after-whitespace">2</span>
|
||||
</p>
|
||||
</div>`;
|
||||
|
||||
const TEST_URL = "data:text/html;charset=utf-8," + encodeURIComponent(HTML);
|
||||
|
||||
add_task(function* () {
|
||||
add_task(function* deleteNodeAfterWhitespace() {
|
||||
let {inspector} = yield openInspectorForURL(TEST_URL);
|
||||
|
||||
info("Test deleting a node that will modify the whitespace nodes rendered in the " +
|
||||
"markup view.");
|
||||
|
||||
info("Select node #after-whitespace and make sure it is focused");
|
||||
yield selectNode("#after-whitespace", inspector);
|
||||
yield clickContainer("#after-whitespace", inspector);
|
||||
|
||||
info("Delete the node with the delete key");
|
||||
let mutated = inspector.once("markupmutation");
|
||||
EventUtils.sendKey("delete", inspector.panelWin);
|
||||
yield Promise.all([mutated, inspector.once("inspector-updated")]);
|
||||
yield selectAndFocusNode("#after-whitespace", inspector);
|
||||
yield deleteCurrentSelection(inspector);
|
||||
|
||||
// TODO: There is still an issue with selection here. When the span is deleted, the
|
||||
// selection goes to text-node. But since the text-node gets removed from the markup
|
||||
|
@ -48,4 +42,32 @@ add_task(function* () {
|
|||
yield undoChange(inspector);
|
||||
node = yield getNodeFront("#after-whitespace", inspector);
|
||||
ok(node, "The node is back");
|
||||
|
||||
info("Test deleting the node before the whitespace and performing an undo preserves " +
|
||||
"the node order");
|
||||
|
||||
yield selectAndFocusNode("#before-whitespace", inspector);
|
||||
yield deleteCurrentSelection(inspector);
|
||||
|
||||
info("Undo the deletion to restore the original markup");
|
||||
yield undoChange(inspector);
|
||||
node = yield getNodeFront("#before-whitespace", inspector);
|
||||
ok(node, "The node is back");
|
||||
|
||||
let nextSibling = yield getNodeFront("#before-whitespace + *", inspector);
|
||||
let afterWhitespace = yield getNodeFront("#after-whitespace", inspector);
|
||||
is(nextSibling, afterWhitespace, "Order has been preserved after restoring the node");
|
||||
});
|
||||
|
||||
function* selectAndFocusNode(selector, inspector) {
|
||||
info(`Select node ${selector} and make sure it is focused`);
|
||||
yield selectNode(selector, inspector);
|
||||
yield clickContainer(selector, inspector);
|
||||
}
|
||||
|
||||
function* deleteCurrentSelection(inspector) {
|
||||
info("Delete the node with the delete key");
|
||||
let mutated = inspector.once("markupmutation");
|
||||
EventUtils.sendKey("delete", inspector.panelWin);
|
||||
yield Promise.all([mutated, inspector.once("inspector-updated")]);
|
||||
}
|
||||
|
|
|
@ -3123,12 +3123,12 @@ DocumentWalker.prototype = {
|
|||
previous = previous && previous.previousSibling;
|
||||
next = next && next.nextSibling;
|
||||
|
||||
if (this.filter(previous) === nodeFilterConstants.FILTER_ACCEPT) {
|
||||
if (previous && this.filter(previous) === nodeFilterConstants.FILTER_ACCEPT) {
|
||||
// A valid node was found in the previous siblings of the node.
|
||||
return previous;
|
||||
}
|
||||
|
||||
if (this.filter(next) === nodeFilterConstants.FILTER_ACCEPT) {
|
||||
if (next && this.filter(next) === nodeFilterConstants.FILTER_ACCEPT) {
|
||||
// A valid node was found in the next siblings of the node.
|
||||
return next;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче