Bug 1367460 Shouldn't make focused editing host blurred when moving selection with Selection API r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 30 May 2017 18:07:22 +0900
changeset 586457 d13fa65cb3d54faf79dee410f297dd8098dfec6c
parent 586419 de87645143103d274870a0b8b773cdff22a08595
child 630987 76909ebadb3a47e1a5cd4d822cf9c92bf0ba1459
push id61404
push usermasayuki@d-toybox.com
push dateTue, 30 May 2017 12:16:35 +0000
reviewerssmaug
bugs1367460
milestone55.0a1
Bug 1367460 Shouldn't make focused editing host blurred when moving selection with Selection API r?smaug Chromium doesn't make focused editing host blurred when a Selection API method call moves selection to a non-editable node. Let's follow same behavior for compatibility with both Chromium and Gecko 54. MozReview-Commit-ID: HXmYX18HVA5
layout/generic/nsSelection.cpp
testing/web-platform/meta/MANIFEST.json
testing/web-platform/mozilla/meta/MANIFEST.json
testing/web-platform/mozilla/meta/focus/Selection_collapse.html.ini
testing/web-platform/mozilla/meta/focus/Selection_extend.html.ini
testing/web-platform/mozilla/meta/focus/Selection_selectAllChildren.html.ini
testing/web-platform/mozilla/tests/focus/Range_collapse.html
testing/web-platform/mozilla/tests/focus/Range_selectNode.html
testing/web-platform/mozilla/tests/focus/Range_setEnd.html
testing/web-platform/mozilla/tests/focus/Range_setStart.html
testing/web-platform/mozilla/tests/focus/Selection_addRange.html
testing/web-platform/mozilla/tests/focus/Selection_addRange_into_iframe.html
testing/web-platform/mozilla/tests/focus/Selection_collapse.html
testing/web-platform/mozilla/tests/focus/Selection_extend.html
testing/web-platform/mozilla/tests/focus/Selection_selectAllChildren.html
testing/web-platform/mozilla/tests/focus/Selection_setBaseAndExtent.html
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -6467,33 +6467,26 @@ Selection::NotifySelectionListeners()
         GetEditor()) {
       RefPtr<Element> newEditingHost = GetCommonEditingHostForAllRanges();
       nsFocusManager* fm = nsFocusManager::GetFocusManager();
       nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
       nsIContent* focusedContent =
         fm->GetFocusedDescendant(window, false, getter_AddRefs(focusedWindow));
       nsCOMPtr<Element> focusedElement = do_QueryInterface(focusedContent);
       // When all selected ranges are in an editing host, it should take focus.
+      // But otherwise, we shouldn't move focus since Chromium doesn't move
+      // focus but only selection range is updated.
       if (newEditingHost && newEditingHost != focusedElement) {
         MOZ_ASSERT(!newEditingHost->IsInNativeAnonymousSubtree());
         nsCOMPtr<nsIDOMElement> domElementToFocus =
           do_QueryInterface(newEditingHost->AsDOMNode());
         // Note that don't steal focus from focused window if the window doesn't
         // have focus.
         fm->SetFocus(domElementToFocus, nsIFocusManager::FLAG_NOSWITCHFRAME);
       }
-      // Otherwise, if current focused element is an editing host, it should
-      // be blurred if there is no common editing host of the selected ranges.
-      else if (!newEditingHost && focusedElement &&
-               focusedElement == focusedElement->GetEditingHost()) {
-        IgnoredErrorResult err;
-        focusedElement->Blur(err);
-        NS_WARNING_ASSERTION(!err.Failed(),
-                             "Failed to blur focused element");
-      }
     }
   }
 
   RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
   if (frameSelection->GetBatching()) {
     frameSelection->SetDirty();
     return NS_OK;
   }
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -220000,17 +220000,17 @@
    "55100f7d505bc8cbc966ced0d1337ed78534a553",
    "testharness"
   ],
   "web-animations/animation-model/animation-types/property-list.js": [
    "a6860f4971e06078b5abdd57b3d7f57c0adff51e",
    "support"
   ],
   "web-animations/animation-model/animation-types/property-types.js": [
-   "1e16ea29f863cdf0bdcc6e9a4d000f4d76a312fb",
+   "ee3e5ae1923027f7e9dd80da11e765085a02c367",
    "support"
   ],
   "web-animations/animation-model/animation-types/spacing-keyframes-filters.html": [
    "bd771a8a18245560221d92ea3495f81918c09848",
    "testharness"
   ],
   "web-animations/animation-model/animation-types/spacing-keyframes-shapes.html": [
    "03c3ab6815cfa96c07d5f95b6059fb276c50a25f",
@@ -220564,25 +220564,25 @@
    "78b6434a88021b7f56e5a7bf3e858fc9558a7c19",
    "wdspec"
   ],
   "webdriver/actions/key.py": [
    "918bcadf034657dfcb679fd92c8a11efe34bfedf",
    "wdspec"
   ],
   "webdriver/actions/mouse.py": [
-   "823e2b1e5ba200487d0598eecbb051f73b5ea69f",
+   "9b591d61e353548d0894db281abad0c006e26497",
    "wdspec"
   ],
   "webdriver/actions/sequence.py": [
    "d80f382863e52ff223db735a2a551197e570774f",
    "wdspec"
   ],
   "webdriver/actions/special_keys.py": [
-   "b2d6c2fa8852c6299b6bd214f67007efebe3029a",
+   "a3989b050d0616ee81e9444303508848f1c5459a",
    "wdspec"
   ],
   "webdriver/actions/support/__init__.py": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webdriver/actions/support/keys.py": [
    "636991372c21e52b623ed4ada9dfb675dd7f7e14",
--- a/testing/web-platform/mozilla/meta/MANIFEST.json
+++ b/testing/web-platform/mozilla/meta/MANIFEST.json
@@ -845,73 +845,73 @@
    "f9d7ec9cf9fa8c847e45664b05482e3f8c191385",
    "support"
   ],
   "fetch/api/redirect/redirect-referrer.https.html": [
    "99cbd16b78771f35e075e4012d8dbc5dce3209c0",
    "testharness"
   ],
   "focus/Range_collapse.html": [
-   "95c795db4cec3ccb1e2632c547e34292364d9c92",
+   "da353916d6a5bf248e11e2a1be7ea7dfbb7cf358",
    "testharness"
   ],
   "focus/Range_selectNode.html": [
-   "699bb01144327600e57c715c84cc72ac2d7439d7",
+   "347dd6d965f5308de501a5cc34d2f30c8639fb74",
    "testharness"
   ],
   "focus/Range_setEnd.html": [
-   "481cecc11bb7a79bdfa171529bd8519dc69e33d4",
+   "57e5870e212eb7a28b1ce8b7f08fd7ea4719661a",
    "testharness"
   ],
   "focus/Range_setStart.html": [
-   "2e23bd20e25da1b4c10c0f8e78162a91ab05a798",
+   "ab6633c08a3a501d3766d9ee38da69e26dc8a9e4",
    "testharness"
   ],
   "focus/Selection_addRange.html": [
-   "03b60c8294d4421810d883255ba49784f390fea5",
+   "e733930483c74e73210c5a127db1d04f82c966cf",
    "testharness"
   ],
   "focus/Selection_addRange_into_iframe.html": [
-   "8d914033edb0bf1a517cf886f7f9c95dd41ec116",
+   "65143dd5377acc88b180460a46dd4bbb79cbf68e",
    "testharness"
   ],
   "focus/Selection_addRange_into_iframe_iframe.html": [
    "8e8eb8ee04e7a0879828de2c5fb2501c088504a4",
    "support"
   ],
   "focus/Selection_collapse.html": [
-   "1110ffe713c8effbf2b557faec5e367c00e8b5a9",
+   "15f83b9e158ff63fd3428c4d681ce4777b74198c",
    "testharness"
   ],
   "focus/Selection_collapseToEnd.html": [
    "92b38fcaffdee31422690f35c3d9147452b3a2e2",
    "testharness"
   ],
   "focus/Selection_collapseToStart.html": [
    "e47f9a13430db7d9f2c18ee41f9445ea372f0a18",
    "testharness"
   ],
   "focus/Selection_extend.html": [
-   "385c583117378f34b301a61391178aac6e3d784b",
+   "7773c09999b94d1f5c3ecf9a0c2fb00f466985e3",
    "testharness"
   ],
   "focus/Selection_removeAllRanges.html": [
    "2002fb41dfadb0e91abf5075f9c6117f06201f9a",
    "testharness"
   ],
   "focus/Selection_removeRange.html": [
    "7950a74c29501a4d7abb86cdcb126928c51c6d9b",
    "testharness"
   ],
   "focus/Selection_selectAllChildren.html": [
-   "6cd254447dea53268ce9ec8ce8a075c7803b5393",
+   "149d62e15b07519c155a1812bf343ef8e7f4fe6c",
    "testharness"
   ],
   "focus/Selection_setBaseAndExtent.html": [
-   "cd25aacffbaabbeafa443140f9b08ff75a838116",
+   "e66e79687e4188d82fb24ac692c36a294021d1a2",
    "testharness"
   ],
   "html/semantics/forms/textfieldselection/selection-value-interactions.html": [
    "eea373cbbfd4f6289234667fe9a002ff6a9755cf",
    "testharness"
   ],
   "html/semantics/scripting-1/the-script-element/create-module-script.html": [
    "3214bced5d81e8001a321aea4c80675b6603b11d",
--- a/testing/web-platform/mozilla/meta/focus/Selection_collapse.html.ini
+++ b/testing/web-platform/mozilla/meta/focus/Selection_collapse.html.ini
@@ -1,17 +1,17 @@
 [Selection_collapse.html]
   type: testharness
-  [Active element should be the <body> after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of the <body>]
+  [Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of the <body>]
     expected: FAIL
 
   [Active element should be 'editor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'editor']
     expected: FAIL
 
   [Active element should be 'outerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'outerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'staticInEditor']
+  [Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'staticInEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'anchor']
+  [Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'anchor']
     expected: FAIL
 
--- a/testing/web-platform/mozilla/meta/focus/Selection_extend.html.ini
+++ b/testing/web-platform/mozilla/meta/focus/Selection_extend.html.ini
@@ -1,26 +1,20 @@
 [Selection_extend.html]
   type: testharness
-  [Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'editor' to end of the first text node of 'outerEditor']
-    expected: FAIL
-
-  [Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'outerEditor' to start of the first text node of 'editor']
+  [Active element should be 'editor' after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'outerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'outerEditor']
+  [Active element should be 'editor' after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'innerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'innerEditor']
-    expected: FAIL
-
-  [Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'outerEditor' to start of the first text node of 'editor']
+  [Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'outerEditor' to start of the first text node of 'editor']
     expected: FAIL
 
   [Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'outerEditor']
     expected: FAIL
 
   [Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'staticInEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'anchor']
+  [Active element should be 'innerEditor' after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'anchor']
     expected: FAIL
 
--- a/testing/web-platform/mozilla/meta/focus/Selection_selectAllChildren.html.ini
+++ b/testing/web-platform/mozilla/meta/focus/Selection_selectAllChildren.html.ini
@@ -1,41 +1,41 @@
 [Selection_selectAllChildren.html]
   type: testharness
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'editor']
+  [Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'editor']
     expected: FAIL
 
   [Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is 'editor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'editor']
+  [Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'editor']
     expected: FAIL
 
   [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' when active element is 'editor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'editor']
+  [Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'editor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'outerEditor']
+  [Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'outerEditor']
     expected: FAIL
 
   [Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'editor' when active element is 'outerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'outerEditor']
+  [Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'outerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'innerEditor']
+  [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'innerEditor']
     expected: FAIL
 
   [Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'editor' when active element is 'innerEditor']
     expected: FAIL
 
   [Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is 'innerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'innerEditor']
+  [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'innerEditor']
     expected: FAIL
 
-  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'innerEditor']
+  [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'innerEditor']
     expected: FAIL
 
--- a/testing/web-platform/mozilla/tests/focus/Range_collapse.html
+++ b/testing/web-platform/mozilla/tests/focus/Range_collapse.html
@@ -164,18 +164,18 @@ test(function() {
     document.getSelection().getRangeAt(0).collapse(true);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Range.collapse(true) of selection between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().getRangeAt(0).collapse(false);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Range.collapse(false) of selection between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Range.collapse(false) of selection between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     document.getSelection().getRangeAt(0).collapse(true);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Range.collapse(true) of selection between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' when active element is 'outerEditor'");
 test(function() {
--- a/testing/web-platform/mozilla/tests/focus/Range_selectNode.html
+++ b/testing/web-platform/mozilla/tests/focus/Range_selectNode.html
@@ -106,105 +106,105 @@ function selectNodeContents(aNodeToSelec
         resetFocusAndSelectionRange();
         aTest.func(anchor.textNode);
         assert_equals(document.activeElement, document.body);
     }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the <body>");
 
     test(function() {
         resetFocusAndSelectionRange(editor);
         aTest.func(staticBefore.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(editor);
         aTest.func(editor.textNode);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with the first text node of 'editor' when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(editor);
         aTest.func(outerEditor.textNode);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with the first text node of 'outerEditor' when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(editor);
         aTest.func(staticInEditor.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(editor);
         aTest.func(innerEditor.textNode);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with the first text node of 'innerEditor' when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(editor);
         aTest.func(anchor.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'editor'");
 
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         aTest.func(staticBefore.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         aTest.func(editor.textNode);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with the first text node of 'editor' when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         aTest.func(outerEditor.textNode);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with the first text node of 'outerEditor' when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         aTest.func(staticInEditor.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         aTest.func(innerEditor.textNode);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with the first text node of 'innerEditor' when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         aTest.func(anchor.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'outerEditor'");
 
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         aTest.func(staticBefore.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         aTest.func(editor.textNode);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with the first text node of 'editor' when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         aTest.func(outerEditor.textNode);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with the first text node of 'outerEditor' when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         aTest.func(staticInEditor.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         aTest.func(innerEditor.textNode);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with the first text node of 'innerEditor' when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         aTest.func(anchor.textNode);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'innerEditor'");
 
     test(function() {
         resetFocusAndSelectionRange(anchor);
         aTest.func(staticBefore.textNode);
         assert_equals(document.activeElement, anchor.element);
     }, "Active element should be 'anchor' after " + aTest.doingDescription + " with the first text node of 'staticBefore' when active element is 'anchor'");
     test(function() {
         resetFocusAndSelectionRange(anchor);
--- a/testing/web-platform/mozilla/tests/focus/Range_setEnd.html
+++ b/testing/web-platform/mozilla/tests/focus/Range_setEnd.html
@@ -82,18 +82,18 @@ function setEndAfter(aNode, aOffset)
 
 // Range.setEnd*() should work same as collapse if specified end position is before its start.
 [{ func: setEnd, doingDescription: "Range.setEnd()" },
  { func: setEndBefore, doingDescription: "Range.setEndBefore()" }].forEach((aTest, aIndex, aArray)=>{
     test(function() {
         resetFocusAndSelectionRange(editor);
         document.getSelection().selectAllChildren(editor.textNode);
         aTest.func(staticBefore.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'staticBefore' (before the selection) when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with start of the first text node of 'staticBefore' (before the selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().selectAllChildren(outerEditor.textNode);
         aTest.func(editor.textNode, 0);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with start of the first text node of 'editor' (before the selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange();
@@ -119,18 +119,18 @@ function setEndAfter(aNode, aOffset)
         document.getSelection().collapse(staticBefore.textNode, staticBefore.textLength);
         aTest.func(staticBefore.textNode, 0);
         assert_equals(document.activeElement, document.body);
     }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'staticBefore' (before the collapsed selection) when active element is the <body>");
     test(function() {
         resetFocusAndSelectionRange(editor);
         document.getSelection().collapse(editor.textNode, editor.textLength);
         aTest.func(staticBefore.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with start of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().collapse(outerEditor.textNode, outerEditor.textLength);
         aTest.func(editor.textNode, 0);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with start of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange();
@@ -192,18 +192,18 @@ test(function() {
     document.getSelection().selectAllChildren(staticAfter.textNode);
     setEndAfter(innerEditor.textNode);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setEndAfter() with the first text node of 'innerEditor' (before the selection) when active element is the <body> and selection is in 'staticAfter'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(innerEditor.textNode);
     setEndAfter(staticInEditor.textNode);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setEndAfter() with the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setEndAfter() with the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange();
     document.getSelection().selectAllChildren(staticInEditor.textNode);
     setEndAfter(outerEditor.textNode);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setEndAfter() with the first text node of 'outerEditor' (before the selection) when active element is the <body> and selection is in 'staticInEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
@@ -216,77 +216,77 @@ test(function() {
     document.getSelection().selectAllChildren(outerEditor.textNode);
     setEndAfter(editor.textNode);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setEndAfter() with the first text node of 'editor' (before the selection) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(editor.textNode);
     setEndAfter(staticBefore.textNode);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setEndAfter() with the first text node of 'staticBefore' (before the selection) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setEndAfter() with the first text node of 'staticBefore' (before the selection) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().selectAllChildren(anchor.textNode);
     setEndAfter(staticBefore.textNode);
     assert_equals(document.activeElement, anchor.element);
 }, "Active element should be 'anchor' after Selection.setEndAfter() with the first text node of 'staticBefore' (before the selection) when active element is 'anchor'");
 
 // Range.setEnd*() should blur focused editing host when it expands selection to outside of it.
 [{ func: setEnd, doingDescription: "Range.setEnd()" },
  { func: setEndAfter, doingDescription: "Range.setEndAfter()" },
  { func: setEndBefore, doingDescription: "Range.setEndBefore()" }].forEach((aTest, aIndex, aArray)=>{
     test(function() {
         resetFocusAndSelectionRange(editor);
         document.getSelection().collapse(editor.textNode, 0);
         aTest.func(outerEditor.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (after end of the collapsed selection) when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (after end of the collapsed selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().collapse(outerEditor.textNode, 0);
         aTest.func(staticInEditor.textNode, 0);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (after end of the collapsed selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().collapse(outerEditor.textNode, 0);
         aTest.func(innerEditor.textNode, 0);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'innerEditor' (after end of the collapsed selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().collapse(outerEditor.textNode, 0);
         aTest.func(staticAfter.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'staticAfter' (after end of the collapsed selection) when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'staticAfter' (after end of the collapsed selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(editor);
         document.getSelection().selectAllChildren(editor.textNode);
         aTest.func(outerEditor.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (after end of the selection) when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (after end of the selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().selectAllChildren(outerEditor.textNode);
         aTest.func(staticInEditor.textNode, 0);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (after end of the selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().selectAllChildren(outerEditor.textNode);
         aTest.func(innerEditor.textNode, 0);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'innerEditor' (after end of the selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().selectAllChildren(outerEditor.textNode);
         aTest.func(staticAfter.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'staticAfter' (after end of the selection) when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'staticAfter' (after end of the selection) when active element is 'outerEditor'");
 });
 
 // Range.setEnd*() should move focus to an editing host when the range is shrunken into it.
 [{ func: setEnd, doingDescription: "Range.setEnd()" },
  { func: setEndAfter, doingDescription: "Range.setEndAfter()" }].forEach((aTest, aIndex, aArray)=>{
     test(function() {
         resetFocusAndSelectionRange();
         document.getSelection().setBaseAndExtent(editor.textNode, 0,
--- a/testing/web-platform/mozilla/tests/focus/Range_setStart.html
+++ b/testing/web-platform/mozilla/tests/focus/Range_setStart.html
@@ -94,30 +94,30 @@ function setStartAfter(aNode, aOffset)
         document.getSelection().selectAllChildren(editor.textNode);
         aTest.func(outerEditor.textNode, outerEditor.textLength);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'outerEditor' (before the selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().selectAllChildren(outerEditor.textNode);
         aTest.func(staticInEditor.textNode, staticInEditor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the selection) when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange();
         document.getSelection().selectAllChildren(staticInEditor.textNode);
         aTest.func(innerEditor.textNode, innerEditor.textLength);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'innerEditor' (before the selection) when active element is the <body> and selection is in 'staticInEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         document.getSelection().selectAllChildren(innerEditor.textNode);
         aTest.func(staticAfter.textNode, staticAfter.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticAfter' (before the selection) when active element is 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticAfter' (before the selection) when active element is 'innerEditor'");
 
     test(function() {
         resetFocusAndSelectionRange();
         document.getSelection().collapse(staticBefore.textNode, 0);
         aTest.func(editor.textNode, editor.textLength);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with end of the first text node of 'editor' (before the collapsed selection) when active element is the <body>");
     test(function() {
@@ -125,30 +125,30 @@ function setStartAfter(aNode, aOffset)
         document.getSelection().collapse(editor.textNode, 0);
         aTest.func(outerEditor.textNode, outerEditor.textLength);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().collapse(outerEditor.textNode, 0);
         aTest.func(staticInEditor.textNode, staticInEditor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange();
         document.getSelection().collapse(staticInEditor.textNode, 0);
         aTest.func(innerEditor.textNode, innerEditor.textLength);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'innerEditor' (before the collapsed selection) when active element is the <body> and selection is in 'staticInEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         document.getSelection().collapse(innerEditor.textNode, 0);
         aTest.func(staticAfter.textNode, staticAfter.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticAfter' (before the collapsed selection) when active element is 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticAfter' (before the collapsed selection) when active element is 'innerEditor'");
 
     test(function() {
         resetFocusAndSelectionRange();
         document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                                  editor.textNode, 0);
         aTest.func(editor.textNode, editor.textLength);
         assert_equals(document.activeElement, editor.element);
     }, "Active element should be 'editor' after " + aTest.doingDescription + " with end of the first text node of 'editor' (before the selection, between start of the first text node of 'staticBefore' and start of the first text node of 'editor') when active element is the <body>");
@@ -159,18 +159,18 @@ function setStartAfter(aNode, aOffset)
         aTest.func(outerEditor.textNode, outerEditor.textLength);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'outerEditor' (before the selection, between start of the first text node of 'editor' and start of the first text node of 'outerEditor') when active element is the <body>");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                                  staticInEditor.textNode, 0);
         aTest.func(staticInEditor.textNode, staticInEditor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the selection, between start of the first text node of 'outerEditor' and start of the first text node of 'staticInEditor') when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the selection, between start of the first text node of 'outerEditor' and start of the first text node of 'staticInEditor') when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                                  innerEditor.textNode, 0);
         aTest.func(innerEditor.textNode, innerEditor.textLength);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'innerEditor' (before the selection, between start of the first text node of 'outerEditor' and start of the first text node of 'innerEditor') when active element is 'outerEditor'");
     test(function() {
@@ -206,78 +206,78 @@ test(function() {
     document.getSelection().selectAllChildren(outerEditor.textNode);
     setStartBefore(innerEditor.textNode);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Range.setStartBefore() with the first text node of 'innerEditor' (before the selection) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(innerEditor.textNode);
     setStartBefore(staticAfter.textNode);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Range.setStartBefore() with the first text node of 'innerEditor' (before the selection) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Range.setStartBefore() with the first text node of 'innerEditor' (before the selection) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange();
     document.getSelection().selectAllChildren(staticAfter.textNode);
     setStartBefore(anchor.textNode);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Range.setStartBefore() with the first text node of 'anchor' (before the selection) when active element is the <body>");
 
 // Range.setStart*() should blur focused editing host when it expands selection to outside of it.
 [{ func: setStart, doingDescription: "Range.setStart()" },
  { func: setStartAfter, doingDescription: "Range.setStartAfter()" },
  { func: setStartBefore, doingDescription: "Range.setStartBefore()" }].forEach((aTest, aIndex, aArray)=>{
     test(function() {
         resetFocusAndSelectionRange(editor);
         document.getSelection().collapse(editor.textNode, editor.textLength);
         aTest.func(staticBefore.textNode, staticBefore.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with end of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().collapse(outerEditor.textNode, outerEditor.textLength);
         aTest.func(editor.textNode, editor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         document.getSelection().collapse(innerEditor.textNode, innerEditor.textLength);
         aTest.func(outerEditor.textNode, outerEditor.textLength);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         document.getSelection().collapse(innerEditor.textNode, innerEditor.textLength);
         aTest.func(staticInEditor.textNode, staticInEditor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'innerEditor'");
 
     test(function() {
         resetFocusAndSelectionRange(editor);
         document.getSelection().selectAllChildren(editor.textNode);
         aTest.func(staticBefore.textNode, staticBefore.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticBefore' (before the selection) when active element is 'editor'");
+        assert_equals(document.activeElement, editor.element);
+    }, "Active element should be 'editor' after " + aTest.doingDescription + " with end of the first text node of 'staticBefore' (before the selection) when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().selectAllChildren(outerEditor.textNode);
         aTest.func(editor.textNode, editor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'editor' (before the selection) when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'editor' (before the selection) when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         document.getSelection().selectAllChildren(innerEditor.textNode);
         aTest.func(outerEditor.textNode, outerEditor.textLength);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with end of the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor'");
     test(function() {
         resetFocusAndSelectionRange(innerEditor);
         document.getSelection().selectAllChildren(innerEditor.textNode);
         aTest.func(staticInEditor.textNode, staticInEditor.textLength);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor'");
+        assert_equals(document.activeElement, innerEditor.element);
+    }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with end of the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor'");
 });
 
 // Range.setStart*() should move focus to an editing host when the range is shrunken into it.
 [{ func: setStart, doingDescription: "Range.setStart()" },
  { func: setStartBefore, doingDescription: "Range.setStartBefore()" }].forEach((aTest, aIndex, aArray)=>{
     test(function() {
         resetFocusAndSelectionRange();
         document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
@@ -292,18 +292,18 @@ test(function() {
         aTest.func(outerEditor.textNode, 0);
         assert_equals(document.activeElement, outerEditor.element);
     }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'outerEditor' (shrunken into 'outerEditor') when active element is 'editor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                                  staticInEditor.textNode, staticInEditor.textLength);
         aTest.func(staticInEditor.textNode, 0);
-        assert_equals(document.activeElement, document.body);
-    }, "Active element should be the <body> after " + aTest.doingDescription + " with start of the first text node of 'staticInEditor' (shrunken into 'staticInEditor') when active element is 'outerEditor'");
+        assert_equals(document.activeElement, outerEditor.element);
+    }, "Active element should be 'outerEditor' after " + aTest.doingDescription + " with start of the first text node of 'staticInEditor' (shrunken into 'staticInEditor') when active element is 'outerEditor'");
     test(function() {
         resetFocusAndSelectionRange(outerEditor);
         document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                                  innerEditor.textNode, innerEditor.textLength);
         aTest.func(innerEditor.textNode, 0);
         assert_equals(document.activeElement, innerEditor.element);
     }, "Active element should be 'innerEditor' after " + aTest.doingDescription + " with start of the first text node of 'innerEditor' (shrunken into 'innerEditor') when active element is 'outerEditor'");
     test(function() {
--- a/testing/web-platform/mozilla/tests/focus/Selection_addRange.html
+++ b/testing/web-platform/mozilla/tests/focus/Selection_addRange.html
@@ -129,18 +129,18 @@ test(function() {
 }, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is the <body>");
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'editor' when active element is 'editor'");
@@ -153,51 +153,51 @@ test(function() {
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'outerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'innerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticAfter.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(anchor.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'editor' when active element is 'outerEditor'");
@@ -210,42 +210,42 @@ test(function() {
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'outerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'innerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticAfter.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(anchor.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(staticInEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, document.body);
@@ -300,18 +300,18 @@ test(function() {
 }, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is the <body> and selection is in 'staticInEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'editor' when active element is 'innerEditor'");
@@ -324,42 +324,42 @@ test(function() {
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'outerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'innerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticAfter.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(anchor.textNode, 0);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, anchor.element);
@@ -480,18 +480,18 @@ test(function() {
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(staticBefore.textNode, staticBefore.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, editor.element);
@@ -507,55 +507,55 @@ test(function() {
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'outerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     range.setEnd(staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'staticInEditor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'staticInEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'innerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticAfter.textNode, 0);
     range.setEnd(staticAfter.textNode, staticAfter.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'staticAfter' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'staticAfter' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(anchor.textNode, 0);
     range.setEnd(anchor.textNode, anchor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'anchor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'anchor' when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(staticBefore.textNode, staticBefore.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, editor.element);
@@ -571,45 +571,45 @@ test(function() {
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'outerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     range.setEnd(staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'innerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticAfter.textNode, 0);
     range.setEnd(staticAfter.textNode, staticAfter.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'staticAfter' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'staticAfter' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(anchor.textNode, 0);
     range.setEnd(anchor.textNode, anchor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'anchor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'anchor' when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(staticInEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(staticBefore.textNode, staticBefore.textLength);
     document.getSelection().addRange(range);
@@ -672,18 +672,18 @@ test(function() {
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(staticBefore.textNode, staticBefore.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, editor.element);
@@ -699,45 +699,45 @@ test(function() {
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'outerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     range.setEnd(staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'innerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticAfter.textNode, 0);
     range.setEnd(staticAfter.textNode, staticAfter.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'staticAfter' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'staticAfter' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(anchor.textNode, 0);
     range.setEnd(anchor.textNode, anchor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range in start of the first text node of 'anchor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'anchor' when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(staticBefore.textNode, staticBefore.textLength);
     document.getSelection().addRange(range);
@@ -865,200 +865,200 @@ test(function() {
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     range.setEnd(outerEditor.textNode, outerEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(outerEditor.textNode, 0);
     range.setEnd(staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' (common editing host is outerEditor) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(outerEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' (common editing host is outerEditor) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(staticAfter.textNode, staticAfter.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(anchor.textNode, anchor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     range.setEnd(outerEditor.textNode, outerEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(outerEditor.textNode, 0);
     range.setEnd(staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' (common editing host is outerEditor) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(outerEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' (common editing host is outerEditor) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(staticAfter.textNode, staticAfter.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(anchor.textNode, anchor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(editor.textNode, 0);
     range.setEnd(outerEditor.textNode, outerEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(outerEditor.textNode, 0);
     range.setEnd(staticInEditor.textNode, staticInEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' (common editing host is outerEditor) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticInEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(outerEditor.textNode, 0);
     range.setEnd(innerEditor.textNode, innerEditor.textLength);
     document.getSelection().addRange(range);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.addRange() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' (common editing host is outerEditor) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(staticAfter.textNode, staticAfter.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(innerEditor.textNode, 0);
     range.setEnd(anchor.textNode, anchor.textLength);
     document.getSelection().addRange(range);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.addRange() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().removeAllRanges();
     var range = document.createRange();
     range.setStart(staticBefore.textNode, 0);
     range.setEnd(editor.textNode, editor.textLength);
     document.getSelection().addRange(range);
--- a/testing/web-platform/mozilla/tests/focus/Selection_addRange_into_iframe.html
+++ b/testing/web-platform/mozilla/tests/focus/Selection_addRange_into_iframe.html
@@ -41,14 +41,14 @@ function doTest() {
         selection.collapse(document.body.firstChild, 0);
         childSelection.collapse(childDocument.getElementById("editor2").firstChild, 0);
 
         childSelection.removeAllRanges();
         var range = childDocument.createRange();
         range.selectNodeContents(childDocument.getElementById("non-editor"));
         childSelection.addRange(range);
         assert_equals(document.activeElement, document.body);
-        assert_equals(childDocument.activeElement, childDocument.body);
-    }, "Active element should be the <body> in the <iframe> after Selection.addRange() to non-editable <div> and parent's active document should be the <body>");
+        assert_equals(childDocument.activeElement, childDocument.getElementById("editor2"));
+    }, "Active element should be 'editor2' in the <iframe> after Selection.addRange() to non-editable <div> and parent's active document should be the <body>");
 
     done();
 }
 </script>
--- a/testing/web-platform/mozilla/tests/focus/Selection_collapse.html
+++ b/testing/web-platform/mozilla/tests/focus/Selection_collapse.html
@@ -98,36 +98,36 @@ test(function() {
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().collapse(innerEditor.textNode, 0);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'outerEditor' to start of the first text node of 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().collapse(staticInEditor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.collapse() moving selection from first text node in 'outerEditor' to start of the first text node of 'staticInEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.collapse() moving selection from first text node in 'outerEditor' to start of the first text node of 'staticInEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().collapse(staticBefore.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of the <body>");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of the <body>");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().collapse(editor.textNode, 0);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'editor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().collapse(outerEditor.textNode, 0);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().collapse(staticInEditor.textNode, 0);
-    assert_equals(document.activeElement, staticInEditor.element);
-}, "Active element should be the <body> after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'staticInEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'staticInEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().collapse(anchor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'anchor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in 'innerEditor' to start of the first text node of 'anchor'");
 </script>
--- a/testing/web-platform/mozilla/tests/focus/Selection_extend.html
+++ b/testing/web-platform/mozilla/tests/focus/Selection_extend.html
@@ -99,23 +99,23 @@ test(function() {
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().extend(editor.textNode, editor.textLength);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.extend() from selection at start of the first text node of 'editor' to end of the first text node of 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().extend(outerEditor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'outerEditor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().extend(innerEditor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'innerEditor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.extend() from selection at start of the first text node of 'editor' to start of the first text node of 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().extend(outerEditor.textNode, outerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'outerEditor' to end of the first text node of 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
@@ -125,18 +125,18 @@ test(function() {
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().extend(innerEditor.textNode, 0);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'outerEditor' to start of the first text node of 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().extend(editor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'outerEditor' to start of the first text node of 'editor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'outerEditor' to start of the first text node of 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().extend(innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.extend() from selection at start of the first text node of 'innerEditor' to end of the first text node of 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
@@ -146,18 +146,18 @@ test(function() {
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().extend(staticInEditor.textNode, 0);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'staticInEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().extend(anchor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'anchor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.extend() from selection at start of the first text node of 'innerEditor' to start of the first text node of 'anchor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().extend(anchor.textNode, anchor.textLength);
     assert_equals(document.activeElement, anchor.element);
 }, "Active element should be 'anchor' after Selection.extend() from selection at start of the first text node of 'anchor' to end of the first text node of 'anchor' and 'anchor' has focus before the call");
 test(function() {
     resetFocusAndSelectionRange(anchor);
--- a/testing/web-platform/mozilla/tests/focus/Selection_selectAllChildren.html
+++ b/testing/web-platform/mozilla/tests/focus/Selection_selectAllChildren.html
@@ -94,105 +94,105 @@ test(function() {
     resetFocusAndSelectionRange();
     document.getSelection().selectAllChildren(anchor.element);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is the <body>");
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(staticBefore.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(editor.element);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'editor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(outerEditor.element);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(staticInEditor.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(innerEditor.element);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().selectAllChildren(anchor.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().selectAllChildren(staticBefore.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().selectAllChildren(editor.element);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'editor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().selectAllChildren(outerEditor.element);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().selectAllChildren(staticInEditor.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'ouerEditor' after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().selectAllChildren(innerEditor.element);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().selectAllChildren(anchor.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(staticBefore.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(editor.element);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'editor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(outerEditor.element);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(staticInEditor.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(innerEditor.element);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().selectAllChildren(anchor.element);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().selectAllChildren(staticBefore.element);
     assert_equals(document.activeElement, anchor.element);
 }, "Active element should be 'anchor' after Selection.selectAllChildren() to select the children of 'staticBefore' when active element is 'anchor'");
 test(function() {
     resetFocusAndSelectionRange(anchor);
--- a/testing/web-platform/mozilla/tests/focus/Selection_setBaseAndExtent.html
+++ b/testing/web-platform/mozilla/tests/focus/Selection_setBaseAndExtent.html
@@ -112,97 +112,97 @@ test(function() {
                                              anchor.textNode, 0);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is the <body>");
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              editor.textNode, 0);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'editor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              outerEditor.textNode, 0);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'outerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              staticInEditor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              innerEditor.textNode, 0);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'innerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
                                              staticAfter.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(anchor.textNode, 0,
                                              anchor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              editor.textNode, 0);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'editor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              outerEditor.textNode, 0);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'outerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              staticInEditor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              innerEditor.textNode, 0);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'innerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
                                              staticAfter.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(anchor.textNode, 0,
                                              anchor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(staticInEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, 0);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is the <body> and selection is in 'staticInEditor'");
 test(function() {
@@ -241,54 +241,54 @@ test(function() {
                                              anchor.textNode, 0);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is the <body> and selection is in 'staticInEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              editor.textNode, 0);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'editor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              outerEditor.textNode, 0);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'outerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              staticInEditor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              innerEditor.textNode, 0);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'innerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
                                              staticAfter.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(anchor.textNode, 0,
                                              anchor.textNode, 0);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, 0);
     assert_equals(document.activeElement, anchor.element);
 }, "Active element should be 'anchor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'anchor'");
 test(function() {
@@ -371,97 +371,97 @@ test(function() {
                                              anchor.textNode, anchor.textLength);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is the <body>");
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, staticBefore.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              editor.textNode, editor.textLength);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'editor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              outerEditor.textNode, outerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'outerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'innerEditor' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
                                              staticAfter.textNode, staticAfter.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(anchor.textNode, 0,
                                              anchor.textNode, anchor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, staticBefore.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              editor.textNode, editor.textLength);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'editor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              outerEditor.textNode, outerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'outerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'innerEditor' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
                                              staticAfter.textNode, staticAfter.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(anchor.textNode, 0,
                                              anchor.textNode, anchor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(staticInEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, staticBefore.textLength);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'outerEditor' and selection is in 'staticInEditor'");
 test(function() {
@@ -500,54 +500,54 @@ test(function() {
                                              anchor.textNode, anchor.textLength);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'outerEditor' and selection is in 'staticInEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, staticBefore.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              editor.textNode, editor.textLength);
     assert_equals(document.activeElement, editor.element);
 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'editor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              outerEditor.textNode, outerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'outerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, innerEditor.element);
 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'innerEditor' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
                                              staticAfter.textNode, staticAfter.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(anchor.textNode, 0,
                                              anchor.textNode, anchor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              staticBefore.textNode, staticBefore.textLength);
     assert_equals(document.activeElement, anchor.element);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'anchor'");
 test(function() {
@@ -630,140 +630,140 @@ test(function() {
                                              anchor.textNode, anchor.textLength);
     assert_equals(document.activeElement, document.body);
 }, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is the <body>");
 
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              editor.textNode, editor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              outerEditor.textNode, outerEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' (common editing host is outerEditor) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' (common editing host is outerEditor) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              staticAfter.textNode, staticAfter.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'editor'");
 test(function() {
     resetFocusAndSelectionRange(editor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              anchor.textNode, anchor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'editor'");
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'editor'");
 
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              editor.textNode, editor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              outerEditor.textNode, outerEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' (common editing host is outerEditor) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' (common editing host is outerEditor) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              staticAfter.textNode, staticAfter.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'outerEditor'");
 test(function() {
     resetFocusAndSelectionRange(outerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              anchor.textNode, anchor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'outerEditor'");
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'outerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              editor.textNode, editor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(editor.textNode, 0,
                                              outerEditor.textNode, outerEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              staticInEditor.textNode, staticInEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor' (common editing host is outerEditor) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
                                              innerEditor.textNode, innerEditor.textLength);
     assert_equals(document.activeElement, outerEditor.element);
 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor' (common editing host is outerEditor) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              staticAfter.textNode, staticAfter.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'innerEditor'");
 test(function() {
     resetFocusAndSelectionRange(innerEditor);
     document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
                                              anchor.textNode, anchor.textLength);
-    assert_equals(document.activeElement, document.body);
-}, "Active element should be the <body> after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'innerEditor'");
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'innerEditor'");
 
 test(function() {
     resetFocusAndSelectionRange(anchor);
     document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
                                              editor.textNode, editor.textLength);
     assert_equals(document.activeElement, anchor.element);
 }, "Active element should be 'anchor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'anchor'");
 test(function() {