mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1346605 - Add pointer events to popup blocking handling. r=smaug
This commit is contained in:
parent
69318bffba
commit
a207c2fcb5
@ -857,6 +857,25 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ePointerEventClass:
|
||||
if (aEvent->IsTrusted() &&
|
||||
aEvent->AsPointerEvent()->button == WidgetMouseEvent::eLeftButton) {
|
||||
switch(aEvent->mMessage) {
|
||||
case ePointerUp:
|
||||
if (PopupAllowedForEvent("pointerup")) {
|
||||
abuse = openControlled;
|
||||
}
|
||||
break;
|
||||
case ePointerDown:
|
||||
if (PopupAllowedForEvent("pointerdown")) {
|
||||
abuse = openControlled;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eFormEventClass:
|
||||
// For these following events only allow popups if they're
|
||||
// triggered while handling user input. See
|
||||
|
@ -125,6 +125,7 @@ support-files =
|
||||
support-files = bug1293174_implicit_pointer_capture_for_touch_2.html
|
||||
[test_bug1303704.html]
|
||||
[test_bug1323158.html]
|
||||
[test_trigger_popup_by_pointer_events.html]
|
||||
[test_empty_file.html]
|
||||
disabled = disabled # Bug 1150091 - Issue with support-files
|
||||
[test_bug1315862.html]
|
||||
|
@ -0,0 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for triggering popup by pointer events</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="target" style="width: 50px; height: 50px; background: green"></div>
|
||||
<script>
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function sendMouseEvent(element, eventName, listenEventName, handler) {
|
||||
element.addEventListener(listenEventName, handler, {once: true});
|
||||
synthesizeMouseAtCenter(element, {type: eventName});
|
||||
}
|
||||
|
||||
function checkAllowOpenPopup(e) {
|
||||
let w = window.open("about:blank");
|
||||
ok(w, "Should allow popup in the " + e.type + " listener");
|
||||
if (w) {
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
|
||||
function checkBlockOpenPopup(e) {
|
||||
let w = window.open("about:blank");
|
||||
ok(!w, "Should block popup in the " + e.type + " listener");
|
||||
if (w) {
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
let target = document.getElementById("target");
|
||||
// By default, only allow opening popup in the pointerup listener.
|
||||
sendMouseEvent(target, "mousemove", "pointermove", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mousedown", "pointerdown", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mousemove", "pointermove", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mouseup", "pointerup", checkAllowOpenPopup);
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.popup_allowed_events",
|
||||
"pointerdown pointerup"]]}, () => {
|
||||
// Adding pointerdown to preference should work
|
||||
sendMouseEvent(target, "mousemove", "pointermove", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mousedown", "pointerdown", checkAllowOpenPopup);
|
||||
sendMouseEvent(target, "mousemove", "pointermove", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mouseup", "pointerup", checkAllowOpenPopup);
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.popup_allowed_events",
|
||||
"pointerdown pointerup pointermove"]]}, () => {
|
||||
// Adding pointermove to preference should be no effect.
|
||||
sendMouseEvent(target, "mousemove", "pointermove", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mousedown", "pointerdown", checkAllowOpenPopup);
|
||||
sendMouseEvent(target, "mousemove", "pointermove", checkBlockOpenPopup);
|
||||
sendMouseEvent(target, "mouseup", "pointerup", checkAllowOpenPopup);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const DENY_ACTION = SpecialPowers.Ci.nsIPermissionManager.DENY_ACTION;
|
||||
|
||||
SimpleTest.waitForFocus(() => {
|
||||
SpecialPowers.pushPermissions([{'type': 'popup', 'allow': DENY_ACTION,
|
||||
'context': document}], () => {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [["dom.w3c_pointer_events.enabled", true]]
|
||||
}, startTest);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1168,7 +1168,7 @@ pref("dom.require_user_interaction_for_beforeunload", true);
|
||||
|
||||
pref("dom.disable_open_during_load", false);
|
||||
pref("dom.popup_maximum", 20);
|
||||
pref("dom.popup_allowed_events", "change click dblclick mouseup notificationclick reset submit touchend");
|
||||
pref("dom.popup_allowed_events", "change click dblclick mouseup pointerup notificationclick reset submit touchend");
|
||||
pref("dom.disable_open_click_delay", 1000);
|
||||
|
||||
pref("dom.storage.enabled", true);
|
||||
|
Loading…
Reference in New Issue
Block a user