Skip to content

Commit

Permalink
Unit test for line widget focus restoration
Browse files Browse the repository at this point in the history
  • Loading branch information
njx authored and marijnh committed Dec 18, 2012
1 parent 0b97e94 commit fee2bb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
font-weight: bold;
white-space: pre;
}
#testground {
visibility: hidden;
}
#testground.offscreen {
visibility: visible;
position: absolute;
left: -10000px;
top: -10000px;
}
.CodeMirror { border: 1px solid black; }
</style>
</head>
Expand All @@ -39,7 +48,7 @@ <h1>CodeMirror: Test Suite</h1>
<p id=status>Please enable JavaScript...</p>
<div id=output></div>

<div style="visibility: hidden" id=testground></div>
<div id=testground></div>

<script src="driver.js"></script>
<script src="test.js"></script>
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,22 @@ testCM("lineWidgets", function(cm) {
eqPos(cm.getCursor(), {line: 1, ch: 1});
});

testCM("lineWidgetFocus", function(cm) {
var place = document.getElementById("testground");
place.className = "offscreen";
try {
addDoc(cm, 500, 10);
var node = document.createElement("input");
var widget = cm.addLineWidget(1, node);
node.focus();
eq(document.activeElement, node);
cm.replaceRange("new stuff", {line: 1, ch: 0});
eq(document.activeElement, node);
} finally {
place.className = "";
}
});

testCM("getLineNumber", function(cm) {
addDoc(cm, 2, 20);
var h1 = cm.getLineHandle(1);
Expand Down

0 comments on commit fee2bb7

Please sign in to comment.