testRestoreSelection() {
    setUpRealEditableField();

    fieldObj.setSafeHtml(false, SafeHtml.htmlEscape('12345'));
    const elem = fieldObj.getElement();
    const helper = new TestHelper(elem);
    helper.select('12345', 1, '12345', 4);  // Selects '234'.

    assertEquals(
        'Incorrect text selected before dialog is opened', '234',
        fieldObj.getRange().getText());
    plugin.execCommand(COMMAND);
    if (!userAgent.IE) {
      // IE returns some bogus range when field doesn't have selection.
      // Opera can't remove the selection from a whitebox field.
      assertNull(
          'There should be no selection while dialog is open',
          fieldObj.getRange());
    }
    plugin.getDialog().hide();
    assertEquals(
        'Incorrect text selected after dialog is closed', '234',
        fieldObj.getRange().getText());
  }
Tests that the selection is cleared when the dialog opens and is
correctly restored after it closes.
@suppress {visibility} suppression added to enable type checking