Files
firefox/editor/libeditor/tests/test_bug537046.html
T
Aryeh Gregor 947daa8d85 Bug 1359397 - Don't allow Selection in nodes not in the document; r=masayuki
This matches the spec and Chrome, and seems to bring us closer to Edge
and WebKit as well.  It also matches our own behavior for addRange(),
which was changed in bug 1341137.

For collapse and selectAllChildren, we match the tests and browsers, but
the spec is incorrect at the time of this writing:
https://github.com/w3c/selection-api/pull/86

The removeAllRanges test hadn't been updated for the spec change.

MozReview-Commit-ID: DTK8283k5IP
2017-08-10 15:02:08 +03:00

50 lines
1.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=537046
-->
<head>
<title>Test for Bug 537046</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=537046">Mozilla Bug 537046</a>
<p id="display"></p>
<div id="content">
<div id="editor" contenteditable="true">
Some editable content
</div>
<div id="source" contenteditable="true">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 537046 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var ed = document.getElementById("editor");
var src = document.getElementById("source");
ed.addEventListener("DOMSubtreeModified", function() {
src.textContent = ed.innerHTML;
});
src.addEventListener("DOMSubtreeModified", function() {
ed.innerHTML = ed.textContent;
});
// Simulate pressing Enter twice
ed.focus();
synthesizeKey("VK_RETURN", {});
synthesizeKey("VK_RETURN", {});
ok(true, "Didn't crash!");
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>