mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1304308: Investigate failure of test_pointerevent_setpointercapture_inactive_button_mouse-manual.html. r=masayuki
This test case should be triggered by pointerover and pointerout. Add new test API to fire mouse event at the specified position and refine the synthesized events fired to the test case to trigger it correctly. MozReview-Commit-ID: DkLYrD6MwYc --HG-- extra : rebase_source : f0ae002edcb6f39d301e83fea9bf1e74dc21c62a
This commit is contained in:
parent
cbf08f5f05
commit
c1cc98fed4
@ -82,7 +82,6 @@ support-files =
|
||||
support-files = pointerevent_setpointercapture_disconnected-manual.html
|
||||
[test_pointerevent_setpointercapture_inactive_button_mouse-manual.html]
|
||||
support-files = pointerevent_setpointercapture_inactive_button_mouse-manual.html
|
||||
disabled = should be investigated
|
||||
[test_pointerevent_setpointercapture_invalid_pointerid-manual.html]
|
||||
support-files = pointerevent_setpointercapture_invalid_pointerid-manual.html
|
||||
[test_pointerevent_setpointercapture_override_pending_capture_element-manual.html]
|
||||
|
@ -81,56 +81,60 @@ var MouseEventHelper = (function() {
|
||||
};
|
||||
}) ();
|
||||
|
||||
function createMouseEvent(aEventType, aParams) {
|
||||
var eventObj = {type: aEventType};
|
||||
|
||||
// Default to mouse.
|
||||
eventObj.inputSource =
|
||||
(aParams && "inputSource" in aParams) ? aParams.inputSource :
|
||||
MouseEvent.MOZ_SOURCE_MOUSE;
|
||||
// Compute pointerId
|
||||
eventObj.id =
|
||||
(eventObj.inputSource === MouseEvent.MOZ_SOURCE_MOUSE) ? MouseEventHelper.MOUSE_ID :
|
||||
MouseEventHelper.PEN_ID;
|
||||
// Check or generate a |button| value.
|
||||
var isButtonEvent = aEventType === "mouseup" || aEventType === "mousedown";
|
||||
|
||||
// Set |button| to the default value first.
|
||||
eventObj.button = isButtonEvent ? MouseEventHelper.BUTTON_LEFT
|
||||
: MouseEventHelper.BUTTON_NONE;
|
||||
|
||||
// |button| is passed, use and check it.
|
||||
if (aParams && "button" in aParams) {
|
||||
var hasButtonValue = (aParams.button !== MouseEventHelper.BUTTON_NONE);
|
||||
ok(!isButtonEvent || hasButtonValue,
|
||||
"Inappropriate |button| value caught.");
|
||||
eventObj.button = aParams.button;
|
||||
}
|
||||
|
||||
// Generate a |buttons| value and update buttons state
|
||||
var buttonsMask = MouseEventHelper.computeButtonsMaskFromButton(eventObj.button);
|
||||
switch(aEventType) {
|
||||
case "mousedown":
|
||||
MouseEventHelper.BUTTONS_STATE |= buttonsMask; // Set button flag.
|
||||
break;
|
||||
case "mouseup":
|
||||
MouseEventHelper.BUTTONS_STATE &= ~buttonsMask; // Clear button flag.
|
||||
break;
|
||||
}
|
||||
eventObj.buttons = MouseEventHelper.BUTTONS_STATE;
|
||||
|
||||
// Replace the button value for mousemove events.
|
||||
// Since in widget level design, even when no button is pressed at all, the
|
||||
// value of WidgetMouseEvent.button is still 0, which is the same value as
|
||||
// the one for mouse left button.
|
||||
if (aEventType === "mousemove") {
|
||||
eventObj.button = MouseEventHelper.BUTTON_LEFT;
|
||||
}
|
||||
return eventObj;
|
||||
}
|
||||
|
||||
// Helper function to send MouseEvent with different parameters
|
||||
function sendMouseEvent(int_win, elemId, mouseEventType, params) {
|
||||
var elem = int_win.document.getElementById(elemId);
|
||||
if(!!elem) {
|
||||
if (elem) {
|
||||
var rect = elem.getBoundingClientRect();
|
||||
var eventObj = {type: mouseEventType};
|
||||
|
||||
// Default to mouse.
|
||||
eventObj.inputSource =
|
||||
(params && "inputSource" in params) ? params.inputSource :
|
||||
MouseEvent.MOZ_SOURCE_MOUSE;
|
||||
// Compute pointerId
|
||||
eventObj.id =
|
||||
(eventObj.inputSource === MouseEvent.MOZ_SOURCE_MOUSE) ? MouseEventHelper.MOUSE_ID :
|
||||
MouseEventHelper.PEN_ID;
|
||||
// Check or generate a |button| value.
|
||||
var isButtonEvent = mouseEventType === "mouseup" ||
|
||||
mouseEventType === "mousedown";
|
||||
|
||||
// Set |button| to the default value first.
|
||||
eventObj.button = isButtonEvent ? MouseEventHelper.BUTTON_LEFT
|
||||
: MouseEventHelper.BUTTON_NONE;
|
||||
|
||||
// |button| is passed, use and check it.
|
||||
if (params && "button" in params) {
|
||||
var hasButtonValue = (params.button !== MouseEventHelper.BUTTON_NONE);
|
||||
ok(!isButtonEvent || hasButtonValue,
|
||||
"Inappropriate |button| value caught.");
|
||||
eventObj.button = params.button;
|
||||
}
|
||||
|
||||
// Generate a |buttons| value and update buttons state
|
||||
var buttonsMask = MouseEventHelper.computeButtonsMaskFromButton(eventObj.button);
|
||||
switch(mouseEventType) {
|
||||
case "mousedown":
|
||||
MouseEventHelper.BUTTONS_STATE |= buttonsMask; // Set button flag.
|
||||
break;
|
||||
case "mouseup":
|
||||
MouseEventHelper.BUTTONS_STATE &= ~buttonsMask; // Clear button flag.
|
||||
break;
|
||||
}
|
||||
eventObj.buttons = MouseEventHelper.BUTTONS_STATE;
|
||||
|
||||
// Replace the button value for mousemove events.
|
||||
// Since in widget level design, even when no button is pressed at all, the
|
||||
// value of WidgetMouseEvent.button is still 0, which is the same value as
|
||||
// the one for mouse left button.
|
||||
if (mouseEventType === "mousemove") {
|
||||
eventObj.button = MouseEventHelper.BUTTON_LEFT;
|
||||
}
|
||||
var eventObj = createMouseEvent(mouseEventType, params);
|
||||
|
||||
// Default to the center of the target element but we can still send to a
|
||||
// position outside of the target element.
|
||||
@ -145,6 +149,13 @@ function sendMouseEvent(int_win, elemId, mouseEventType, params) {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to send MouseEvent with position
|
||||
function sendMouseEventAtPoint(aWindow, aLeft, aTop, aMouseEventType, aParams) {
|
||||
var eventObj = createMouseEvent(aMouseEventType, aParams);
|
||||
console.log(eventObj);
|
||||
synthesizeMouseAtPoint(aLeft, aTop, eventObj, aWindow);
|
||||
}
|
||||
|
||||
// Touch Event Helper Object
|
||||
var TouchEventHelper = {
|
||||
// State
|
||||
|
@ -17,9 +17,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
||||
runTestInNewWindow("pointerevent_setpointercapture_inactive_button_mouse-manual.html");
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendMouseEvent(int_win, "target1", "mousemove");
|
||||
sendMouseEvent(int_win, "target0", "mousemove");
|
||||
sendMouseEvent(int_win, "target1", "mousemove");
|
||||
let target0 = int_win.document.getElementById("target0");
|
||||
let rect = target0.getBoundingClientRect();
|
||||
sendMouseEventAtPoint(int_win, rect.left + 1, rect.top + 1, "mousemove");
|
||||
sendMouseEventAtPoint(int_win, rect.left - 1, rect.top - 1, "mousemove");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
Loading…
x
Reference in New Issue
Block a user