Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: LayoutTests/fast/dom/Range/getBoundingClientRect-caret.html

Issue 998263002: range.getBoundingClientRect() returns incorrect value for collapsed ranges (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/Range/getBoundingClientRect-caret.html
diff --git a/LayoutTests/fast/dom/Range/getBoundingClientRect-caret.html b/LayoutTests/fast/dom/Range/getBoundingClientRect-caret.html
new file mode 100644
index 0000000000000000000000000000000000000000..41adea808c1cc78bd616e4cceacc6dcd2aff07bf
--- /dev/null
+++ b/LayoutTests/fast/dom/Range/getBoundingClientRect-caret.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+</head>
+<body>
+<div id="d1" contenteditable="true"> hello </div>
+<div id="console"></div>
+</body>
+<script>
+ description('Test getBoundingClientRect of caret for collapsed range.');
+
+ /* Set caret position */
+ var el = document.getElementById("d1");
+ var sel = window.getSelection();
+ var range = document.createRange();
+ range.setStart(el.childNodes[0], 3);
+ range.collapse(true);
+ sel.removeAllRanges();
+ sel.addRange(range);
+ el.focus();
+
+ /* Actual test */
+ sel = window.getSelection();
+ range = sel.getRangeAt(0);
+ range.collapse(true);
+ var rect = range.getBoundingClientRect();
+
+ shouldBe("rect.left", "22");
+ shouldBe("rect.top", "8");
+ shouldBe("rect.width", "0");
+ shouldBe("rect.height", "19");
+</script>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Range/getBoundingClientRect-caret-expected.txt » ('j') | Source/core/dom/Range.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698