From 673ff1cec9201df8f37de20f9e8f65a8444f2327 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Thu, 31 Aug 2017 16:55:20 +0100 Subject: [PATCH] Don't allow Selection in nodes not in the document; This matches the spec and Chrome, and seems to bring us closer to Edge and WebKit as well. It also matches our own behavior for addRange(), which was changed in bug 1341137. For collapse and selectAllChildren, we match the tests and browsers, but the spec is incorrect at the time of this writing: https://github.com/w3c/selection-api/pull/86 The removeAllRanges test hadn't been updated for the spec change. MozReview-Commit-ID: DTK8283k5IP Upstreamed from https://bugzilla.mozilla.org/show_bug.cgi?id=1359397 [ci skip] --- selection/removeAllRanges.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/selection/removeAllRanges.html b/selection/removeAllRanges.html index 286876f8bda1f85..026280d6b8c252c 100644 --- a/selection/removeAllRanges.html +++ b/selection/removeAllRanges.html @@ -13,8 +13,13 @@ var range = rangeFromEndpoints([paras[0].firstChild, 0, paras[0].firstChild, 1]); function testRange(rangeDesc, method) { + var endpoints = eval(testRanges[i]); + if (endpoints.length && (!isSelectableNode(endpoints[0]) || + !isSelectableNode(endpoints[2]))) { + return; + } test(function() { - setSelectionForwards(eval(rangeDesc)); + setSelectionForwards(endpoints); selection[method](); assert_equals(selection.rangeCount, 0, "After " + method + "(), rangeCount must be 0"); @@ -28,7 +33,7 @@ // Copy-pasted from above test(function() { - setSelectionBackwards(eval(rangeDesc)); + setSelectionBackwards(endpoints); selection[method](); assert_equals(selection.rangeCount, 0, "After " + method + "(), rangeCount must be 0");