Bug 1318312 part.1 Add automated tests for checking focus move at using Selection API r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 13 Mar 2017 22:30:28 +0900
changeset 498029 607bf31da6e8f5b9056668be028dcce958432d33
parent 498028 545e603fafd2c04207ee91c769080fba48e02b47
child 498030 9aa2777f807bda8a8d85f723123d9014d7a787c0
push id49084
push usermasayuki@d-toybox.com
push dateTue, 14 Mar 2017 05:28:54 +0000
reviewerssmaug
bugs1318312
milestone55.0a1
Bug 1318312 part.1 Add automated tests for checking focus move at using Selection API r?smaug Adding automated tests as web platform tests (only for mozilla) for focus move at using Selection API. Although, there is no standards of relation between Selection API and focus, we should move focus when Selection API moves selections into only an editing host or outside of focused editing host. Chrome moves focus as this rules, therefore, user can modify contenteditable editor immediately after web app moves selection. Edge does NOT move focus at using Selection API. However, user can modify contenteditable editor similar to Chrome. We can guess that Edge doesn't need to move focus in its design because perhaps, Edge decides if it's editable only with primary selected range. We cannot take the Edge behavior due to our editor design. So, we can take only Chrome's approach for improving the compatibility. MozReview-Commit-ID: JuLiSMgqODm
testing/web-platform/mozilla/meta/MANIFEST.json
testing/web-platform/mozilla/meta/focus/Range_collapse.html.ini
testing/web-platform/mozilla/meta/focus/Range_selectNode.html.ini
testing/web-platform/mozilla/meta/focus/Range_setEnd.html.ini
testing/web-platform/mozilla/meta/focus/Range_setStart.html.ini
testing/web-platform/mozilla/meta/focus/Selection_addRange.html.ini
testing/web-platform/mozilla/meta/focus/Selection_addRange_into_iframe.html.ini
testing/web-platform/mozilla/meta/focus/Selection_collapse.html.ini
testing/web-platform/mozilla/meta/focus/Selection_collapseToEnd.html.ini
testing/web-platform/mozilla/meta/focus/Selection_collapseToStart.html.ini
testing/web-platform/mozilla/meta/focus/Selection_extend.html.ini
testing/web-platform/mozilla/meta/focus/Selection_removeAllRanges.html.ini
testing/web-platform/mozilla/meta/focus/Selection_removeRange.html.ini
testing/web-platform/mozilla/meta/focus/Selection_selectAllChildren.html.ini
testing/web-platform/mozilla/meta/focus/Selection_setBaseAndExtent.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_addRange_into_iframe_iframe.html
testing/web-platform/mozilla/tests/focus/Selection_collapse.html
testing/web-platform/mozilla/tests/focus/Selection_collapseToEnd.html
testing/web-platform/mozilla/tests/focus/Selection_collapseToStart.html
testing/web-platform/mozilla/tests/focus/Selection_extend.html
testing/web-platform/mozilla/tests/focus/Selection_removeAllRanges.html
testing/web-platform/mozilla/tests/focus/Selection_removeRange.html
testing/web-platform/mozilla/tests/focus/Selection_selectAllChildren.html
testing/web-platform/mozilla/tests/focus/Selection_setBaseAndExtent.html
--- a/testing/web-platform/mozilla/meta/MANIFEST.json
+++ b/testing/web-platform/mozilla/meta/MANIFEST.json
@@ -8,16 +8,21 @@
      {}
     ]
    ],
    "fetch/api/redirect/redirect-referrer-mixed-content.js": [
     [
      {}
     ]
    ],
+   "focus/Selection_addRange_into_iframe_iframe.html": [
+    [
+     {}
+    ]
+   ],
    "html/semantics/scripting-1/the-script-element/support/missing_import.js": [
     [
      {}
     ]
    ],
    "html/semantics/scripting-1/the-script-element/support/module.js": [
     [
      {}
@@ -346,16 +351,100 @@
   },
   "testharness": {
    "fetch/api/redirect/redirect-referrer.https.html": [
     [
      "/_mozilla/fetch/api/redirect/redirect-referrer.https.html",
      {}
     ]
    ],
+   "focus/Range_collapse.html": [
+    [
+     "/_mozilla/focus/Range_collapse.html",
+     {}
+    ]
+   ],
+   "focus/Range_selectNode.html": [
+    [
+     "/_mozilla/focus/Range_selectNode.html",
+     {}
+    ]
+   ],
+   "focus/Range_setEnd.html": [
+    [
+     "/_mozilla/focus/Range_setEnd.html",
+     {}
+    ]
+   ],
+   "focus/Range_setStart.html": [
+    [
+     "/_mozilla/focus/Range_setStart.html",
+     {}
+    ]
+   ],
+   "focus/Selection_addRange.html": [
+    [
+     "/_mozilla/focus/Selection_addRange.html",
+     {}
+    ]
+   ],
+   "focus/Selection_addRange_into_iframe.html": [
+    [
+     "/_mozilla/focus/Selection_addRange_into_iframe.html",
+     {}
+    ]
+   ],
+   "focus/Selection_collapse.html": [
+    [
+     "/_mozilla/focus/Selection_collapse.html",
+     {}
+    ]
+   ],
+   "focus/Selection_collapseToEnd.html": [
+    [
+     "/_mozilla/focus/Selection_collapseToEnd.html",
+     {}
+    ]
+   ],
+   "focus/Selection_collapseToStart.html": [
+    [
+     "/_mozilla/focus/Selection_collapseToStart.html",
+     {}
+    ]
+   ],
+   "focus/Selection_extend.html": [
+    [
+     "/_mozilla/focus/Selection_extend.html",
+     {}
+    ]
+   ],
+   "focus/Selection_removeAllRanges.html": [
+    [
+     "/_mozilla/focus/Selection_removeAllRanges.html",
+     {}
+    ]
+   ],
+   "focus/Selection_removeRange.html": [
+    [
+     "/_mozilla/focus/Selection_removeRange.html",
+     {}
+    ]
+   ],
+   "focus/Selection_selectAllChildren.html": [
+    [
+     "/_mozilla/focus/Selection_selectAllChildren.html",
+     {}
+    ]
+   ],
+   "focus/Selection_setBaseAndExtent.html": [
+    [
+     "/_mozilla/focus/Selection_setBaseAndExtent.html",
+     {}
+    ]
+   ],
    "html/semantics/forms/textfieldselection/selection-value-interactions.html": [
     [
      "/_mozilla/html/semantics/forms/textfieldselection/selection-value-interactions.html",
      {}
     ]
    ],
    "html/semantics/scripting-1/the-script-element/create-module-script.html": [
     [
@@ -745,16 +834,76 @@
   "fetch/api/redirect/redirect-referrer-mixed-content.js": [
    "f9d7ec9cf9fa8c847e45664b05482e3f8c191385",
    "support"
   ],
   "fetch/api/redirect/redirect-referrer.https.html": [
    "99cbd16b78771f35e075e4012d8dbc5dce3209c0",
    "testharness"
   ],
+  "focus/Range_collapse.html": [
+   "95c795db4cec3ccb1e2632c547e34292364d9c92",
+   "testharness"
+  ],
+  "focus/Range_selectNode.html": [
+   "699bb01144327600e57c715c84cc72ac2d7439d7",
+   "testharness"
+  ],
+  "focus/Range_setEnd.html": [
+   "481cecc11bb7a79bdfa171529bd8519dc69e33d4",
+   "testharness"
+  ],
+  "focus/Range_setStart.html": [
+   "2e23bd20e25da1b4c10c0f8e78162a91ab05a798",
+   "testharness"
+  ],
+  "focus/Selection_addRange.html": [
+   "03b60c8294d4421810d883255ba49784f390fea5",
+   "testharness"
+  ],
+  "focus/Selection_addRange_into_iframe.html": [
+   "8d914033edb0bf1a517cf886f7f9c95dd41ec116",
+   "testharness"
+  ],
+  "focus/Selection_addRange_into_iframe_iframe.html": [
+   "8e8eb8ee04e7a0879828de2c5fb2501c088504a4",
+   "support"
+  ],
+  "focus/Selection_collapse.html": [
+   "1110ffe713c8effbf2b557faec5e367c00e8b5a9",
+   "testharness"
+  ],
+  "focus/Selection_collapseToEnd.html": [
+   "92b38fcaffdee31422690f35c3d9147452b3a2e2",
+   "testharness"
+  ],
+  "focus/Selection_collapseToStart.html": [
+   "e47f9a13430db7d9f2c18ee41f9445ea372f0a18",
+   "testharness"
+  ],
+  "focus/Selection_extend.html": [
+   "385c583117378f34b301a61391178aac6e3d784b",
+   "testharness"
+  ],
+  "focus/Selection_removeAllRanges.html": [
+   "2002fb41dfadb0e91abf5075f9c6117f06201f9a",
+   "testharness"
+  ],
+  "focus/Selection_removeRange.html": [
+   "7950a74c29501a4d7abb86cdcb126928c51c6d9b",
+   "testharness"
+  ],
+  "focus/Selection_selectAllChildren.html": [
+   "6cd254447dea53268ce9ec8ce8a075c7803b5393",
+   "testharness"
+  ],
+  "focus/Selection_setBaseAndExtent.html": [
+   "cd25aacffbaabbeafa443140f9b08ff75a838116",
+   "testharness"
+  ],
   "html/semantics/forms/textfieldselection/selection-value-interactions.html": [
    "6c5e95a8f2f11d106e669eb82b46ffff73d08335",
    "testharness"
   ],
   "html/semantics/scripting-1/the-script-element/create-module-script.html": [
    "3214bced5d81e8001a321aea4c80675b6603b11d",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Range_collapse.html.ini
@@ -0,0 +1,17 @@
+[Range_collapse.html]
+  type: testharness
+
+  [Active element should be 'editor' after Range.collapse(false) of selection between start of the first text node of 'staticBefore' and end of the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.collapse(true) of selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.collapse(false) of selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.collapse(false) 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']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Range_selectNode.html.ini
@@ -0,0 +1,128 @@
+[Range_selectNode.html]
+  type: testharness
+
+  [Active element should be 'editor' after Range.selectNode() with the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNode() with the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNode() with the first text node of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'staticBefore' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNode() with the first text node of 'outerEditor' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'staticInEditor' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNode() with the first text node of 'innerEditor' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'anchor' when active element is the 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'staticBefore' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNode() with the first text node of 'editor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'staticInEditor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNode() with the first text node of 'innerEditor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'anchor' when active element is the 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'staticBefore' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNode() with the first text node of 'editor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNode() with the first text node of 'outerEditor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'staticInEditor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNode() with the first text node of 'anchor' when active element is the 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNode() with the first text node of 'editor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNode() with the first text node of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNode() with the first text node of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNodeContents() with the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNodeContents() with the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNodeContents() with the first text node of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'staticBefore' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNodeContents() with the first text node of 'outerEditor' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'staticInEditor' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNodeContents() with the first text node of 'innerEditor' when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'anchor' when active element is the 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'staticBefore' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNodeContents() with the first text node of 'editor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'staticInEditor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNodeContents() with the first text node of 'innerEditor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'anchor' when active element is the 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'staticBefore' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNodeContents() with the first text node of 'editor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNodeContents() with the first text node of 'outerEditor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'staticInEditor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.selectNodeContents() with the first text node of 'anchor' when active element is the 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.selectNodeContents() with the first text node of 'editor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.selectNodeContents() with the first text node of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.selectNodeContents() with the first text node of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Range_setEnd.html.ini
@@ -0,0 +1,122 @@
+[Range_setEnd.html]
+  type: testharness
+
+  [Active element should be the <body> after Range.setEnd() with start of the first text node of 'staticBefore' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEnd() with start of the first text node of 'editor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEnd() with start of the first text node of 'outerEditor' (before the selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEnd() with start of the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEnd() with start of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEnd() with start of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEnd() with start of the first text node of 'outerEditor' (before the collapsed selection) when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEnd() with start of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEnd() with start of the first text node of 'editor' (before the selection, between end of the first text node of 'editor' and end of the first text node of 'outerEditor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndBefore() with start of the first text node of 'staticBefore' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEndBefore() with start of the first text node of 'editor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEndBefore() with start of the first text node of 'outerEditor' (before the selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEndBefore() with start of the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndBefore() with start of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEndBefore() with start of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEndBefore() with start of the first text node of 'outerEditor' (before the collapsed selection) when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setEndBefore() with start of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEndBefore() with start of the first text node of 'editor' (before the selection, between end of the first text node of 'editor' and end of the first text node of 'outerEditor') when active element is the <body>]
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.setEndAfter() with the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.setEndAfter() with the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.setEndAfter() with the first text node of 'editor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.setEndAfter() with the first text node of 'staticBefore' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEnd() with start of the first text node of 'outerEditor' (after end of the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEnd() with start of the first text node of 'staticAfter' (after end of the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEnd() with start of the first text node of 'outerEditor' (after end of the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEnd() with start of the first text node of 'staticAfter' (after end of the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndAfter() with start of the first text node of 'outerEditor' (after end of the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndAfter() with start of the first text node of 'staticAfter' (after end of the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndAfter() with start of the first text node of 'outerEditor' (after end of the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndAfter() with start of the first text node of 'staticAfter' (after end of the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndBefore() with start of the first text node of 'outerEditor' (after end of the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndBefore() with start of the first text node of 'staticAfter' (after end of the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndBefore() with start of the first text node of 'outerEditor' (after end of the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setEndBefore() with start of the first text node of 'staticAfter' (after end of the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEnd() with end of the first text node of 'editor' (shrunken into 'editor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setEnd() with end of the first text node of 'innerEditor' (shrunken into 'innerEditor') when active element is 'innerEditor' and selection end is in 'staticAfter']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setEndAfter() with end of the first text node of 'editor' (shrunken into 'editor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setEndAfter() with end of the first text node of 'innerEditor' (shrunken into 'innerEditor') when active element is 'innerEditor' and selection end is in 'staticAfter']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Range_setStart.html.ini
@@ -0,0 +1,200 @@
+[Range_setStart.html]
+  type: testharness
+
+  [Active element should be 'editor' after Range.setStart() with end of the first text node of 'editor' (before the selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStart() with end of the first text node of 'outerEditor' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticInEditor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStart() with end of the first text node of 'innerEditor' (before the selection) when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticAfter' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStart() with end of the first text node of 'editor' (before the collapsed selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStart() with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStart() with end of the first text node of 'innerEditor' (before the collapsed selection) when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticAfter' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStart() 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>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStart() 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>]
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() 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']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStart() 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']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStart() with end of the first text node of 'innerEditor' (before the selection, between start of the first text node of 'staticInEditor' and start of the first text node of 'innerEditor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStartAfter() with end of the first text node of 'editor' (before the selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartAfter() with end of the first text node of 'outerEditor' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticInEditor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStartAfter() with end of the first text node of 'innerEditor' (before the selection) when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticAfter' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStartAfter() with end of the first text node of 'editor' (before the collapsed selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartAfter() with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStartAfter() with end of the first text node of 'innerEditor' (before the collapsed selection) when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticAfter' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStartAfter() 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>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartAfter() 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>]
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() 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']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStartAfter() 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']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStartAfter() with end of the first text node of 'innerEditor' (before the selection, between start of the first text node of 'staticInEditor' and start of the first text node of 'innerEditor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStartBefore() with the first text node of 'editor' (before the selection) when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartBefore() with the first text node of 'outerEditor' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStartBefore() with the first text node of 'innerEditor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with the first text node of 'innerEditor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStart() with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticBefore' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'editor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStart() with end of the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with end of the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartAfter() with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticBefore' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'editor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartAfter() with end of the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartAfter() with end of the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with end of the first text node of 'staticBefore' (before the collapsed selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with end of the first text node of 'editor' (before the collapsed selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartBefore() with end of the first text node of 'outerEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with end of the first text node of 'staticInEditor' (before the collapsed selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with end of the first text node of 'staticBefore' (before the selection) when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with end of the first text node of 'editor' (before the selection) when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartBefore() with end of the first text node of 'outerEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with end of the first text node of 'staticInEditor' (before the selection) when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStart() with start of the first text node of 'editor' (shrunken into 'editor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStart() with start of the first text node of 'outerEditor' (shrunken into 'outerEditor') when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStart() with start of the first text node of 'staticInEditor' (shrunken into 'staticInEditor') when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStart() with start of the first text node of 'innerEditor' (shrunken into 'innerEditor') when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Range.setStartBefore() with start of the first text node of 'editor' (shrunken into 'editor') when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Range.setStartBefore() with start of the first text node of 'outerEditor' (shrunken into 'outerEditor') when active element is 'editor']
+    expected: FAIL
+
+  [Active element should be the <body> after Range.setStartBefore() with start of the first text node of 'staticInEditor' (shrunken into 'staticInEditor') when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Range.setStartBefore() with start of the first text node of 'innerEditor' (shrunken into 'innerEditor') when active element is 'outerEditor']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_addRange.html.ini
@@ -0,0 +1,233 @@
+[Selection_addRange.html]
+  type: testharness
+
+  [Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'editor' when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'outerEditor' when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'innerEditor' when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with collapsed range at start of the first text node of 'editor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.addRange() with collapsed range at start of the first text node of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'editor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'outerEditor' and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [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' and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [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' and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'innerEditor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'innerEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.addRange() with a range in start of the first text node of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.addRange() with a range in start of the first text node of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [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 the <body>]
+    expected: FAIL
+
+  [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 the <body>]
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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 'anchor']
+    expected: FAIL
+
+  [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 'anchor']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_addRange_into_iframe.html.ini
@@ -0,0 +1,8 @@
+[Selection_addRange_into_iframe.html]
+  type: testharness
+
+  [Active element should be 'editor1' in the <iframe> after Selection.addRange() but parent's active document should be the <body>]
+    expected: FAIL
+
+  [Active element should be 'editor2' in the <iframe> after Selection.addRange() but parent's active document should be the <body>]
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_collapse.html.ini
@@ -0,0 +1,31 @@
+[Selection_collapse.html]
+  type: testharness
+  [Active element should be 'editor' after Selection.collapse() moving selection from first text node in the <body> 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 the <body> to start of the first text node of 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.collapse() moving selection from first text node in the <body> to start of the first text node of 'innerEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    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 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']
+    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']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_collapseToEnd.html.ini
@@ -0,0 +1,10 @@
+[Selection_collapseToEnd.html]
+  type: testharness
+  [Active element should be 'editor' after Selection.collapseToEnd() with selection between start of the first text node of 'staticBefore' and end of the first text node of 'editor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.collapseToEnd() with selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.collapseToEnd() with selection between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_collapseToStart.html.ini
@@ -0,0 +1,7 @@
+[Selection_collapseToStart.html]
+  type: testharness
+  [Active element should be 'outerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_extend.html.ini
@@ -0,0 +1,25 @@
+[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']
+    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']
+    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']
+    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']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_removeAllRanges.html.ini
@@ -0,0 +1,2 @@
+[Selection_removeAllRanges.html]
+  type: testharness
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_removeRange.html.ini
@@ -0,0 +1,2 @@
+[Selection_removeRange.html]
+  type: testharness
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_selectAllChildren.html.ini
@@ -0,0 +1,65 @@
+[Selection_selectAllChildren.html]
+  type: testharness
+
+  [Active element should be 'editor' after Selection.selectAllChildren() to select the children of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be the <body> 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']
+    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']
+    expected: FAIL
+
+  [Active element should be the <body> 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 'staticInEditor' when active element is 'outerEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' 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']
+    expected: FAIL
+
+  [Active element should be the <body> 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']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.selectAllChildren() to select the children of 'anchor' 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 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.selectAllChildren() to select the children of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.selectAllChildren() to select the children of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/focus/Selection_setBaseAndExtent.html.ini
@@ -0,0 +1,233 @@
+[Selection_setBaseAndExtent.html]
+  type: testharness
+
+  [Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'editor' when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'outerEditor' when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'innerEditor' when active element is the <body> and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'editor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'editor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'outerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'innerEditor' when active element is the <body>]
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'editor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'outerEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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' and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [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' and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [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' and selection is in 'staticInEditor']
+    expected: FAIL
+
+  [Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'innerEditor']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'editor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'outerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'innerEditor' when active element is 'anchor']
+    expected: FAIL
+
+  [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 the <body>]
+    expected: FAIL
+
+  [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 the <body>]
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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']
+    expected: FAIL
+
+  [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 'anchor']
+    expected: FAIL
+
+  [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 'anchor']
+    expected: FAIL
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Range_collapse.html
@@ -0,0 +1,188 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Range.collapse()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().getRangeAt(0).collapse(true);
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Range.collapse(true) of selection between start of the first text node of 'anchor' and end of the first text node of 'anchor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.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 'anchor' and end of the first text node of 'anchor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
+                                             anchor.textNode, anchor.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 'staticBefore' and end of the first text node of 'anchor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().getRangeAt(0).collapse(false);
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Range.collapse(false) of selection between start of the first text node of 'editor' and end of the first text node of 'editor' when active element is 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().getRangeAt(0).collapse(true);
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Range.collapse(true) of selection between start of the first text node of 'editor' and end of the first text node of 'editor' when active element is 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().getRangeAt(0).collapse(false);
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Range.collapse(false) of selection between start of the first text node of 'innerEditor' and end of the first text node of 'innerEditor' when active element is 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().getRangeAt(0).collapse(true);
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Range.collapse(true) of selection between start of the first text node of 'innerEditor' and end of the first text node of 'innerEditor' when active element is 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().getRangeAt(0).collapse(false);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Range.collapse(false) of selection between start of the first text node of 'anchor' and end of the first text node of 'anchor' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().getRangeAt(0).collapse(true);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Range.collapse(true) of selection between start of the first text node of 'anchor' and end of the first text node of 'anchor' when active element is 'anchor'");
+
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().getRangeAt(0).collapse(true);
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Range.collapse(true) of selection between start of the first text node of 'staticBefore' and end of the first text node of 'editor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().getRangeAt(0).collapse(false);
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Range.collapse(false) of selection between start of the first text node of 'staticBefore' and end of the first text node of 'editor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().getRangeAt(0).collapse(true);
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Range.collapse(true) of selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().getRangeAt(0).collapse(false);
+    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 'editor' and end 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, staticInEditor.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 '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'");
+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() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().getRangeAt(0).collapse(false);
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Range.collapse(false) 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'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Range_selectNode.html
@@ -0,0 +1,235 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Range.selectNode() and Range.selectNodeContents()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+function selectNode(aNodeToSelect)
+{
+    document.getSelection().getRangeAt(0).selectNode(aNodeToSelect);
+}
+
+function selectNodeContents(aNodeToSelectItsContents)
+{
+    document.getSelection().getRangeAt(0).selectNodeContents(aNodeToSelectItsContents);
+}
+
+[{ func: selectNode, doingDescription: "Range.selectNode()" },
+ { func: selectNodeContents, doingDescription: "Range.selectNodeContents()" }].forEach((aTest, aIndex, aArray)=>{
+    test(function() {
+        resetFocusAndSelectionRange();
+        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 the <body>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        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 the <body>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        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 the <body>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        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 the <body>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        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 the <body>");
+    test(function() {
+        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'");
+    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'");
+    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'");
+
+    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'");
+    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'");
+    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'");
+
+    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'");
+    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'");
+    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'");
+
+    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);
+        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 'anchor'");
+    test(function() {
+        resetFocusAndSelectionRange(anchor);
+        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 'anchor'");
+    test(function() {
+        resetFocusAndSelectionRange(anchor);
+        aTest.func(staticInEditor.textNode);
+        assert_equals(document.activeElement, anchor.element);
+    }, "Active element should be 'anchor' after " + aTest.doingDescription + " with the first text node of 'staticInEditor' when active element is 'anchor'");
+    test(function() {
+        resetFocusAndSelectionRange(anchor);
+        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 'anchor'");
+    test(function() {
+        resetFocusAndSelectionRange(anchor);
+        aTest.func(anchor.textNode);
+        assert_equals(document.activeElement, anchor.element);
+    }, "Active element should be 'anchor' after " + aTest.doingDescription + " with the first text node of 'anchor' when active element is the 'anchor'");
+});
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Range_setEnd.html
@@ -0,0 +1,326 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Range.setEnd(), Range.setEndAfter() and Range.setEndBefore()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+function setEnd(aNode, aOffset)
+{
+    document.getSelection().getRangeAt(0).setEnd(aNode, aOffset);
+}
+
+function setEndBefore(aNode, aOffset)
+{
+    document.getSelection().getRangeAt(0).setEndBefore(aNode);
+}
+
+function setEndAfter(aNode, aOffset)
+{
+    document.getSelection().getRangeAt(0).setEndAfter(aNode);
+}
+
+// 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'");
+    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();
+        document.getSelection().selectAllChildren(staticInEditor.textNode);
+        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' (before the selection) when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange(innerEditor);
+        document.getSelection().selectAllChildren(innerEditor.textNode);
+        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' (before the selection) when active element is 'innerEditor'");
+    test(function() {
+        resetFocusAndSelectionRange(anchor);
+        document.getSelection().selectAllChildren(anchor.textNode);
+        aTest.func(staticAfter.textNode, 0);
+        assert_equals(document.activeElement, anchor.element);
+    }, "Active element should be 'anchor' after " + aTest.doingDescription + " with start of the first text node of 'staticAfter' (before the selection) when active element is 'anchor'");
+
+    test(function() {
+        resetFocusAndSelectionRange();
+        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'");
+    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();
+        document.getSelection().collapse(staticInEditor.textNode, staticInEditor.textLength);
+        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' (before the collapsed selection) when active element is the <body> and selection is in 'staticInEditor'");
+    test(function() {
+        resetFocusAndSelectionRange(innerEditor);
+        document.getSelection().collapse(innerEditor.textNode, innerEditor.textLength);
+        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' (before the collapsed selection) when active element is 'innerEditor'");
+    test(function() {
+        resetFocusAndSelectionRange(anchor);
+        document.getSelection().collapse(anchor.textNode, anchor.textLength);
+        aTest.func(staticAfter.textNode, 0);
+        assert_equals(document.activeElement, anchor.element);
+    }, "Active element should be 'anchor' after " + aTest.doingDescription + " with start of the first text node of 'staticAfter' (before the collapsed selection) when active element is 'anchor'");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().collapse(anchor.textNode, anchor.textLength);
+        aTest.func(anchor.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 'anchor' (before the collapsed selection) when active element is the <body>");
+
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(staticBefore.textNode, staticBefore.textLength,
+                                                 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 selection, between end of the first text node of 'staticBefore' and end of the first text node of 'editor') when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(editor.textNode, editor.textLength,
+                                                 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 selection, between end of the first text node of 'editor' and end of the first text node of 'outerEditor') when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange(outerEditor);
+        document.getSelection().setBaseAndExtent(outerEditor.textNode, outerEditor.textLength,
+                                                 innerEditor.textNode, innerEditor.textLength);
+        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' (before the selection, between end of the first text node of 'outerEditor' and end of the first text node of 'innerEditor') when active element is 'outerEditor'");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(staticInEditor.textNode, staticInEditor.textLength,
+                                                 innerEditor.textNode, innerEditor.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' (before the selection, between end of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor') when active element is the <body>");
+});
+
+test(function() {
+    resetFocusAndSelectionRange();
+    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'");
+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);
+    document.getSelection().selectAllChildren(innerEditor.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 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    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'");
+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'");
+    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'");
+    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'");
+    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'");
+});
+
+// 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,
+                                                 outerEditor.textNode, outerEditor.textLength);
+        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' (shrunken into 'editor') when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange(outerEditor);
+        document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
+                                                 staticInEditor.textNode, staticInEditor.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' (shrunken into 'outerEditor') when active element is 'outerEditor' and selection end is in 'staticInEditor'");
+    test(function() {
+        resetFocusAndSelectionRange(outerEditor);
+        document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
+                                                 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' (shrunken into 'outerEditor') when active element is 'outerEditor' and selection end is in 'innerEditor'");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                                 staticAfter.textNode, staticAfter.textLength);
+        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' (shrunken into 'innerEditor') when active element is 'innerEditor' and selection end is in 'staticAfter'");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
+                                                 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' (shrunken into 'staticInEditor') when active element is the <body>");
+});
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Range_setStart.html
@@ -0,0 +1,317 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Range.setStart(), Range.setStartAfter() and Range.setStartBefore()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+function setStart(aNode, aOffset)
+{
+    document.getSelection().getRangeAt(0).setStart(aNode, aOffset);
+}
+
+function setStartBefore(aNode, aOffset)
+{
+    document.getSelection().getRangeAt(0).setStartBefore(aNode);
+}
+
+function setStartAfter(aNode, aOffset)
+{
+    document.getSelection().getRangeAt(0).setStartAfter(aNode);
+}
+
+// Range.setStart*() should work same as collapse if specified start position is after its end.
+[{ func: setStart, doingDescription: "Range.setStart()" },
+ { func: setStartAfter, doingDescription: "Range.setStartAfter()" }].forEach((aTest, aIndex, aArray)=>{
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().selectAllChildren(staticBefore.textNode);
+        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) when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange(editor);
+        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'");
+    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'");
+
+    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() {
+        resetFocusAndSelectionRange(editor);
+        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'");
+    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'");
+
+    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>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                                 outerEditor.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 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'");
+    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() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(staticInEditor.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 'staticInEditor' and start of the first text node of 'innerEditor') when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                                 staticAfter.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 selection, between start of the first text node of 'innerEditor' and start of the first text node of 'staticAfter') when active element is the <body>");
+});
+
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().selectAllChildren(staticBefore.textNode);
+    setStartBefore(editor.textNode);
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Range.setStartBefore() with the first text node of 'editor' (before the selection) when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().selectAllChildren(editor.textNode);
+    setStartBefore(outerEditor.textNode);
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Range.setStartBefore() with the first text node of 'outerEditor' (before the selection) when active element is 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    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'");
+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'");
+    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'");
+    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'");
+
+    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'");
+    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'");
+    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'");
+});
+
+// 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,
+                                                 editor.textNode, editor.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' (shrunken into 'editor') when active element is the <body>");
+    test(function() {
+        resetFocusAndSelectionRange(editor);
+        document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                                 outerEditor.textNode, outerEditor.textLength);
+        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'");
+    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() {
+        resetFocusAndSelectionRange();
+        document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                                 anchor.textNode, anchor.textLength);
+        aTest.func(anchor.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 'anchor' (shrunken into 'anchor') when active element is the <body>");
+});
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_addRange.html
@@ -0,0 +1,1121 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.addRange()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+/**
+ * NOTE: When you add/modify something in this file, you should add same test to Selection_setBaseAndExtent.html too.
+ */
+
+
+// Selection.addRange() with collapsed range.
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 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'");
+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'");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    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'");
+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'");
+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'");
+
+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'");
+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'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    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'");
+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'");
+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'");
+
+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);
+}, "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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 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'");
+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'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    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'");
+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'");
+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'");
+
+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);
+}, "Active element should be 'anchor' after Selection.addRange() with collapsed range at start of the first text node of 'staticBefore' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(staticInEditor.textNode, 0);
+    document.getSelection().addRange(range);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.addRange() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(staticAfter.textNode, 0);
+    document.getSelection().addRange(range);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.addRange() with collapsed range at start of the first text node of 'staticAfter' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(anchor.textNode, 0);
+    document.getSelection().addRange(range);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.addRange() with collapsed range at start of the first text node of 'anchor' when active element is 'anchor'");
+
+// Selection.addRange() with non-collapsed range in a node.
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    range.setEnd(outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().addRange(range);
+    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 'outerEditor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+
+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'");
+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);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    range.setEnd(outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().addRange(range);
+    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 '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'");
+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'");
+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'");
+
+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'");
+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);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    range.setEnd(outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().addRange(range);
+    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 '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'");
+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'");
+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'");
+
+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);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'outerEditor' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    range.setEnd(outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().addRange(range);
+    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 'outerEditor' when active element is 'outerEditor' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+
+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'");
+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);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    range.setEnd(outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().addRange(range);
+    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 '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'");
+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'");
+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'");
+
+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);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be the <body> after Selection.addRange() with a range in the first text node of 'staticBefore' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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);
+}, "Active element should be 'editor' after Selection.addRange() with a range in start of the first text node of 'editor' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeAllRanges();
+    var range = document.createRange();
+    range.setStart(outerEditor.textNode, 0);
+    range.setEnd(outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().addRange(range);
+    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 'outerEditor' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "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 'anchor'");
+
+// Selection.addRange() with a range across editing host boundary.
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+
+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'");
+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'");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+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'");
+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'");
+
+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);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' 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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "Active element should be 'anchor' 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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "Active element should be 'anchor' 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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "Active element should be 'anchor' 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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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, anchor.element);
+}, "Active element should be 'anchor' 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 'anchor'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_addRange_into_iframe.html
@@ -0,0 +1,54 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.addRange() into iframe</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body onload="doTest()">
+<p>Here is an iframe:</p>
+<iframe src="Selection_addRange_into_iframe_iframe.html"></iframe>
+<script>
+"use strict";
+
+setup({explicit_done:true});
+
+function doTest() {
+    var selection = document.getSelection();
+    var childDocument = document.getElementsByTagName("iframe")[0].contentDocument;
+    var childSelection = childDocument.getSelection();
+    test(function() {
+        selection.collapse(document.body.firstChild, 0);
+        childSelection.collapse(childDocument.body.firstChild, 0);
+
+        childSelection.removeAllRanges();
+        var range = childDocument.createRange();
+        range.selectNodeContents(childDocument.getElementById("editor1"));
+        childSelection.addRange(range);
+        assert_equals(document.activeElement, document.body);
+        assert_equals(childDocument.activeElement, childDocument.getElementById("editor1"));
+    }, "Active element should be 'editor1' in the <iframe> after Selection.addRange() but parent's active document should be the <body>");
+    test(function() {
+        selection.collapse(document.body.firstChild, 0);
+        childSelection.collapse(childDocument.getElementById("editor1").firstChild, 0);
+
+        childSelection.removeAllRanges();
+        var range = childDocument.createRange();
+        range.selectNodeContents(childDocument.getElementById("editor2"));
+        childSelection.addRange(range);
+        assert_equals(document.activeElement, document.body);
+        assert_equals(childDocument.activeElement, childDocument.getElementById("editor2"));
+    }, "Active element should be 'editor2' in the <iframe> after Selection.addRange() but parent's active document should be the <body>");
+    test(function() {
+        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>");
+
+    done();
+}
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_addRange_into_iframe_iframe.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+<body>
+<p>Here are two editors:</p>
+<div id="editor1" contenteditable>The first editor.</div>
+<div id="editor2" contenteditable>The second editor.</div>
+<div id="non-editor">The non-editable div.</div>
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_collapse.html
@@ -0,0 +1,133 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.collapse()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().collapse(staticBefore.textNode, 0);
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.collapse() not moving selection from first text node in the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body> to start of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body> to start of the first text node of 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body> to start of the first text node of 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body> to start of the first text node of 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body> to start of the first text node of 'anchor'");
+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'");
+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>");
+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'");
+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'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_collapseToEnd.html
@@ -0,0 +1,124 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.collapseToEnd()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.collapseToEnd() with selection between start of the first text node of 'anchor' and end of the first text node of 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.collapseToEnd() with selection between start of the first text node of 'staticBefore' and end of the first text node of 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.collapseToEnd() with selection between start of the first text node of 'editor' and end of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapseToEnd() with selection between start of the first text node of 'innerEditor' and end of the first text node of 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.collapseToEnd() with selection between start of the first text node of 'anchor' and end of the first text node of 'anchor' and 'anchor' has focus before the call");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.collapseToEnd() with selection between start of the first text node of 'staticBefore' and end of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.collapseToEnd() with selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().collapseToEnd();
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapseToEnd() with selection between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_collapseToStart.html
@@ -0,0 +1,131 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.collapseToStart()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.collapseToStart() with selection between start of the first text node of 'anchor' and end of the first text node of 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.collapseToStart() with selection between start of the first text node of 'editor' and end of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'innerEditor' and end of the first text node of 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.collapseToStart() with selection between start of the first text node of 'anchor' and end of the first text node of 'anchor' and 'anchor' has focus before the call");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
+                                             editor.textNode, editor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.collapseToStart() with selection between start of the first text node of 'staticBefore' and end of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             outerEditor.textNode, outerEditor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'outerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'editor' and end of the first text node of 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
+                                             staticInEditor.textNode, staticInEditor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'outerEditor' and end of the first text node of 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'outerEditor' and end of the first text node of 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             staticAfter.textNode, staticAfter.textLength);
+    document.getSelection().collapseToStart();
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.collapseToStart() with selection between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_extend.html
@@ -0,0 +1,168 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.extend()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange();
+    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 'staticBefore' to start of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 'staticBefore' to start of the first text node of 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().extend(staticInEditor.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 'staticBefore' to start of the first text node of 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 'staticBefore' to start of the first text node of 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange();
+    document.getSelection().extend(staticAfter.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 'staticBefore' to start of the first text node of 'staticAfter'");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 'staticBefore' to start of the first text node of 'anchor'");
+
+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'");
+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'");
+
+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);
+    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 'outerEditor' to start of the first text node of 'staticInEditor'");
+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'");
+
+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);
+    document.getSelection().extend(outerEditor.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 'outerEditor'");
+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'");
+
+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);
+    anchor.element.blur();
+    document.getSelection().extend(anchor.textNode, anchor.textLength);
+    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 'anchor' to end of the first text node of 'anchor' and 'anchor' doesn't have focus before the call");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_removeAllRanges.html
@@ -0,0 +1,103 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.removeAllRanges()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange(staticBefore);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.removeAllRanges() when active element is the <body> and selection is at the start of the first text node of 'staticBefore'");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.removeAllRanges() when active element is 'editor' and selection is at the start of the first text node of 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.removeAllRanges() when active element is 'outerEditor' and selection is at the start of the first text node of 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.removeAllRanges() when active element is the <body> and selection is at the start of the first text node of 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.removeAllRanges() when active element is 'innerEditor' and selection is at the start of the first text node of 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticAfter);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.removeAllRanges() when active element is the <body> and selection is at the start of the first text node of 'staticAfter'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeAllRanges();
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.removeAllRanges() when active element is 'anchor' and selection is at the start of the first text node of 'anchor'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_removeRange.html
@@ -0,0 +1,103 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.removeRange()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange(staticBefore);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.removeRange() to remove selected range at the start of the first text node of 'staticBefore' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange(editor);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, editor.element);
+}, "Active element should be 'editor' after Selection.removeRange() to remove selected range at the start of the first text node of 'editor' when active element is 'editor'");
+test(function() {
+    resetFocusAndSelectionRange(outerEditor);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, outerEditor.element);
+}, "Active element should be 'outerEditor' after Selection.removeRange() to remove selected range at the start of the first text node of 'outerEditor' when active element is 'outerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.removeRange() to remove selected range at the start of the first text node of 'staticInEditor' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange(innerEditor);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, innerEditor.element);
+}, "Active element should be 'innerEditor' after Selection.removeRange() to remove selected range at the start of the first text node of 'innerEditor' when active element is 'innerEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticAfter);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, document.body);
+}, "Active element should be the <body> after Selection.removeRange() to remove selected range at the start of the first text node of 'staticAfter' when active element is the <body>");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().removeRange(document.getSelection().getRangeAt(0));
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.removeRange() to remove selected range at the start of the first text node of 'anchor' when active element is 'anchor'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_selectAllChildren.html
@@ -0,0 +1,222 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.selectAllChildren()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+
+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);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().selectAllChildren(staticInEditor.element);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.selectAllChildren() to select the children of 'staticInEditor' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().selectAllChildren(anchor.element);
+    assert_equals(document.activeElement, anchor.element);
+}, "Active element should be 'anchor' after Selection.selectAllChildren() to select the children of 'anchor' when active element is 'anchor'");
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/focus/Selection_setBaseAndExtent.html
@@ -0,0 +1,805 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>focus move tests caused by a call of Selection.setBaseAndExtent()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p id="staticBefore">static text</p>
+<div id="editor" contenteditable><p>content of editor</p></div>
+<div id="outerEditor" contenteditable
+><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
+><p>static content of outer editor</p><div id="innerEditor" contenteditable
+><p>content of inner editor</p></div></div></div>
+<p id="staticAfter">static text</p>
+<p><a id="anchor" href="about:blank">anchor</a></p>
+<script>
+"use strict";
+
+var staticBefore = {
+    element: document.getElementById("staticBefore"),
+    textNode: document.getElementById("staticBefore").firstChild,
+    textLength: document.getElementById("staticBefore").firstChild.length
+};
+var editor = {
+    element: document.getElementById("editor"),
+    textNode: document.getElementById("editor").firstChild.firstChild,
+    textLength: document.getElementById("editor").firstChild.firstChild.length
+};
+var outerEditor = {
+    element: document.getElementById("outerEditor"),
+    textNode: document.getElementById("outerEditor").firstChild.firstChild,
+    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
+};
+var staticInEditor = {
+    element: document.getElementById("staticInEditor"),
+    textNode: document.getElementById("staticInEditor").firstChild,
+    textLength: document.getElementById("staticInEditor").firstChild.length
+};
+var innerEditor = {
+    element: document.getElementById("innerEditor"),
+    textNode: document.getElementById("innerEditor").firstChild.firstChild,
+    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
+};
+var staticAfter = {
+    element: document.getElementById("staticAfter"),
+    textNode: document.getElementById("staticAfter").firstChild,
+    textLength: document.getElementById("staticAfter").firstChild.length
+};
+var anchor = {
+    element: document.getElementById("anchor"),
+    textNode: document.getElementById("anchor").firstChild,
+    textLength: document.getElementById("anchor").firstChild.length
+};
+
+function resetFocusAndSelectionRange(aFocus)
+{
+    document.getSelection().removeAllRanges();
+    if (document.activeElement) {
+        document.activeElement.blur();
+    }
+    if (aFocus) {
+        aFocus.element.focus();
+        document.getSelection().collapse(aFocus.textNode, 0);
+    } else {
+        document.getSelection().collapse(staticBefore.textNode, 0);
+    }
+}
+
+/**
+ * NOTE: When you add/modify something in this file, you should add same test to Selection_addRange.html too.
+ */
+
+// Selection.setBaseAndExtent() with collapsed range.
+test(function() {
+    resetFocusAndSelectionRange();
+    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>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 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'");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+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'");
+
+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() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 the <body> and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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 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'");
+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'");
+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'");
+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'");
+
+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() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
+                                             staticInEditor.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 'staticInEditor' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
+                                             staticAfter.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 'staticAfter' when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.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 'anchor' when active element is 'anchor'");
+
+// Selection.setBaseAndExtent() with non-collapsed range in a node.
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 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'");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+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'");
+
+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() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' and selection is in 'staticInEditor'");
+test(function() {
+    resetFocusAndSelectionRange(staticInEditor);
+    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' 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'");
+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'");
+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'");
+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'");
+
+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() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
+                                             staticInEditor.textNode, staticInEditor.textLength);
+    assert_equals(document.activeElement, anchor.element);
+}, "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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
+                                             staticAfter.textNode, staticAfter.textLength);
+    assert_equals(document.activeElement, anchor.element);
+}, "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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
+                                             anchor.textNode, anchor.textLength);
+    assert_equals(document.activeElement, anchor.element);
+}, "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 'anchor'");
+
+// Selection.setBaseAndExtent() with a range across editing host boundary.
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 the <body>");
+test(function() {
+    resetFocusAndSelectionRange();
+    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 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'");
+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'");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+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'");
+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'");
+
+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'");
+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'");
+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'");
+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'");
+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'");
+
+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() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(editor.textNode, 0,
+                                             outerEditor.textNode, outerEditor.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 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
+                                             innerEditor.textNode, innerEditor.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 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    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 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             staticAfter.textNode, staticAfter.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 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'anchor'");
+test(function() {
+    resetFocusAndSelectionRange(anchor);
+    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
+                                             anchor.textNode, anchor.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 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'anchor'");
+</script>