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

Unified Diff: LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html

Issue 800633004: ShadowRoot's getSelection().getRangeAt(0) returns an incorrect Range object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test failures Created 5 years, 11 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
« no previous file with comments | « no previous file | Source/core/editing/DOMSelection.cpp » ('j') | Source/core/editing/DOMSelection.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html
diff --git a/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html b/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html
new file mode 100644
index 0000000000000000000000000000000000000000..4cc77d1b35777f6b26f56f94064ad9bde1ef9429
--- /dev/null
+++ b/LayoutTests/editing/shadow/getRangeAt-end-of-text-node.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<div id="shadowHost"></div>
+<script>
+(function () {
+ var shadowRoot = shadowHost.createShadowRoot();
+ shadowRoot.innerHTML = '<div id="editable" contenteditable>Test</div>';
+ var textNode = shadowRoot.querySelector("#editable").firstChild;
+ var selection = shadowRoot.getSelection();
+ selection.collapse(textNode, textNode.textContent.length);
+ test(function () {
+ var range = selection.getRangeAt(0);
+ assert_equals(range.startContainer, textNode);
+ assert_equals(range.startOffset, textNode.textContent.length);
+ assert_true(range.collapsed);
+ }, "collapsed");
+
+ selection.collapse(textNode, 0);
+ selection.extend(textNode, 2);
+ test(function () {
+ var range = selection.getRangeAt(0);
+ assert_equals(range.startContainer, textNode);
+ assert_equals(range.startOffset, 0);
+ assert_equals(range.endContainer, textNode);
+ assert_equals(range.endOffset, 2);
+ assert_false(range.collapsed);
+ }, "range");
+
+ test(function () {
+ assert_not_equals(window.getSelection().getRangeAt(0).anchorNode, textNode);
+ }, "Nodes in Shadow should not be exposed to window.getSelection()");
+})();
+</script>
« no previous file with comments | « no previous file | Source/core/editing/DOMSelection.cpp » ('j') | Source/core/editing/DOMSelection.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698