зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615732 - Don't dispatch xul command event on Mac if it is from mouse event with ctrl key is pressed; r=Gijs,NeilDeakin
Differential Revision: https://phabricator.services.mozilla.com/D68735 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0de61803a3
Коммит
f8e3c1a6a9
|
@ -137,6 +137,7 @@ skip-if = verify
|
|||
[browser_1484275_PanelMultiView_toggle_with_other_popup.js]
|
||||
[browser_allow_dragging_removable_false.js]
|
||||
[browser_bootstrapped_custom_toolbar.js]
|
||||
[browser_character_encoding_ctrl_click.js]
|
||||
[browser_ctrl_click_panel_opening.js]
|
||||
[browser_currentset_post_reset.js]
|
||||
[browser_customizemode_contextmenu_menubuttonstate.js]
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_character_encoding_menu() {
|
||||
// On macOS, ctrl-click shouldn't open the panel because this normally opens
|
||||
// the context menu. This happens via the `contextmenu` event which is created
|
||||
// by widget code, so our simulated clicks do not do so, so we can't test
|
||||
// anything on macOS.
|
||||
if (AppConstants.platform == "macosx") {
|
||||
ok(true, "The test is ignored on Mac");
|
||||
return;
|
||||
}
|
||||
|
||||
CustomizableUI.addWidgetToArea(
|
||||
"characterencoding-button",
|
||||
CustomizableUI.AREA_NAVBAR,
|
||||
4
|
||||
);
|
||||
|
||||
const button = document.getElementById("characterencoding-button");
|
||||
const view = document.getElementById("PanelUI-characterEncodingView");
|
||||
|
||||
let shownPromise = subviewShown(view);
|
||||
EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true });
|
||||
await shownPromise;
|
||||
ok(true, "Character encoding menu shown after button pressed");
|
||||
|
||||
// Close character encoding popup.
|
||||
let hiddenPromise = subviewHidden(view);
|
||||
view.closest("panel").hidePopup();
|
||||
await hiddenPromise;
|
||||
|
||||
CustomizableUI.reset();
|
||||
});
|
|
@ -59,6 +59,16 @@ add_task(async function test_clickData() {
|
|||
|
||||
for (let modifier of Object.keys(map)) {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
// On Mac, ctrl-click will send a context menu event from the widget,
|
||||
// we won't send xul command event and won't have onClick message, either.
|
||||
if (
|
||||
AppConstants.platform == "macosx" &&
|
||||
i == 0 &&
|
||||
modifier == "ctrlKey"
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let clickEventData = { button: i };
|
||||
clickEventData[modifier] = true;
|
||||
await clickBrowserAction(extension, window, clickEventData);
|
||||
|
|
|
@ -157,7 +157,15 @@ nsresult nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
|
||||
case eMouseClick: {
|
||||
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
|
||||
if (mouseEvent->IsLeftClickEvent()) {
|
||||
|
||||
if (mouseEvent->IsLeftClickEvent()
|
||||
#ifdef XP_MACOSX
|
||||
// On Mac, ctrl-click will send a context menu event from the widget,
|
||||
// so we don't want to dispatch widget command if it is redispatched
|
||||
// from the mouse event with ctrl key is pressed.
|
||||
&& !mouseEvent->IsControl()
|
||||
#endif
|
||||
) {
|
||||
MouseClicked(mouseEvent);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -285,7 +285,14 @@ nsresult nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
|
||||
case eMouseClick: {
|
||||
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
|
||||
if (mouseEvent->IsLeftClickEvent()) {
|
||||
if (mouseEvent->IsLeftClickEvent()
|
||||
#ifdef XP_MACOSX
|
||||
// On Mac, ctrl-click will send a context menu event from the widget,
|
||||
// so we don't want to dispatch widget command if it is redispatched
|
||||
// from the mouse event with ctrl key is pressed.
|
||||
&& !mouseEvent->IsControl()
|
||||
#endif
|
||||
) {
|
||||
MouseClicked(mouseEvent);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -134,7 +134,14 @@ nsresult nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
|
|||
|
||||
case eMouseClick: {
|
||||
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
|
||||
if (mouseEvent->IsLeftClickEvent()) {
|
||||
if (mouseEvent->IsLeftClickEvent()
|
||||
#ifdef XP_MACOSX
|
||||
// On Mac, ctrl-click will send a context menu event from the widget,
|
||||
// so we don't want to dispatch widget command if it is redispatched
|
||||
// from the mouse event with ctrl key is pressed.
|
||||
&& !mouseEvent->IsControl()
|
||||
#endif
|
||||
) {
|
||||
MouseClicked(mouseEvent);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -35,6 +35,9 @@ skip-if = os == 'linux' # No native mousedown event on Linux
|
|||
skip-if = (verify && (os == 'win'))
|
||||
[test_submenuClose.xhtml]
|
||||
[test_windowminmaxsize.xhtml]
|
||||
[test_resizer_ctrl_click.xhtml]
|
||||
[test_resizer_incontent.xhtml]
|
||||
[test_splitter.xhtml]
|
||||
skip-if = toolkit == 'android' # no XUL theme
|
||||
[test_titlebar_ctrl_click.xhtml]
|
||||
[test_toolbarbutton_ctrl_click.xhtml]
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
XUL Widget Test for the resizer element
|
||||
-->
|
||||
<window title="Titlebar" width="200" height="200"
|
||||
onload="setTimeout(test_resizer_ctrl_click, 0);"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<resizer id="resizer" dir="bottomend" width="16" height="16"/>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function test_resizer_ctrl_click()
|
||||
{
|
||||
let resizer = document.getElementById("resizer");
|
||||
let isCommandFired = false;
|
||||
|
||||
resizer.addEventListener("click", function(aEvent) {
|
||||
// Delay check for command event, because it is fired after click event.
|
||||
setTimeout(() => {
|
||||
is(isCommandFired, AppConstants.platform != "macosx",
|
||||
"Check if command event is fired");
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
});
|
||||
resizer.addEventListener("command", function(aEvent) {
|
||||
isCommandFired = true;
|
||||
ok(aEvent.ctrlKey, "Check ctrlKey for command event");
|
||||
ok(!aEvent.shiftKey, "Check shiftKey for command event");
|
||||
ok(!aEvent.altKey, "Check altKey for command event");
|
||||
ok(!aEvent.metaKey, "Check metaKey for command event");
|
||||
is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
|
||||
"Check inputSource for command event");
|
||||
});
|
||||
synthesizeMouseAtCenter(resizer, { ctrlKey: true });
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
XUL Widget Test for the titlebar element
|
||||
-->
|
||||
<window title="Titlebar" width="200" height="200"
|
||||
onload="setTimeout(test_titlebar_ctrl_click, 0);"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<titlebar id="titlebar">
|
||||
<label id="label" value="Titlebar"/>
|
||||
</titlebar>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function test_titlebar_ctrl_click()
|
||||
{
|
||||
let titlebar = document.getElementById("titlebar");
|
||||
let isCommandFired = false;
|
||||
|
||||
titlebar.addEventListener("click", function(aEvent) {
|
||||
// Delay check for command event, because it is fired after click event.
|
||||
setTimeout(() => {
|
||||
is(isCommandFired, AppConstants.platform != "macosx",
|
||||
"Check if command event is fired");
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
});
|
||||
titlebar.addEventListener("command", function(aEvent) {
|
||||
isCommandFired = true;
|
||||
ok(aEvent.ctrlKey, "Check ctrlKey for command event");
|
||||
ok(!aEvent.shiftKey, "Check shiftKey for command event");
|
||||
ok(!aEvent.altKey, "Check altKey for command event");
|
||||
ok(!aEvent.metaKey, "Check metaKey for command event");
|
||||
is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
|
||||
"Check inputSource for command event");
|
||||
});
|
||||
synthesizeMouseAtCenter(titlebar, { ctrlKey: true });
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
XUL Widget Test for the toolbarbutton element
|
||||
-->
|
||||
<window title="Titlebar" width="200" height="200"
|
||||
onload="setTimeout(test_resizer_ctrl_click, 0);"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<toolbarbutton id="toolbarbutton" width="16" height="16"/>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function test_resizer_ctrl_click()
|
||||
{
|
||||
let toolbarbutton = document.getElementById("toolbarbutton");
|
||||
let isCommandFired = false;
|
||||
|
||||
toolbarbutton.addEventListener("click", function(aEvent) {
|
||||
// Delay check for command event, because it is fired after click event.
|
||||
setTimeout(() => {
|
||||
is(isCommandFired, AppConstants.platform != "macosx",
|
||||
"Check if command event is fired");
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
});
|
||||
toolbarbutton.addEventListener("command", function(aEvent) {
|
||||
isCommandFired = true;
|
||||
ok(aEvent.ctrlKey, "Check ctrlKey for command event");
|
||||
ok(!aEvent.shiftKey, "Check shiftKey for command event");
|
||||
ok(!aEvent.altKey, "Check altKey for command event");
|
||||
ok(!aEvent.metaKey, "Check metaKey for command event");
|
||||
is(aEvent.inputSource, MouseEvent.MOZ_SOURCE_MOUSE,
|
||||
"Check inputSource for command event");
|
||||
});
|
||||
synthesizeMouseAtCenter(toolbarbutton, { ctrlKey: true });
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче