diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 071ec11b1d98..24bf0937d503 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -1842,8 +1842,23 @@ ValidateCurrentNode(nsRange* aRange, RangeSubtreeIterator& aIter) } nsresult res = nsRange::CompareNodeToRange(node, aRange, &before, &after); + NS_ENSURE_SUCCESS(res, false); - return NS_SUCCEEDED(res) && !before && !after; + if (before || after) { + nsCOMPtr charData = do_QueryInterface(node); + if (charData) { + // If we're dealing with the start/end container which is a character + // node, pretend that the node is in the range. + if (before && node == aRange->GetStartParent()) { + before = false; + } + if (after && node == aRange->GetEndParent()) { + after = false; + } + } + } + + return !before && !after; } nsresult diff --git a/dom/base/test/file_bug1274806.html b/dom/base/test/file_bug1274806.html new file mode 100644 index 000000000000..62bef3044bcb --- /dev/null +++ b/dom/base/test/file_bug1274806.html @@ -0,0 +1,33 @@ + + + + + + + + +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur elit nisi, convallis sed scelerisque sit amet, vestibulum eu odio. Pellentesque et quam et nibh sollicitudin rutrum. Fusce tristique hendrerit ligula, et euismod sapien facilisis quis. Donec tincidunt turpis tortor, in pharetra tellus euismod ac. Vestibulum consectetur nulla lacinia, consectetur mauris ac, tempus libero. Nam non dui id enim dapibus porta id sed lectus. Praesent at suscipit neque. Vestibulum tellus lorem, placerat et volutpat sed, elementum eget lacus. Sed interdum nisi et imperdiet varius. Sed non magna odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus velit risus, accumsan nec efficitur nec, semper sed arcu. Praesent consectetur lectus justo, fringilla imperdiet neque lobortis id. Donec efficitur pulvinar finibus. + +

+

test

+ + diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index b4e3549c6654..c4496b7cb555 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -160,6 +160,7 @@ support-files = file_bug945152.jar file_bug1263696_frame_pass.html file_bug1263696_frame_fail.html + file_bug1274806.html file_general_document.html file_html_in_xhr.html file_html_in_xhr.sjs @@ -664,6 +665,7 @@ skip-if = buildapp == 'b2g' [test_bug1250148.html] [test_bug1259588.html] [test_bug1263696.html] +[test_bug1274806.html] [test_caretPositionFromPoint.html] [test_change_policy.html] skip-if = buildapp == 'b2g' #no ssl support diff --git a/dom/base/test/test_bug1274806.html b/dom/base/test/test_bug1274806.html new file mode 100644 index 000000000000..e49fbf628c61 --- /dev/null +++ b/dom/base/test/test_bug1274806.html @@ -0,0 +1,31 @@ + + + + + + Test for Bug 1274806 + + + + + +Mozilla Bug 1274806 +

+ +
+
+ +