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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/StaticRange/staticrange-no-mutate.html

Issue 2022863002: [InputEvent] Introduce |StaticRange| and use in |InputEvent::getRanges()| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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/fast/dom/StaticRange/staticrange-no-mutate.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/StaticRange/staticrange-no-mutate.html b/third_party/WebKit/LayoutTests/fast/dom/StaticRange/staticrange-no-mutate.html
new file mode 100644
index 0000000000000000000000000000000000000000..6dec75d2130f0fe1127ce5d83c4b632436a42634
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/StaticRange/staticrange-no-mutate.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>StaticRange: No mutate on DOM change</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+</head>
+<body>
+abcdefg
+<script>
+test(function() {
+ // Initialize.
+ var txt = document.body.firstChild;
+ var staticRange = new StaticRange();
+ staticRange.setStart(txt, 0);
+ staticRange.setEnd(txt, 5);
+ var range = staticRange.toRange();
+
+ // Split text and StaticRange shouldn't mutate.
+ txt.splitText(2);
+ assert_equals(staticRange.startContainer, txt);
+ assert_equals(staticRange.startOffset, 0);
+ assert_equals(staticRange.endContainer, txt);
+ assert_equals(staticRange.endOffset, 5);
+
+ // Range should mutate.
+ assert_equals(range.startContainer, txt);
+ assert_equals(range.startOffset, 0);
+ assert_equals(range.endContainer, txt.nextSibling);
+ assert_equals(range.endOffset, 3);
+}, 'Testing StaticRange wont mutate on DOM change');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698