From 3db636e4001a8323eb04e1e0662a07a2a73501c6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 20 Oct 2011 22:50:04 +0000 Subject: [PATCH] QUnit test cases for bug 31847: will trigger a fail on IE 6/7/8 jquery.textSelection's getCaretPosition() gives bogus results on IE 6/7/8 when there's not a selection set in the textarea; it seems to give us some value somewhere in the middle of the textarea, rather than what we expected. If we actually set an empty selection, then it gets it back just fine! But if the cursor is in initial state, or has been moved by the user, we get back garbage. This is causing WikiEditor to sometimes insert things in the wrong place, as it tries to pull the caret position and manipulate the selection to do insertions; we then end up using the bogus selection when it gets saved in via selection restoration. --- .../jquery/jquery.textSelection.test.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js b/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js index 5926409d73..5cd49de076 100644 --- a/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js @@ -222,3 +222,54 @@ encapsulateTest({ }, replace: ulist }); + + +var caretTest = function(options) { + test(options.description, function() { + expect(2); + + var $fixture = $( '
' ); + var $textarea = $( '