gecko-dev/dom/base/test/test_bug1381710.html
Makoto Kato 4418d7d986 Bug 1381710 - Selection.addRange will be failure with dynamic table insertion. r=tnikkel
When range is selected table element, Selection.addRange uses nsFrameSelection.  If frame isn't constructed yet, addRange throws NS_ERROR_FAILURE even if table element isn't editable element.

When getting nsITableCellLayout, we should flush frame to construct cell frame.

MozReview-Commit-ID: 9qWwW46RYNL

--HG--
extra : rebase_source : 708e78af457a28bc273b83015f78950a5bee232e
2017-07-18 16:54:31 +09:00

41 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1381710
-->
<head>
<title>Test for Mozilla Bug 1381710</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.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=1381710">Mozilla Bug 1381710</a>
<div id="content">
<div id="nonedit"></div>
<div id="edit" contenteditable=true></div>
</div>
<pre id="test">
<script type="application/javascript">
function test(element)
{
let selection = window.getSelection();
selection.removeAllRanges();
let range = document.createRange();
element.innerHTML = "<table><tr id=tr><td id=td>A</td><td>B</td><tr></table>";
let td = document.getElementById("td");
range.selectNode(td);
// Don't throw exception
selection.addRange(range);
is(selection.anchorNode, document.getElementById("tr"),
"anchor node should be <TR> element");
element.innerHTML = "";
}
test(document.getElementById("nonedit"));
test(document.getElementById("edit"));
</script>
</pre>
</body>
</html>