testDeleteBrBeforeBlock() {
    setUpFields(true);

    // This test only works on Gecko, because it's testing for manual deletion
    // of BR tags, which is done only for Gecko. For other browsers we fall
    // through and let the browser do the delete, which can only be tested with
    // a robot test (see javascript/apps/editor/tests/delete_br_robot.html).
    if (userAgent.GECKO) {
      field1.setSafeHtml(
          false, testing.newSafeHtmlForTest('one<br><br><div>two</div>'));
      const helper = new TestHelper(field1.getElement());
      helper.select(field1.getElement(), 2);  // Between the two BR's.
      testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);
      assertEquals(
          'Should have deleted exactly one <br>', 'one<br><div>two</div>',
          field1.getElement().innerHTML);

      // We test the case where the BR has a previous sibling which is not
      // a block level element.
      field1.setSafeHtml(
          false, testing.newSafeHtmlForTest('one<br><ul><li>two</li></ul>'));
      helper.select(field1.getElement(), 1);  // Between one and BR.
      testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);
      assertEquals(
          'Should have deleted the <br>', 'one<ul><li>two</li></ul>',
          field1.getElement().innerHTML);
      // Verify that the cursor is placed at the end of the text node "one".
      let range = field1.getRange();
      let focusNode = range.getFocusNode();
      assertTrue('The selected range should be collapsed', range.isCollapsed());
      assertTrue(
          'The focus node should be the text node "one"',
          focusNode.nodeType == NodeType.TEXT && focusNode.data == 'one');
      assertEquals(
          'The focus offset should be at the end of the text node "one"',
          focusNode.length, range.getFocusOffset());
      assertTrue(
          'The next sibling of the focus node should be the UL',
          focusNode.nextSibling && focusNode.nextSibling.tagName == TagName.UL);

      // We test the case where the previous sibling of the BR is a block
      // level element.
      field1.setSafeHtml(
          false,
          testing.newSafeHtmlForTest(
              '<div>foo</div><br><div><span>bar</span></div>'));
      helper.select(field1.getElement(), 1);  // Before the BR.
      testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);
      assertEquals(
          'Should have deleted the <br>',
          '<div>foo</div><div><span>bar</span></div>',
          field1.getElement().innerHTML);
      range = field1.getRange();
      assertEquals(
          'The selected range should be contained within the <span>',
          String(TagName.SPAN), range.getContainerElement().tagName);
      assertTrue('The selected range should be collapsed', range.isCollapsed());
      // Verify that the cursor is placed inside the span at the beginning of
      // bar.
      focusNode = range.getFocusNode();
      assertTrue(
          'The focus node should be the text node "bar"',
          focusNode.nodeType == NodeType.TEXT && focusNode.data == 'bar');
      assertEquals(
          'The focus offset should be at the beginning ' +
              'of the text node "bar"',
          0, range.getFocusOffset());

      // We test the case where the BR does not have a previous sibling.
      field1.setSafeHtml(
          false, testing.newSafeHtmlForTest('<br><ul><li>one</li></ul>'));
      helper.select(field1.getElement(), 0);  // Before the BR.
      testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);
      assertEquals(
          'Should have deleted the <br>', '<ul><li>one</li></ul>',
          field1.getElement().innerHTML);
      range = field1.getRange();
      // Verify that the cursor is placed inside the LI at the text node "one".
      assertEquals(
          'The selected range should be contained within the <li>',
          String(TagName.LI), range.getContainerElement().tagName);
      assertTrue('The selected range should be collapsed', range.isCollapsed());
      focusNode = range.getFocusNode();
      assertTrue(
          'The focus node should be the text node "one"',
          (focusNode.nodeType == NodeType.TEXT && focusNode.data == 'one'));
      assertEquals(
          'The focus offset should be at the beginning of ' +
              'the text node "one"',
          0, range.getFocusOffset());

      // Testing deleting a BR followed by a block level element and preceded
      // by a BR.
      field1.setSafeHtml(
          false, testing.newSafeHtmlForTest('<br><br><ul><li>one</li></ul>'));
      helper.select(field1.getElement(), 1);  // Between the BR's.
      testingEvents.fireKeySequence(field1.getElement(), KeyCodes.DELETE);
      assertEquals(
          'Should have deleted the <br>', '<br><ul><li>one</li></ul>',
          field1.getElement().innerHTML);
      // Verify that the cursor is placed inside the LI at the text node "one".
      range = field1.getRange();
      assertEquals(
          'The selected range should be contained within the <li>',
          String(TagName.LI), range.getContainerElement().tagName);
      assertTrue('The selected range should be collapsed', range.isCollapsed());
      focusNode = range.getFocusNode();
      assertTrue(
          'The focus node should be the text node "one"',
          (focusNode.nodeType == NodeType.TEXT && focusNode.data == 'one'));
      assertEquals(
          'The focus offset should be at the beginning of ' +
              'the text node "one"',
          0, range.getFocusOffset());
    }  // End if GECKO
  }
Tests that deleting a BR that comes right before a block element works.
@bug 1471096
@bug 2056376