From c0d79062b5bb34ee3c28e7c591c2b22d361830b9 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 29 Feb 2016 00:19:18 +0100 Subject: [PATCH] Fix step 14.2 of Range::ExtractContents We need the last inclusive ancestor of start node that is not an inclusive ancestor of end node, not the first that is an inclusive ancestor of it. --- components/script/dom/range.rs | 5 +++-- .../dom/ranges/Range-extractContents.html.ini | 17 ----------------- 2 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 88fc9ad35bc..c6efae90b98 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -564,8 +564,9 @@ impl RangeMethods for Range { } else { // Step 14.1-2. let reference_node = start_node.ancestors() - .find(|n| n.is_inclusive_ancestor_of(end_node.r())) - .unwrap(); + .take_while(|n| !n.is_inclusive_ancestor_of(&end_node)) + .last() + .unwrap_or(Root::from_ref(&start_node)); // Step 14.3. (reference_node.GetParentNode().unwrap(), reference_node.index() + 1) }; diff --git a/tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini b/tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini deleted file mode 100644 index e509efc61c4..00000000000 --- a/tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini +++ /dev/null @@ -1,17 +0,0 @@ -[Range-extractContents.html] - type: testharness - [Resulting cursor position for range 18 [paras[0\].firstChild, 0, paras[1\].firstChild, 0\]] - expected: FAIL - - [Resulting cursor position for range 19 [paras[0\].firstChild, 0, paras[1\].firstChild, 8\]] - expected: FAIL - - [Resulting cursor position for range 20 [paras[0\].firstChild, 3, paras[3\], 1\]] - expected: FAIL - - [Resulting cursor position for range 50 [paras[2\].firstChild, 4, comment, 2\]] - expected: FAIL - - [Resulting cursor position for range 51 [paras[3\], 1, comment, 8\]] - expected: FAIL -