tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Selection_setBaseAndExtent.html (68002B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>focus move tests caused by a call of Selection.setBaseAndExtent()</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <body>
      7 <div style="height: 3000px;">Spacer to check whether or not page was scrolled down to focused editor</div>
      8 <p id="staticBefore">static text</p>
      9 <div id="editor" contenteditable><p>content of editor</p></div>
     10 <div id="outerEditor" contenteditable
     11 ><p>content of outer editor</p><div id="staticInEditor" contenteditable="false"
     12 ><p>static content of outer editor</p><div id="innerEditor" contenteditable
     13 ><p>content of inner editor</p></div></div></div>
     14 <p id="staticAfter">static text</p>
     15 <p><a id="anchor" href="about:blank">anchor</a></p>
     16 <script>
     17 "use strict";
     18 
     19 var staticBefore = {
     20    element: document.getElementById("staticBefore"),
     21    textNode: document.getElementById("staticBefore").firstChild,
     22    textLength: document.getElementById("staticBefore").firstChild.length
     23 };
     24 var editor = {
     25    element: document.getElementById("editor"),
     26    textNode: document.getElementById("editor").firstChild.firstChild,
     27    textLength: document.getElementById("editor").firstChild.firstChild.length
     28 };
     29 var outerEditor = {
     30    element: document.getElementById("outerEditor"),
     31    textNode: document.getElementById("outerEditor").firstChild.firstChild,
     32    textLength: document.getElementById("outerEditor").firstChild.firstChild.length
     33 };
     34 var staticInEditor = {
     35    element: document.getElementById("staticInEditor"),
     36    textNode: document.getElementById("staticInEditor").firstChild,
     37    textLength: document.getElementById("staticInEditor").firstChild.length
     38 };
     39 var innerEditor = {
     40    element: document.getElementById("innerEditor"),
     41    textNode: document.getElementById("innerEditor").firstChild.firstChild,
     42    textLength: document.getElementById("innerEditor").firstChild.firstChild.length
     43 };
     44 var staticAfter = {
     45    element: document.getElementById("staticAfter"),
     46    textNode: document.getElementById("staticAfter").firstChild,
     47    textLength: document.getElementById("staticAfter").firstChild.length
     48 };
     49 var anchor = {
     50    element: document.getElementById("anchor"),
     51    textNode: document.getElementById("anchor").firstChild,
     52    textLength: document.getElementById("anchor").firstChild.length
     53 };
     54 
     55 function resetFocusAndSelectionRange(aFocus)
     56 {
     57    document.getSelection().removeAllRanges();
     58    if (document.activeElement) {
     59        document.activeElement.blur();
     60    }
     61    if (aFocus) {
     62        aFocus.element.focus();
     63        document.getSelection().collapse(aFocus.textNode, 0);
     64    } else {
     65        document.getSelection().collapse(staticBefore.textNode, 0);
     66    }
     67    document.documentElement.scrollTop = 0;
     68 }
     69 
     70 /**
     71 * NOTE: When you add/modify something in this file, you should add same test to Selection_addRange.html too.
     72 */
     73 
     74 // Selection.setBaseAndExtent() with collapsed range.
     75 test(function() {
     76    resetFocusAndSelectionRange();
     77    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
     78                                             staticBefore.textNode, 0);
     79    assert_equals(document.activeElement, document.body);
     80    assert_equals(document.documentElement.scrollTop, 0);
     81 }, "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>");
     82 test(function() {
     83    resetFocusAndSelectionRange();
     84    document.getSelection().setBaseAndExtent(editor.textNode, 0,
     85                                             editor.textNode, 0);
     86    assert_equals(document.activeElement, editor.element);
     87    assert_equals(document.documentElement.scrollTop, 0);
     88 }, "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>");
     89 test(function() {
     90    resetFocusAndSelectionRange();
     91    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
     92                                             outerEditor.textNode, 0);
     93    assert_equals(document.activeElement, outerEditor.element);
     94    assert_equals(document.documentElement.scrollTop, 0);
     95 }, "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>");
     96 test(function() {
     97    resetFocusAndSelectionRange();
     98    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
     99                                             staticInEditor.textNode, 0);
    100    assert_equals(document.activeElement, document.body);
    101    assert_equals(document.documentElement.scrollTop, 0);
    102 }, "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>");
    103 test(function() {
    104    resetFocusAndSelectionRange();
    105    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    106                                             innerEditor.textNode, 0);
    107    assert_equals(document.activeElement, innerEditor.element);
    108    assert_equals(document.documentElement.scrollTop, 0);
    109 }, "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>");
    110 test(function() {
    111    resetFocusAndSelectionRange();
    112    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    113                                             staticAfter.textNode, 0);
    114    assert_equals(document.activeElement, document.body);
    115    assert_equals(document.documentElement.scrollTop, 0);
    116 }, "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>");
    117 test(function() {
    118    resetFocusAndSelectionRange();
    119    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    120                                             anchor.textNode, 0);
    121    assert_equals(document.activeElement, document.body);
    122    assert_equals(document.documentElement.scrollTop, 0);
    123 }, "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>");
    124 
    125 test(function() {
    126    resetFocusAndSelectionRange(editor);
    127    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    128                                             staticBefore.textNode, 0);
    129    assert_equals(document.activeElement, editor.element);
    130    assert_equals(document.documentElement.scrollTop, 0);
    131 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'editor'");
    132 test(function() {
    133    resetFocusAndSelectionRange(editor);
    134    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    135                                             editor.textNode, 0);
    136    assert_equals(document.activeElement, editor.element);
    137    assert_equals(document.documentElement.scrollTop, 0);
    138 }, "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'");
    139 test(function() {
    140    resetFocusAndSelectionRange(editor);
    141    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    142                                             outerEditor.textNode, 0);
    143    assert_equals(document.activeElement, outerEditor.element);
    144    assert_equals(document.documentElement.scrollTop, 0);
    145 }, "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'");
    146 test(function() {
    147    resetFocusAndSelectionRange(editor);
    148    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    149                                             staticInEditor.textNode, 0);
    150    assert_equals(document.activeElement, editor.element);
    151    assert_equals(document.documentElement.scrollTop, 0);
    152 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'editor'");
    153 test(function() {
    154    resetFocusAndSelectionRange(editor);
    155    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    156                                             innerEditor.textNode, 0);
    157    assert_equals(document.activeElement, innerEditor.element);
    158    assert_equals(document.documentElement.scrollTop, 0);
    159 }, "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'");
    160 test(function() {
    161    resetFocusAndSelectionRange(editor);
    162    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    163                                             staticAfter.textNode, 0);
    164    assert_equals(document.activeElement, editor.element);
    165    assert_equals(document.documentElement.scrollTop, 0);
    166 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'editor'");
    167 test(function() {
    168    resetFocusAndSelectionRange(editor);
    169    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    170                                             anchor.textNode, 0);
    171    assert_equals(document.activeElement, editor.element);
    172    assert_equals(document.documentElement.scrollTop, 0);
    173 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'editor'");
    174 
    175 test(function() {
    176    resetFocusAndSelectionRange(outerEditor);
    177    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    178                                             staticBefore.textNode, 0);
    179    assert_equals(document.activeElement, outerEditor.element);
    180    assert_equals(document.documentElement.scrollTop, 0);
    181 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'outerEditor'");
    182 test(function() {
    183    resetFocusAndSelectionRange(outerEditor);
    184    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    185                                             editor.textNode, 0);
    186    assert_equals(document.activeElement, editor.element);
    187    assert_equals(document.documentElement.scrollTop, 0);
    188 }, "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'");
    189 test(function() {
    190    resetFocusAndSelectionRange(outerEditor);
    191    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    192                                             outerEditor.textNode, 0);
    193    assert_equals(document.activeElement, outerEditor.element);
    194    assert_equals(document.documentElement.scrollTop, 0);
    195 }, "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'");
    196 test(function() {
    197    resetFocusAndSelectionRange(outerEditor);
    198    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    199                                             staticInEditor.textNode, 0);
    200    assert_equals(document.activeElement, outerEditor.element);
    201    assert_equals(document.documentElement.scrollTop, 0);
    202 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
    203 test(function() {
    204    resetFocusAndSelectionRange(outerEditor);
    205    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    206                                             innerEditor.textNode, 0);
    207    assert_equals(document.activeElement, innerEditor.element);
    208    assert_equals(document.documentElement.scrollTop, 0);
    209 }, "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'");
    210 test(function() {
    211    resetFocusAndSelectionRange(outerEditor);
    212    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    213                                             staticAfter.textNode, 0);
    214    assert_equals(document.activeElement, outerEditor.element);
    215    assert_equals(document.documentElement.scrollTop, 0);
    216 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'outerEditor'");
    217 test(function() {
    218    resetFocusAndSelectionRange(outerEditor);
    219    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    220                                             anchor.textNode, 0);
    221    assert_equals(document.activeElement, outerEditor.element);
    222    assert_equals(document.documentElement.scrollTop, 0);
    223 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'outerEditor'");
    224 
    225 test(function() {
    226    resetFocusAndSelectionRange(staticInEditor);
    227    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    228                                             staticBefore.textNode, 0);
    229    assert_equals(document.activeElement, document.body);
    230    assert_equals(document.documentElement.scrollTop, 0);
    231 }, "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'");
    232 test(function() {
    233    resetFocusAndSelectionRange(staticInEditor);
    234    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    235                                             editor.textNode, 0);
    236    assert_equals(document.activeElement, editor.element);
    237    assert_equals(document.documentElement.scrollTop, 0);
    238 }, "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'");
    239 test(function() {
    240    resetFocusAndSelectionRange(staticInEditor);
    241    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    242                                             outerEditor.textNode, 0);
    243    assert_equals(document.activeElement, outerEditor.element);
    244    assert_equals(document.documentElement.scrollTop, 0);
    245 }, "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'");
    246 test(function() {
    247    resetFocusAndSelectionRange(staticInEditor);
    248    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    249                                             staticInEditor.textNode, 0);
    250    assert_equals(document.activeElement, document.body);
    251    assert_equals(document.documentElement.scrollTop, 0);
    252 }, "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'");
    253 test(function() {
    254    resetFocusAndSelectionRange(staticInEditor);
    255    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    256                                             innerEditor.textNode, 0);
    257    assert_equals(document.activeElement, innerEditor.element);
    258    assert_equals(document.documentElement.scrollTop, 0);
    259 }, "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'");
    260 test(function() {
    261    resetFocusAndSelectionRange(staticInEditor);
    262    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    263                                             staticAfter.textNode, 0);
    264    assert_equals(document.activeElement, document.body);
    265    assert_equals(document.documentElement.scrollTop, 0);
    266 }, "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'");
    267 test(function() {
    268    resetFocusAndSelectionRange(staticInEditor);
    269    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    270                                             anchor.textNode, 0);
    271    assert_equals(document.activeElement, document.body);
    272    assert_equals(document.documentElement.scrollTop, 0);
    273 }, "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'");
    274 
    275 test(function() {
    276    resetFocusAndSelectionRange(innerEditor);
    277    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    278                                             staticBefore.textNode, 0);
    279    assert_equals(document.activeElement, innerEditor.element);
    280    assert_equals(document.documentElement.scrollTop, 0);
    281 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticBefore' when active element is 'innerEditor'");
    282 test(function() {
    283    resetFocusAndSelectionRange(innerEditor);
    284    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    285                                             editor.textNode, 0);
    286    assert_equals(document.activeElement, editor.element);
    287    assert_equals(document.documentElement.scrollTop, 0);
    288 }, "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'");
    289 test(function() {
    290    resetFocusAndSelectionRange(innerEditor);
    291    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    292                                             outerEditor.textNode, 0);
    293    assert_equals(document.activeElement, outerEditor.element);
    294    assert_equals(document.documentElement.scrollTop, 0);
    295 }, "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'");
    296 test(function() {
    297    resetFocusAndSelectionRange(innerEditor);
    298    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    299                                             staticInEditor.textNode, 0);
    300    assert_equals(document.activeElement, innerEditor.element);
    301    assert_equals(document.documentElement.scrollTop, 0);
    302 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
    303 test(function() {
    304    resetFocusAndSelectionRange(innerEditor);
    305    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    306                                             innerEditor.textNode, 0);
    307    assert_equals(document.activeElement, innerEditor.element);
    308    assert_equals(document.documentElement.scrollTop, 0);
    309 }, "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'");
    310 test(function() {
    311    resetFocusAndSelectionRange(innerEditor);
    312    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    313                                             staticAfter.textNode, 0);
    314    assert_equals(document.activeElement, innerEditor.element);
    315    assert_equals(document.documentElement.scrollTop, 0);
    316 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'staticAfter' when active element is 'innerEditor'");
    317 test(function() {
    318    resetFocusAndSelectionRange(innerEditor);
    319    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    320                                             anchor.textNode, 0);
    321    assert_equals(document.activeElement, innerEditor.element);
    322    assert_equals(document.documentElement.scrollTop, 0);
    323 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with collapsed range at start of the first text node of 'anchor' when active element is 'innerEditor'");
    324 
    325 test(function() {
    326    resetFocusAndSelectionRange(anchor);
    327    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    328                                             staticBefore.textNode, 0);
    329    assert_equals(document.activeElement, anchor.element);
    330    assert_equals(document.documentElement.scrollTop, 0);
    331 }, "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'");
    332 test(function() {
    333    resetFocusAndSelectionRange(anchor);
    334    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    335                                             editor.textNode, 0);
    336    assert_equals(document.activeElement, editor.element);
    337    assert_equals(document.documentElement.scrollTop, 0);
    338 }, "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'");
    339 test(function() {
    340    resetFocusAndSelectionRange(anchor);
    341    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    342                                             outerEditor.textNode, 0);
    343    assert_equals(document.activeElement, outerEditor.element);
    344    assert_equals(document.documentElement.scrollTop, 0);
    345 }, "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'");
    346 test(function() {
    347    resetFocusAndSelectionRange(anchor);
    348    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    349                                             staticInEditor.textNode, 0);
    350    assert_equals(document.activeElement, anchor.element);
    351    assert_equals(document.documentElement.scrollTop, 0);
    352 }, "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'");
    353 test(function() {
    354    resetFocusAndSelectionRange(anchor);
    355    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    356                                             innerEditor.textNode, 0);
    357    assert_equals(document.activeElement, innerEditor.element);
    358    assert_equals(document.documentElement.scrollTop, 0);
    359 }, "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'");
    360 test(function() {
    361    resetFocusAndSelectionRange(anchor);
    362    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    363                                             staticAfter.textNode, 0);
    364    assert_equals(document.activeElement, anchor.element);
    365    assert_equals(document.documentElement.scrollTop, 0);
    366 }, "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'");
    367 test(function() {
    368    resetFocusAndSelectionRange(anchor);
    369    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    370                                             anchor.textNode, 0);
    371    assert_equals(document.activeElement, anchor.element);
    372    assert_equals(document.documentElement.scrollTop, 0);
    373 }, "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'");
    374 
    375 // Selection.setBaseAndExtent() with non-collapsed range in a node.
    376 test(function() {
    377    resetFocusAndSelectionRange();
    378    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    379                                             staticBefore.textNode, staticBefore.textLength);
    380    assert_equals(document.activeElement, document.body);
    381    assert_equals(document.documentElement.scrollTop, 0);
    382 }, "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>");
    383 test(function() {
    384    resetFocusAndSelectionRange();
    385    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    386                                             editor.textNode, editor.textLength);
    387    assert_equals(document.activeElement, editor.element);
    388    assert_equals(document.documentElement.scrollTop, 0);
    389 }, "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>");
    390 test(function() {
    391    resetFocusAndSelectionRange();
    392    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    393                                             outerEditor.textNode, outerEditor.textLength);
    394    assert_equals(document.activeElement, outerEditor.element);
    395    assert_equals(document.documentElement.scrollTop, 0);
    396 }, "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>");
    397 test(function() {
    398    resetFocusAndSelectionRange();
    399    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    400                                             staticInEditor.textNode, staticInEditor.textLength);
    401    assert_equals(document.activeElement, document.body);
    402    assert_equals(document.documentElement.scrollTop, 0);
    403 }, "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>");
    404 test(function() {
    405    resetFocusAndSelectionRange();
    406    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    407                                             innerEditor.textNode, innerEditor.textLength);
    408    assert_equals(document.activeElement, innerEditor.element);
    409    assert_equals(document.documentElement.scrollTop, 0);
    410 }, "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>");
    411 test(function() {
    412    resetFocusAndSelectionRange();
    413    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    414                                             staticAfter.textNode, staticAfter.textLength);
    415    assert_equals(document.activeElement, document.body);
    416    assert_equals(document.documentElement.scrollTop, 0);
    417 }, "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>");
    418 test(function() {
    419    resetFocusAndSelectionRange();
    420    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    421                                             anchor.textNode, anchor.textLength);
    422    assert_equals(document.activeElement, document.body);
    423    assert_equals(document.documentElement.scrollTop, 0);
    424 }, "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>");
    425 
    426 test(function() {
    427    resetFocusAndSelectionRange(editor);
    428    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    429                                             staticBefore.textNode, staticBefore.textLength);
    430    assert_equals(document.activeElement, editor.element);
    431    assert_equals(document.documentElement.scrollTop, 0);
    432 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'editor'");
    433 test(function() {
    434    resetFocusAndSelectionRange(editor);
    435    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    436                                             editor.textNode, editor.textLength);
    437    assert_equals(document.activeElement, editor.element);
    438    assert_equals(document.documentElement.scrollTop, 0);
    439 }, "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'");
    440 test(function() {
    441    resetFocusAndSelectionRange(editor);
    442    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    443                                             outerEditor.textNode, outerEditor.textLength);
    444    assert_equals(document.activeElement, outerEditor.element);
    445    assert_equals(document.documentElement.scrollTop, 0);
    446 }, "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'");
    447 test(function() {
    448    resetFocusAndSelectionRange(editor);
    449    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    450                                             staticInEditor.textNode, staticInEditor.textLength);
    451    assert_equals(document.activeElement, editor.element);
    452    assert_equals(document.documentElement.scrollTop, 0);
    453 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'editor'");
    454 test(function() {
    455    resetFocusAndSelectionRange(editor);
    456    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    457                                             innerEditor.textNode, innerEditor.textLength);
    458    assert_equals(document.activeElement, innerEditor.element);
    459    assert_equals(document.documentElement.scrollTop, 0);
    460 }, "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'");
    461 test(function() {
    462    resetFocusAndSelectionRange(editor);
    463    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    464                                             staticAfter.textNode, staticAfter.textLength);
    465    assert_equals(document.activeElement, editor.element);
    466    assert_equals(document.documentElement.scrollTop, 0);
    467 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'editor'");
    468 test(function() {
    469    resetFocusAndSelectionRange(editor);
    470    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    471                                             anchor.textNode, anchor.textLength);
    472    assert_equals(document.activeElement, editor.element);
    473    assert_equals(document.documentElement.scrollTop, 0);
    474 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'editor'");
    475 
    476 test(function() {
    477    resetFocusAndSelectionRange(outerEditor);
    478    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    479                                             staticBefore.textNode, staticBefore.textLength);
    480    assert_equals(document.activeElement, outerEditor.element);
    481    assert_equals(document.documentElement.scrollTop, 0);
    482 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'outerEditor'");
    483 test(function() {
    484    resetFocusAndSelectionRange(outerEditor);
    485    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    486                                             editor.textNode, editor.textLength);
    487    assert_equals(document.activeElement, editor.element);
    488    assert_equals(document.documentElement.scrollTop, 0);
    489 }, "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'");
    490 test(function() {
    491    resetFocusAndSelectionRange(outerEditor);
    492    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    493                                             outerEditor.textNode, outerEditor.textLength);
    494    assert_equals(document.activeElement, outerEditor.element);
    495    assert_equals(document.documentElement.scrollTop, 0);
    496 }, "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'");
    497 test(function() {
    498    resetFocusAndSelectionRange(outerEditor);
    499    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    500                                             staticInEditor.textNode, staticInEditor.textLength);
    501    assert_equals(document.activeElement, outerEditor.element);
    502    assert_equals(document.documentElement.scrollTop, 0);
    503 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'outerEditor'");
    504 test(function() {
    505    resetFocusAndSelectionRange(outerEditor);
    506    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    507                                             innerEditor.textNode, innerEditor.textLength);
    508    assert_equals(document.activeElement, innerEditor.element);
    509    assert_equals(document.documentElement.scrollTop, 0);
    510 }, "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'");
    511 test(function() {
    512    resetFocusAndSelectionRange(outerEditor);
    513    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    514                                             staticAfter.textNode, staticAfter.textLength);
    515    assert_equals(document.activeElement, outerEditor.element);
    516    assert_equals(document.documentElement.scrollTop, 0);
    517 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'outerEditor'");
    518 test(function() {
    519    resetFocusAndSelectionRange(outerEditor);
    520    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    521                                             anchor.textNode, anchor.textLength);
    522    assert_equals(document.activeElement, outerEditor.element);
    523    assert_equals(document.documentElement.scrollTop, 0);
    524 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'outerEditor'");
    525 
    526 test(function() {
    527    resetFocusAndSelectionRange(staticInEditor);
    528    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    529                                             staticBefore.textNode, staticBefore.textLength);
    530    assert_equals(document.activeElement, document.body);
    531    assert_equals(document.documentElement.scrollTop, 0);
    532 }, "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'");
    533 test(function() {
    534    resetFocusAndSelectionRange(staticInEditor);
    535    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    536                                             editor.textNode, editor.textLength);
    537    assert_equals(document.activeElement, editor.element);
    538    assert_equals(document.documentElement.scrollTop, 0);
    539 }, "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'");
    540 test(function() {
    541    resetFocusAndSelectionRange(staticInEditor);
    542    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    543                                             outerEditor.textNode, outerEditor.textLength);
    544    assert_equals(document.activeElement, outerEditor.element);
    545    assert_equals(document.documentElement.scrollTop, 0);
    546 }, "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'");
    547 test(function() {
    548    resetFocusAndSelectionRange(staticInEditor);
    549    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    550                                             staticInEditor.textNode, staticInEditor.textLength);
    551    assert_equals(document.activeElement, document.body);
    552    assert_equals(document.documentElement.scrollTop, 0);
    553 }, "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'");
    554 test(function() {
    555    resetFocusAndSelectionRange(staticInEditor);
    556    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    557                                             innerEditor.textNode, innerEditor.textLength);
    558    assert_equals(document.activeElement, innerEditor.element);
    559    assert_equals(document.documentElement.scrollTop, 0);
    560 }, "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'");
    561 test(function() {
    562    resetFocusAndSelectionRange(staticInEditor);
    563    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    564                                             staticAfter.textNode, staticAfter.textLength);
    565    assert_equals(document.activeElement, document.body);
    566    assert_equals(document.documentElement.scrollTop, 0);
    567 }, "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'");
    568 test(function() {
    569    resetFocusAndSelectionRange(staticInEditor);
    570    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    571                                             anchor.textNode, anchor.textLength);
    572    assert_equals(document.activeElement, document.body);
    573    assert_equals(document.documentElement.scrollTop, 0);
    574 }, "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'");
    575 
    576 test(function() {
    577    resetFocusAndSelectionRange(innerEditor);
    578    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    579                                             staticBefore.textNode, staticBefore.textLength);
    580    assert_equals(document.activeElement, innerEditor.element);
    581    assert_equals(document.documentElement.scrollTop, 0);
    582 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'innerEditor'");
    583 test(function() {
    584    resetFocusAndSelectionRange(innerEditor);
    585    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    586                                             editor.textNode, editor.textLength);
    587    assert_equals(document.activeElement, editor.element);
    588    assert_equals(document.documentElement.scrollTop, 0);
    589 }, "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'");
    590 test(function() {
    591    resetFocusAndSelectionRange(innerEditor);
    592    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    593                                             outerEditor.textNode, outerEditor.textLength);
    594    assert_equals(document.activeElement, outerEditor.element);
    595    assert_equals(document.documentElement.scrollTop, 0);
    596 }, "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'");
    597 test(function() {
    598    resetFocusAndSelectionRange(innerEditor);
    599    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    600                                             staticInEditor.textNode, staticInEditor.textLength);
    601    assert_equals(document.activeElement, innerEditor.element);
    602    assert_equals(document.documentElement.scrollTop, 0);
    603 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticInEditor' when active element is 'innerEditor'");
    604 test(function() {
    605    resetFocusAndSelectionRange(innerEditor);
    606    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    607                                             innerEditor.textNode, innerEditor.textLength);
    608    assert_equals(document.activeElement, innerEditor.element);
    609    assert_equals(document.documentElement.scrollTop, 0);
    610 }, "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'");
    611 test(function() {
    612    resetFocusAndSelectionRange(innerEditor);
    613    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    614                                             staticAfter.textNode, staticAfter.textLength);
    615    assert_equals(document.activeElement, innerEditor.element);
    616    assert_equals(document.documentElement.scrollTop, 0);
    617 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'staticAfter' when active element is 'innerEditor'");
    618 test(function() {
    619    resetFocusAndSelectionRange(innerEditor);
    620    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    621                                             anchor.textNode, anchor.textLength);
    622    assert_equals(document.activeElement, innerEditor.element);
    623    assert_equals(document.documentElement.scrollTop, 0);
    624 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range in start of the first text node of 'anchor' when active element is 'innerEditor'");
    625 
    626 test(function() {
    627    resetFocusAndSelectionRange(anchor);
    628    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    629                                             staticBefore.textNode, staticBefore.textLength);
    630    assert_equals(document.activeElement, anchor.element);
    631    assert_equals(document.documentElement.scrollTop, 0);
    632 }, "Active element should be the <body> after Selection.setBaseAndExtent() with a range in the first text node of 'staticBefore' when active element is 'anchor'");
    633 test(function() {
    634    resetFocusAndSelectionRange(anchor);
    635    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    636                                             editor.textNode, editor.textLength);
    637    assert_equals(document.activeElement, editor.element);
    638    assert_equals(document.documentElement.scrollTop, 0);
    639 }, "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'");
    640 test(function() {
    641    resetFocusAndSelectionRange(anchor);
    642    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    643                                             outerEditor.textNode, outerEditor.textLength);
    644    assert_equals(document.activeElement, outerEditor.element);
    645    assert_equals(document.documentElement.scrollTop, 0);
    646 }, "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'");
    647 test(function() {
    648    resetFocusAndSelectionRange(anchor);
    649    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    650                                             staticInEditor.textNode, staticInEditor.textLength);
    651    assert_equals(document.activeElement, anchor.element);
    652    assert_equals(document.documentElement.scrollTop, 0);
    653 }, "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'");
    654 test(function() {
    655    resetFocusAndSelectionRange(anchor);
    656    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    657                                             innerEditor.textNode, innerEditor.textLength);
    658    assert_equals(document.activeElement, innerEditor.element);
    659    assert_equals(document.documentElement.scrollTop, 0);
    660 }, "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'");
    661 test(function() {
    662    resetFocusAndSelectionRange(anchor);
    663    document.getSelection().setBaseAndExtent(staticAfter.textNode, 0,
    664                                             staticAfter.textNode, staticAfter.textLength);
    665    assert_equals(document.activeElement, anchor.element);
    666    assert_equals(document.documentElement.scrollTop, 0);
    667 }, "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'");
    668 test(function() {
    669    resetFocusAndSelectionRange(anchor);
    670    document.getSelection().setBaseAndExtent(anchor.textNode, 0,
    671                                             anchor.textNode, anchor.textLength);
    672    assert_equals(document.activeElement, anchor.element);
    673    assert_equals(document.documentElement.scrollTop, 0);
    674 }, "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'");
    675 
    676 // Selection.setBaseAndExtent() with a range across editing host boundary.
    677 test(function() {
    678    resetFocusAndSelectionRange();
    679    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    680                                             editor.textNode, editor.textLength);
    681    assert_equals(document.activeElement, document.body);
    682    assert_equals(document.documentElement.scrollTop, 0);
    683 }, "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>");
    684 test(function() {
    685    resetFocusAndSelectionRange();
    686    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    687                                             outerEditor.textNode, outerEditor.textLength);
    688    assert_equals(document.activeElement, document.body);
    689    assert_equals(document.documentElement.scrollTop, 0);
    690 }, "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>");
    691 test(function() {
    692    resetFocusAndSelectionRange();
    693    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    694                                             staticInEditor.textNode, staticInEditor.textLength);
    695    assert_equals(document.activeElement, outerEditor.element);
    696    assert_equals(document.documentElement.scrollTop, 0);
    697 }, "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>");
    698 test(function() {
    699    resetFocusAndSelectionRange();
    700    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    701                                             innerEditor.textNode, innerEditor.textLength);
    702    assert_equals(document.activeElement, document.body);
    703    assert_equals(document.documentElement.scrollTop, 0);
    704 }, "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>");
    705 test(function() {
    706    resetFocusAndSelectionRange();
    707    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    708                                             innerEditor.textNode, innerEditor.textLength);
    709    assert_equals(document.activeElement, outerEditor.element);
    710    assert_equals(document.documentElement.scrollTop, 0);
    711 }, "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>");
    712 test(function() {
    713    resetFocusAndSelectionRange();
    714    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    715                                             staticAfter.textNode, staticAfter.textLength);
    716    assert_equals(document.activeElement, document.body);
    717    assert_equals(document.documentElement.scrollTop, 0);
    718 }, "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>");
    719 test(function() {
    720    resetFocusAndSelectionRange();
    721    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    722                                             anchor.textNode, anchor.textLength);
    723    assert_equals(document.activeElement, document.body);
    724    assert_equals(document.documentElement.scrollTop, 0);
    725 }, "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>");
    726 
    727 test(function() {
    728    resetFocusAndSelectionRange(editor);
    729    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    730                                             editor.textNode, editor.textLength);
    731    assert_equals(document.activeElement, editor.element);
    732    assert_equals(document.documentElement.scrollTop, 0);
    733 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'editor'");
    734 test(function() {
    735    resetFocusAndSelectionRange(editor);
    736    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    737                                             outerEditor.textNode, outerEditor.textLength);
    738    assert_equals(document.activeElement, editor.element);
    739    assert_equals(document.documentElement.scrollTop, 0);
    740 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'editor'");
    741 test(function() {
    742    resetFocusAndSelectionRange(editor);
    743    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    744                                             staticInEditor.textNode, staticInEditor.textLength);
    745    assert_equals(document.activeElement, outerEditor.element);
    746    assert_equals(document.documentElement.scrollTop, 0);
    747 }, "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'");
    748 test(function() {
    749    resetFocusAndSelectionRange(editor);
    750    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    751                                             innerEditor.textNode, innerEditor.textLength);
    752    assert_equals(document.activeElement, editor.element);
    753    assert_equals(document.documentElement.scrollTop, 0);
    754 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'editor'");
    755 test(function() {
    756    resetFocusAndSelectionRange(editor);
    757    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    758                                             innerEditor.textNode, innerEditor.textLength);
    759    assert_equals(document.activeElement, outerEditor.element);
    760    assert_equals(document.documentElement.scrollTop, 0);
    761 }, "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'");
    762 test(function() {
    763    resetFocusAndSelectionRange(editor);
    764    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    765                                             staticAfter.textNode, staticAfter.textLength);
    766    assert_equals(document.activeElement, editor.element);
    767    assert_equals(document.documentElement.scrollTop, 0);
    768 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'editor'");
    769 test(function() {
    770    resetFocusAndSelectionRange(editor);
    771    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    772                                             anchor.textNode, anchor.textLength);
    773    assert_equals(document.activeElement, editor.element);
    774    assert_equals(document.documentElement.scrollTop, 0);
    775 }, "Active element should be 'editor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'editor'");
    776 
    777 test(function() {
    778    resetFocusAndSelectionRange(outerEditor);
    779    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    780                                             editor.textNode, editor.textLength);
    781    assert_equals(document.activeElement, outerEditor.element);
    782    assert_equals(document.documentElement.scrollTop, 0);
    783 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'outerEditor'");
    784 test(function() {
    785    resetFocusAndSelectionRange(outerEditor);
    786    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    787                                             outerEditor.textNode, outerEditor.textLength);
    788    assert_equals(document.activeElement, outerEditor.element);
    789    assert_equals(document.documentElement.scrollTop, 0);
    790 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'outerEditor'");
    791 test(function() {
    792    resetFocusAndSelectionRange(outerEditor);
    793    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    794                                             staticInEditor.textNode, staticInEditor.textLength);
    795    assert_equals(document.activeElement, outerEditor.element);
    796    assert_equals(document.documentElement.scrollTop, 0);
    797 }, "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'");
    798 test(function() {
    799    resetFocusAndSelectionRange(outerEditor);
    800    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    801                                             innerEditor.textNode, innerEditor.textLength);
    802    assert_equals(document.activeElement, outerEditor.element);
    803    assert_equals(document.documentElement.scrollTop, 0);
    804 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'outerEditor'");
    805 test(function() {
    806    resetFocusAndSelectionRange(outerEditor);
    807    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    808                                             innerEditor.textNode, innerEditor.textLength);
    809    assert_equals(document.activeElement, outerEditor.element);
    810    assert_equals(document.documentElement.scrollTop, 0);
    811 }, "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'");
    812 test(function() {
    813    resetFocusAndSelectionRange(outerEditor);
    814    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    815                                             staticAfter.textNode, staticAfter.textLength);
    816    assert_equals(document.activeElement, outerEditor.element);
    817    assert_equals(document.documentElement.scrollTop, 0);
    818 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'outerEditor'");
    819 test(function() {
    820    resetFocusAndSelectionRange(outerEditor);
    821    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    822                                             anchor.textNode, anchor.textLength);
    823    assert_equals(document.activeElement, outerEditor.element);
    824    assert_equals(document.documentElement.scrollTop, 0);
    825 }, "Active element should be 'outerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'outerEditor'");
    826 
    827 test(function() {
    828    resetFocusAndSelectionRange(innerEditor);
    829    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    830                                             editor.textNode, editor.textLength);
    831    assert_equals(document.activeElement, innerEditor.element);
    832    assert_equals(document.documentElement.scrollTop, 0);
    833 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticBefore' and end of the first text node of 'editor' (no common editing host) when active element is 'innerEditor'");
    834 test(function() {
    835    resetFocusAndSelectionRange(innerEditor);
    836    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    837                                             outerEditor.textNode, outerEditor.textLength);
    838    assert_equals(document.activeElement, innerEditor.element);
    839    assert_equals(document.documentElement.scrollTop, 0);
    840 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'editor' and end of the first text node of 'outerEditor' (no common editing host) when active element is 'innerEditor'");
    841 test(function() {
    842    resetFocusAndSelectionRange(innerEditor);
    843    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    844                                             staticInEditor.textNode, staticInEditor.textLength);
    845    assert_equals(document.activeElement, outerEditor.element);
    846    assert_equals(document.documentElement.scrollTop, 0);
    847 }, "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'");
    848 test(function() {
    849    resetFocusAndSelectionRange(innerEditor);
    850    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    851                                             innerEditor.textNode, innerEditor.textLength);
    852    assert_equals(document.activeElement, innerEditor.element);
    853    assert_equals(document.documentElement.scrollTop, 0);
    854 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'staticInEditor' and end of the first text node of 'innerEditor' (no common editing host) when active element is 'innerEditor'");
    855 test(function() {
    856    resetFocusAndSelectionRange(innerEditor);
    857    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    858                                             innerEditor.textNode, innerEditor.textLength);
    859    assert_equals(document.activeElement, outerEditor.element);
    860    assert_equals(document.documentElement.scrollTop, 0);
    861 }, "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'");
    862 test(function() {
    863    resetFocusAndSelectionRange(innerEditor);
    864    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    865                                             staticAfter.textNode, staticAfter.textLength);
    866    assert_equals(document.activeElement, innerEditor.element);
    867    assert_equals(document.documentElement.scrollTop, 0);
    868 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'staticAfter' (no common editing host) when active element is 'innerEditor'");
    869 test(function() {
    870    resetFocusAndSelectionRange(innerEditor);
    871    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    872                                             anchor.textNode, anchor.textLength);
    873    assert_equals(document.activeElement, innerEditor.element);
    874    assert_equals(document.documentElement.scrollTop, 0);
    875 }, "Active element should be 'innerEditor' after Selection.setBaseAndExtent() with a range between start of the first text node of 'innerEditor' and end of the first text node of 'anchor' (no common editing host) when active element is 'innerEditor'");
    876 
    877 test(function() {
    878    resetFocusAndSelectionRange(anchor);
    879    document.getSelection().setBaseAndExtent(staticBefore.textNode, 0,
    880                                             editor.textNode, editor.textLength);
    881    assert_equals(document.activeElement, anchor.element);
    882    assert_equals(document.documentElement.scrollTop, 0);
    883 }, "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'");
    884 test(function() {
    885    resetFocusAndSelectionRange(anchor);
    886    document.getSelection().setBaseAndExtent(editor.textNode, 0,
    887                                             outerEditor.textNode, outerEditor.textLength);
    888    assert_equals(document.activeElement, anchor.element);
    889    assert_equals(document.documentElement.scrollTop, 0);
    890 }, "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'");
    891 test(function() {
    892    resetFocusAndSelectionRange(anchor);
    893    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    894                                             staticInEditor.textNode, staticInEditor.textLength);
    895    assert_equals(document.activeElement, outerEditor.element);
    896    assert_equals(document.documentElement.scrollTop, 0);
    897 }, "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'");
    898 test(function() {
    899    resetFocusAndSelectionRange(anchor);
    900    document.getSelection().setBaseAndExtent(staticInEditor.textNode, 0,
    901                                             innerEditor.textNode, innerEditor.textLength);
    902    assert_equals(document.activeElement, anchor.element);
    903    assert_equals(document.documentElement.scrollTop, 0);
    904 }, "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'");
    905 test(function() {
    906    resetFocusAndSelectionRange(anchor);
    907    document.getSelection().setBaseAndExtent(outerEditor.textNode, 0,
    908                                             innerEditor.textNode, innerEditor.textLength);
    909    assert_equals(document.activeElement, outerEditor.element);
    910    assert_equals(document.documentElement.scrollTop, 0);
    911 }, "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'");
    912 test(function() {
    913    resetFocusAndSelectionRange(anchor);
    914    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    915                                             staticAfter.textNode, staticAfter.textLength);
    916    assert_equals(document.activeElement, anchor.element);
    917    assert_equals(document.documentElement.scrollTop, 0);
    918 }, "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'");
    919 test(function() {
    920    resetFocusAndSelectionRange(anchor);
    921    document.getSelection().setBaseAndExtent(innerEditor.textNode, 0,
    922                                             anchor.textNode, anchor.textLength);
    923    assert_equals(document.activeElement, anchor.element);
    924    assert_equals(document.documentElement.scrollTop, 0);
    925 }, "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'");
    926 </script>