testSafari3StyleKeyHandling() {
    userAgent.IE = false;
    userAgent.GECKO = false;
    userAgent.WEBKIT = true;
    userAgent.MAC = true;
    userAgent.WINDOWS = false;
    userAgent.LINUX = false;
    /** @suppress {checkTypes} suppression added to enable type checking */
    userAgent.VERSION = 525.3;

    let keyEvent;
    const keyHandler = new KeyHandler();

    // Make sure all events are caught while testing
    events.listen(keyHandler, KeyHandler.EventType.KEY, (e) => {
      keyEvent = e;
    });

    fireKeyDown(keyHandler, KeyCodes.ENTER);
    fireKeyPress(keyHandler, KeyCodes.ENTER);
    assertEquals(
        'Enter should fire a key event with the keycode 13', KeyCodes.ENTER,
        keyEvent.keyCode);
    assertEquals(
        'Enter should fire a key event with the charcode 0', 0,
        keyEvent.charCode);
    fireKeyUp(keyHandler, KeyCodes.ENTER);

    // Add a listener to ensure that an extra ENTER event is not dispatched
    // by a subsequent keypress.
    const enterCheck =
        events.listen(keyHandler, KeyHandler.EventType.KEY, (e) => {
          assertNotEquals(
              'Unexpected ENTER keypress dispatched', e.keyCode,
              KeyCodes.ENTER);
        });

    fireKeyDown(keyHandler, KeyCodes.ESC);
    assertEquals(
        'Esc should fire a key event with the keycode 27', KeyCodes.ESC,
        keyEvent.keyCode);
    assertEquals(
        'Esc should fire a key event with the charcode 0', 0,
        keyEvent.charCode);
    fireKeyPress(keyHandler, KeyCodes.ESC);
    events.unlistenByKey(enterCheck);

    fireKeyDown(keyHandler, KeyCodes.UP);
    assertEquals(
        'Up should fire a key event with the keycode 38', KeyCodes.UP,
        keyEvent.keyCode);
    assertEquals(
        'Up should fire a key event with the charcode 0', 0, keyEvent.charCode);

    fireKeyDown(
        keyHandler, KeyCodes.SEVEN, undefined, undefined, undefined, undefined,
        true);
    fireKeyPress(keyHandler, 38, 38, undefined, undefined, undefined, true);
    assertEquals(
        'Shift+7 should fire a key event with the keycode 55', KeyCodes.SEVEN,
        keyEvent.keyCode);
    assertEquals(
        'Shift+7 should fire a key event with the charcode 38', 38,
        keyEvent.charCode);

    fireKeyDown(keyHandler, KeyCodes.A);
    fireKeyPress(keyHandler, 97, 97);
    assertEquals(
        'Lower case a should fire a key event with the keycode 65', KeyCodes.A,
        keyEvent.keyCode);
    assertEquals(
        'Lower case a should fire a key event with the charcode 97', 97,
        keyEvent.charCode);

    fireKeyDown(keyHandler, KeyCodes.A);
    fireKeyPress(keyHandler, 65, 65);
    assertEquals(
        'Upper case A should fire a key event with the keycode 65', KeyCodes.A,
        keyEvent.keyCode);
    assertEquals(
        'Upper case A should fire a key event with the charcode 65', 65,
        keyEvent.charCode);

    fireKeyDown(keyHandler, KeyCodes.CTRL);
    fireKeyDown(keyHandler, KeyCodes.A, null, null, true /*ctrl*/);
    assertEquals(
        'A with control down should fire a key event', KeyCodes.A,
        keyEvent.keyCode);

    // Test that Alt-Tab outside the window doesn't break things.
    fireKeyDown(keyHandler, KeyCodes.ALT);
    keyEvent.keyCode = -1;  // Reset the event.
    fireKeyDown(keyHandler, KeyCodes.A);
    assertEquals('Should not have dispatched an Alt-A', -1, keyEvent.keyCode);
    fireKeyPress(keyHandler, 65, 65);
    assertEquals(
        'Alt should be ignored since it isn\'t currently depressed', KeyCodes.A,
        keyEvent.keyCode);

    fireKeyDown(keyHandler, KeyCodes.DELETE);
    assertEquals(
        'Delete should fire a key event with the keycode 46', KeyCodes.DELETE,
        keyEvent.keyCode);
    assertEquals(
        'Delete should fire a key event with the charcode 0', 0,
        keyEvent.charCode);

    fireKeyDown(keyHandler, KeyCodes.PERIOD);
    fireKeyPress(keyHandler, 46, 46);
    assertEquals(
        'Period should fire a key event with the keycode 190', KeyCodes.PERIOD,
        keyEvent.keyCode);
    assertEquals(
        'Period should fire a key event with the charcode 46', 46,
        keyEvent.charCode);

    // Safari sends zero key code for non-latin characters.
    fireKeyDown(keyHandler, 0, 0);
    fireKeyPress(keyHandler, 1092, 1092);
    assertEquals(
        'Cyrillic small letter "Ef" should fire a key event with ' +
            'the keycode 0',
        0, keyEvent.keyCode);
    assertEquals(
        'Cyrillic small letter "Ef" should fire a key event with ' +
            'the charcode 1092',
        1092, keyEvent.charCode);
  }
Tests the key handler for the Safari 3 behavior.