From 04bf3a0295799089215504998b46ab9a3e86a3d8 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Thu, 15 Feb 2024 14:08:47 -0800 Subject: [PATCH] [EditContext] Allow backwards range params in updateText Per https://github.com/w3c/edit-context/pull/90, EditContext.updateText() should allow the start/end parameters to be backwards. Bug: 40642681 Change-Id: Idde01fa7282120e0961eb60a9ccab58061f4062b --- .../edit-context/edit-context-basics.tentative.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/editing/edit-context/edit-context-basics.tentative.html b/editing/edit-context/edit-context-basics.tentative.html index 78b6824921a3bb..0011270c812fdd 100644 --- a/editing/edit-context/edit-context-basics.tentative.html +++ b/editing/edit-context/edit-context-basics.tentative.html @@ -191,6 +191,19 @@ assert_equals(editContext.selectionStart, 3); assert_equals(editContext.selectionEnd, 0); }, 'EditContext should allow a backwards selection'); + + test(function() { + const editContext = new EditContext(); + assert_not_equals(editContext, null); + editContext.updateText(6, 0, "abcdef"); + assert_equals(editContext.text, "abcdef"); + + editContext.updateText(2, 5, "ghi"); + assert_equals(editContext.text, "abghif"); + + editContext.updateText(5, 2, "jkl"); + assert_equals(editContext.text, "abjklf"); + }, 'updateText can replace substrings including with backwards parameters');