@SmallTest
  @Feature({"TextSelection"})
  public void testSelectionPreservedAfterLossOfFocusIfRequested() throws Throwable {
    requestFocusOnUiThread(true);

    DOMUtils.longPressNode(this, mContentViewCore, "textarea");
    assertWaitForSelectActionBarVisible(true);
    assertTrue(mContentViewCore.hasSelection());

    mContentViewCore.preserveSelectionOnNextLossOfFocus();
    requestFocusOnUiThread(false);
    assertWaitForSelectActionBarVisible(false);
    assertTrue(mContentViewCore.hasSelection());

    requestFocusOnUiThread(true);
    assertWaitForSelectActionBarVisible(true);
    assertTrue(mContentViewCore.hasSelection());

    // Losing focus yet again should properly clear the selection.
    requestFocusOnUiThread(false);
    assertWaitForSelectActionBarVisible(false);
    assertFalse(mContentViewCore.hasSelection());
  }