diff --git a/test/index.html b/test/index.html index 5e3641aefe..9634ac23e8 100644 --- a/test/index.html +++ b/test/index.html @@ -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; } @@ -39,7 +48,7 @@

CodeMirror: Test Suite

Please enable JavaScript...

- +
diff --git a/test/test.js b/test/test.js index f78f37c029..841a984fab 100644 --- a/test/test.js +++ b/test/test.js @@ -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);