Commit d543c99a authored by Neil Deakin's avatar Neil Deakin Committed by Georg Koppen
Browse files

Bug 1266963, stop propagation before other steps, r=masayuki

This is a backport of
https://hg.mozilla.org/mozilla-central/rev/1d23af51e886.

Note we don't call `AsEvent()` as the original patch is doing as that
change got introduced by bug 1230216 which landed in mozilla46.
parent 17ea0638
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -2514,6 +2514,12 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
  if (!mActiveMenuBar && (!item || item->PopupType() != ePopupTypeMenu))
    return NS_OK;

  // Since a menu was open, stop propagation of the event to keep other event
  // listeners from becoming confused.
  if (!item || item->IgnoreKeys() != eIgnoreKeys_Handled) {
    aKeyEvent->StopPropagation();
  }

  int32_t menuAccessKey = -1;

  // If the key just pressed is the access key (usually Alt),
@@ -2544,19 +2550,15 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
          Rollup(0, false, nullptr, nullptr);
        else if (mActiveMenuBar)
          mActiveMenuBar->MenuClosed();

        // Clear the item to avoid bugs as it may have been deleted during rollup.
        item = nullptr;
      }
      aKeyEvent->StopPropagation();
      aKeyEvent->PreventDefault();
    }
  }

  // Since a menu was open, stop propagation of the event to keep other event
  // listeners from becoming confused.

  if (!item || item->IgnoreKeys() != eIgnoreKeys_Handled) {
    aKeyEvent->StopPropagation();
  }

  aKeyEvent->StopCrossProcessForwarding();
  return NS_OK;
}
+24 −0
Original line number Diff line number Diff line
@@ -706,6 +706,30 @@ var popupTests = [
  }
},

{
  testname: "Open menu and press alt key by itself - open menu",
  events: [ "DOMMenuBarActive menubar",
            "popupshowing filepopup", "DOMMenuItemActive filemenu",
            "DOMMenuItemActive item1", "popupshown filepopup" ],
  test: function() { synthesizeKey("F", { altKey: true }); },
  result: function (testname) {
    checkOpen("filemenu", testname);
  }
},
{
  testname: "Open menu and press alt key by itself - close menu",
  events: [ "popuphiding filepopup", "popuphidden filepopup",
            "DOMMenuItemInactive item1", "DOMMenuInactive filepopup",
            "DOMMenuBarInactive menubar", "DOMMenuItemInactive filemenu",
            "DOMMenuItemInactive filemenu" ],
  test: function() {
    synthesizeKey("VK_ALT", { });
  },
  result: function (testname) {
    checkClosed("filemenu", testname);
  }
},

// Fllowing 4 tests are a test of bug 616797, don't insert any new tests
// between them.
{