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

Unified Diff: third_party/WebKit/LayoutTests/editing/selection/selection-update-range-after-addrange.html

Issue 2687273002: Selection API: Mutating a Range object after adding it to Selection should update Selection attribu… (Closed)
Patch Set: . Created 3 years, 10 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: third_party/WebKit/LayoutTests/editing/selection/selection-update-range-after-addrange.html
diff --git a/third_party/WebKit/LayoutTests/editing/selection/selection-update-range-after-addrange.html b/third_party/WebKit/LayoutTests/editing/selection/selection-update-range-after-addrange.html
new file mode 100644
index 0000000000000000000000000000000000000000..d76083b1abb3ca46cb0b27576fd6154ed5b6dd6d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/editing/selection/selection-update-range-after-addrange.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<p>abcdef</p>
+<script>
+test(() => {
+ let selection = getSelection();
+ selection.removeAllRanges();
+ let range = document.createRange();
+ let text = document.querySelector('p').firstChild;
+ range.setStart(text, 1);
+ range.setEnd(text, 2);
+
+ selection.addRange(range);
+ assert_equals(selection.anchorNode, text);
yosin_UTC9 2017/02/10 10:26:27 Could you use assesrt_selection()? It is easier to
tkent 2017/02/13 07:31:40 We can't test Range-Selection relationship behavio
+ assert_equals(selection.anchorOffset, 1);
+ assert_equals(selection.focusNode, text);
+ assert_equals(selection.focusOffset, 2);
+
+ range.setStart(text, 0);
+ assert_equals(selection.anchorOffset, 0);
+}, 'Mutation of Range after adding it to Selection should update Selection attributes.');
+</script>

Powered by Google App Engine
This is Rietveld 408576698