Previously, it (renamed from `GetNodeLocation) returned error in this case [1]. Then, the callers aborted. However, now, this returns unset point instead and then, the loops in `GetPromotedStartPoint` and `GetPromotedEndPoint` will treat as in a generated content. The generated content handler in `GetPromotedEndPoint` is ported as-is, but the now, `GetParentPoint()` cannot return only the container because `RawRangeBoundary` needs to be a valid point for selection. Therefore, the ported code won't work. This patch restores the behavior of `GetParentPoint` in the case. However, then, there is a discrepancy. If the loops stop due to the point is not start/end of the container, it returns the promoted point in the shadow. However, if it reaches the host which is not part of the flattened tree, it returns an error so that failing to copy the selection. Therefore, this fixes the case in `IsRoot()`. Finally, in these days, selections shouldn't be start/end in generated content. Therefore, this patch makes them return error in the case with asserting in the debug builds. 1. https://searchfox.org/firefox-main/rev/a1c0acfae3e40def5d80b3dc9916b07e18a85c63/dom/serializers/nsDocumentEncoder.cpp#2275-2276,2278-2279 Differential Revision: https://phabricator.services.mozilla.com/D284051
73 lines
2.2 KiB
HTML
73 lines
2.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html><head>
|
|
<title>Test for bug 1306532</title>
|
|
<style src="/tests/SimpleTest/test.css" type="text/css"></style>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
function runTest() {
|
|
const headingone = document.getElementById("headingone");
|
|
const celltwo = document.getElementById("celltwo");
|
|
const pasteframe = document.getElementById("pasteframe");
|
|
|
|
// Copy content from table.
|
|
var selection = getSelection();
|
|
var startRange = document.createRange();
|
|
startRange.setStart(headingone, 0);
|
|
startRange.setEnd(celltwo, 0);
|
|
selection.removeAllRanges();
|
|
selection.addRange(startRange);
|
|
SpecialPowers.wrap(document).execCommand("copy", false, null);
|
|
|
|
// Paste content into "pasteframe"
|
|
var pasteContainer = pasteframe.contentDocument.body;
|
|
var pasteRange = pasteframe.contentDocument.createRange();
|
|
pasteRange.selectNodeContents(pasteContainer);
|
|
pasteRange.collapse(false);
|
|
selection.removeAllRanges();
|
|
selection.addRange(pasteRange);
|
|
SpecialPowers.wrap(pasteframe.contentDocument).execCommand("paste", false, null);
|
|
|
|
is(pasteContainer.querySelector("#headingone").textContent, "Month", "First heading should be 'Month'.");
|
|
is(pasteContainer.querySelector("#headingtwo").textContent, "Savings", "Second heading should be 'Savings'.");
|
|
is(pasteContainer.querySelector("#cellone").textContent, "January", "First cell should be 'January'.");
|
|
is(
|
|
pasteContainer.querySelector("#celltwo").textContent,
|
|
"",
|
|
"Second cell should be empty since the range ends at start of the cell"
|
|
);
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1306532">Mozilla Bug 1306532</a>
|
|
<p id="display"></p>
|
|
|
|
<pre id="test">
|
|
</pre>
|
|
|
|
<div id="container">
|
|
<table border="1">
|
|
<tr>
|
|
<th id="headingone">Month</th>
|
|
<th id="headingtwo">Savings</th>
|
|
</tr>
|
|
<tr>
|
|
<td id="cellone">January</td>
|
|
<td id="celltwo">$100</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<iframe onload="runTest();" id="pasteframe" srcdoc="<html><body contenteditable='true'>"></iframe>
|
|
|
|
</body>
|
|
</html>
|