From 7de2519eefef511da5944861ebe7712111362958 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 9 Jul 2013 13:23:55 -0400 Subject: [PATCH] collapse() now has an optional argument and detach() is a no-op --- dom/ranges/Range-collapse.html | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/dom/ranges/Range-collapse.html b/dom/ranges/Range-collapse.html index b30731ea2292c7..3ca95ac0123595 100644 --- a/dom/ranges/Range-collapse.html +++ b/dom/ranges/Range-collapse.html @@ -12,14 +12,9 @@ var range; if (rangeEndpoints == "detached") { range = document.createRange(); - range.detach(); - assert_throws("INVALID_STATE_ERR", function() { - range.collapse(toStart); - }, "Detached Range must throw INVALID_STATE_ERR on .collapse()"); - assert_throws("INVALID_STATE_ERR", function() { - range.collapsed; - }, "Detached Range must throw INVALID_STATE_ERR on .collapsed access"); - return; + range.detach(); // should be a no-op and therefore the following should not throw + range.collapse(toStart); + assert_equals(true, range.collapsed); } // Have to account for Ranges involving Documents! @@ -37,7 +32,10 @@ && range.startOffset == range.endOffset, "collapsed must be true if and only if the start and end are equal"); - range.collapse(toStart); + if(undefined == toStart) + range.collapse() + else + range.collapse(toStart); assert_equals(range.startContainer, expectedContainer, "Wrong startContainer"); @@ -128,6 +126,11 @@ eval(ranges[i]), false ]); + tests.push([ + "Range " + i + " " + ranges[i] + ", toStart omitted", + eval(ranges[i]), + undefined + ]); } generate_tests(testCollapse, tests);