testSetAndGetCursorWithLineBreaks() {
    select(textarea);
    const newline = '\n';
    let message = `Hello${newline}World`;
    selection.setText(textarea, message);

    // Test setEnd and getEnd, by setting the cursor somewhere after the
    // \r\n combination.
    selection.setEnd(textarea, 9);
    assertEquals(9, selection.getEnd(textarea));

    // Test basic setStart and getStart
    selection.setStart(textarea, 10);
    assertEquals(10, selection.getStart(textarea));

    // Test setEnd and getEnd, by setting the cursor exactly after the
    // \r\n combination in IE or after \n in GECKO.
    let endOfNewline = 6;
    checkSetAndGetTextarea(endOfNewline, endOfNewline);

    // Select a \r\n combination in IE or \n in GECKO and see if
    // getStart and getEnd work correctly.
    clearField(textarea);
    message = `Hello${newline}${newline}World`;
    selection.setText(textarea, message);
    const startOfNewline = 6;
    endOfNewline = 7;
    checkSetAndGetTextarea(startOfNewline, endOfNewline);

    // Select 2 \r\n combinations in IE or 2 \ns in GECKO and see if getStart
    // and getEnd work correctly.
    checkSetAndGetTextarea(5, endOfNewline);

    // Position cursor b/w 2 \r\n combinations in IE or 2 \ns in GECKO and see
    // if getStart and getEnd work correctly.
    clearField(textarea);
    message = `Hello${newline}${newline}${newline}${newline}World`;
    selection.setText(textarea, message);
    const middleOfNewlines = 7;
    checkSetAndGetTextarea(middleOfNewlines, middleOfNewlines);

    // Position cursor at end of a textarea which ends with \r\n in IE or \n in
    // GECKO.
    if (!userAgent.IE) {
      // TODO(johnlenz): investigate why this fails in IE 11.
      clearField(textarea);
      message = `Hello${newline}${newline}`;
      selection.setText(textarea, message);
      const endOfTextarea = message.length;
      checkSetAndGetTextarea(endOfTextarea, endOfTextarea);
    }

    // Position cursor at the end of the 2 starting \r\ns in IE or \ns in GECKO
    // within a textarea.
    clearField(textarea);
    message = `${newline}${newline}World`;
    selection.setText(textarea, message);
    const endOfTwoNewlines = 2;
    checkSetAndGetTextarea(endOfTwoNewlines, endOfTwoNewlines);

    // Position cursor at the end of the first \r\n in IE or \n in
    // GECKO within a textarea.
    let endOfOneNewline = 1;
    checkSetAndGetTextarea(endOfOneNewline, endOfOneNewline);
  }
Test setStart, setEnd, getStart and getEnd in textarea with text
containing line breaks.