Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Bug 1485205 [wpt PR 12607] - Direct dispatch mouse pointer event by M…
Browse files Browse the repository at this point in the history
…EM and PEM, a=testonly

Automatic update from web-platform-testsDirect dispatch mouse pointer event by MEM and PEM

We used to direct dispatch mouse pointer events by a different
code path in node.cc. Unlike normal events, these events are
created separately and didn't went through EventHandler. This
causes extra complexity.

This CL changes the direct dispatch code path to dispatch events
through PointerEventManager and MouseEventManager, so we can have
only one place to create events and further merge the event
code path in the future.
This patch should cause no change for direct dispatched events
other then the click count. The new direct dispatch code path
will also update click_count stored in MEM by the
WebMouseEvent.click_count.

This CL also fixes two issue caused by different code path,
1. direct dispatched pointermove events, (eg. when pointerlocked),
didn't havbe getCoalescedEvents.
2. pointer move on chorded mouse button when pointer is locked.

Bug: 859132, 665924
Change-Id: Iead9c8135ef58c2bf8e45bd7787cf14334c2e139
Reviewed-on: https://chromium-review.googlesource.com/1134219
Commit-Queue: Ella Ge <eirage@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591834}

--

wpt-commits: d4c197a71c0777e839b65c17a59da12b6ddd8d0d
wpt-pr: 12607
  • Loading branch information
EiraGe authored and moz-wptsync-bot committed Sep 20, 2018
1 parent 84b96ff commit ebb6385
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 4 deletions.
41 changes: 40 additions & 1 deletion testing/web-platform/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -13579,6 +13579,12 @@
{}
]
],
"pointerevents/extension/pointerevent_getCoalescedEvents_when_pointerlocked-manual.html": [
[
"/pointerevents/extension/pointerevent_getCoalescedEvents_when_pointerlocked-manual.html",
{}
]
],
"pointerevents/extension/pointerevent_pointerrawmove-manual.html": [
[
"/pointerevents/extension/pointerevent_pointerrawmove-manual.html",
Expand Down Expand Up @@ -14023,6 +14029,18 @@
{}
]
],
"pointerevents/pointerlock/pointerevent_pointermove_in_pointerlock-manual.html": [
[
"/pointerevents/pointerlock/pointerevent_pointermove_in_pointerlock-manual.html",
{}
]
],
"pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked-manual.html": [
[
"/pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked-manual.html",
{}
]
],
"pointerlock/mouse_buttons_back_forward-manual.html": [
[
"/pointerlock/mouse_buttons_back_forward-manual.html",
Expand Down Expand Up @@ -295760,6 +295778,11 @@
{}
]
],
"pointerevents/pointerlock/resources/pointerevent_pointermove_in_pointerlock-iframe.html": [
[
{}
]
],
"pointerevents/resources/pointerevent_attributes_hoverable_pointers-iframe.html": [
[
{}
Expand Down Expand Up @@ -631259,12 +631282,16 @@
"43d0aa5d38b2ac65b5100c9ba8fa2b794ffd03ee",
"testharness"
],
"pointerevents/extension/pointerevent_getCoalescedEvents_when_pointerlocked-manual.html": [
"6efded85b4562bd960a4b5e584e68984a1ce6316",
"manual"
],
"pointerevents/extension/pointerevent_pointerrawmove-manual.html": [
"0c4ccf9ad48d49c62b3d138845dfa3ac631a8e4e",
"manual"
],
"pointerevents/extension/pointerevent_pointerrawmove_in_pointerlock-manual.html": [
"30fff15bd92f536de826b7ef98419b6a30284d41",
"970355863bb7d6affb0b50289af75b98cfccbb57",
"manual"
],
"pointerevents/extension/pointerevent_touch-action-pan-down-css_touch-manual.html": [
Expand Down Expand Up @@ -631587,10 +631614,22 @@
"d8dbeaae172dfd6314341c55ef1fa3b9945f60fc",
"manual"
],
"pointerevents/pointerlock/pointerevent_pointermove_in_pointerlock-manual.html": [
"80c01d61c8f906364fea0497d32cbd44ad8fdd3f",
"manual"
],
"pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked-manual.html": [
"b2fadbfe05f7efcc674f2b4cac61a15a67560597",
"manual"
],
"pointerevents/pointerlock/resources/pointerevent_movementxy-iframe.html": [
"627af3b61cad74bb112558169b1e66f6a24b1129",
"support"
],
"pointerevents/pointerlock/resources/pointerevent_pointermove_in_pointerlock-iframe.html": [
"b7cc7068e96c7dbbf7f8ffa9e5ce9bd1ce63686f",
"support"
],
"pointerevents/resources/pointerevent_attributes_hoverable_pointers-iframe.html": [
"5e55868282ce5ce549f1d32092839f05bd43aba7",
"support"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!doctype html>
<html>
<head>
<title>Pointer Events pointer lock tests</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="../pointerevent_support.js"></script>
<style>
#testContainer {
touch-action: none;
user-select: none;
position: relative;
}
</style>
<script>
var lock_change_count = 0;
var mouseeventMovements = []
var pointereventMovements = []

function resetTestState() {
}

function run() {
var test_pointerEvent = setup_pointerevent_test("pointermove getCoalescedEvents when lock test", ['mouse']);
var div1 = document.getElementById("target");

on_event(div1, 'pointerdown', function(event) {
div1.requestPointerLock();
});
on_event(div1, 'pointermove', function(event) {
if (document.pointerLockElement == div1) {
test_pointerEvent.step(function() {
assert_greater_than(event.getCoalescedEvents().length, 0, "document.pointerLockElement should have coalesced events.");
document.exitPointerLock();
test_pointerEvent.done();
});
}
});
}
</script>
</head>
<body onload="run()">
<h1>PointerMove getCoalescedEvent in locked state test</h1>
<h2 id="pointerTypeDescription"></h2>
<h4>
Test Description: This test checks if pointerevent.getCoalescedEvent work correctly when pointer is locked.
<ol>
<li>Press left button down on the green rectangle to lock pointer.</li>
<li>Move the mouse</li>
</ol>
</ol>

Test passes if the proper behavior of the events is observed.
</h4>
<div id="testContainer">
<div id="target" style="width:800px;height:250px;background:green"></div>
</div>
<div class="spacer"></div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
</head>
<body onload="run()">
<h2>pointerrawmove</h2>
<h4>Test Description: This test checks if pointerrawmove is dispatched correctly while in pointerlock mode. </h4>
<p>Click in the box (and accept the pointerlock permission if asked).</p>
<p>Move your mouse.</p>
<h4>Test Description: This test checks if pointerrawmove is dispatched correctly while in pointerlock mode.
<ol>
<li>Click in the black box (and accept the pointerlock permission if asked).</li>
<li>Move your mouse.</li>
<li>Click in the purple box inside the iframe</li>
<li>Move your mouse.</li>
</ol>
</h4>
<div id="target0"></div>
<iframe id="innerframe" src="../resources/pointerevent_pointerrawmove_in_pointerlock-iframe.html"></iframe>
<script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!doctype html>
<html>
<head>
<title>pointermove</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="../pointerevent_support.js"></script>
</head>
<body onload="run()">
<h2>pointerlock</h2>
<h4>Test Description: This test checks if pointermove is dispatched correctly while in pointerlock mode.
<ol>
<li>Click in the black box (and accept the pointerlock permission if asked).</li>
<li>Move your mouse.</li>
<li>Click in the purple box inside the iframe</li>
<li>Move your mouse.</li>
</ol>
</h4>
<div id="target0"></div>
<iframe id="innerframe" src="resources/pointerevent_pointermove_in_pointerlock-iframe.html"></iframe>
<script>
window.name="outerframe";
var test_pointermove = async_test("pointermove event received");

function run() {
var target0 = document.getElementById("target0");
var innerframe = document.getElementById('innerframe');
var target1 = innerframe.contentDocument.getElementById('target1');
innerframe.contentWindow.name = "innerframe";

on_event(document, "pointerlockchange", function(event) {
if (document.pointerLockElement == target0) {
on_event(target0, "pointermove", function (event) {
test_pointermove.step(function() {
assert_equals(event.view.name, "outerframe", "View attribute of pointermove should be the target frame.");
}, "View attribute of pointermove should be the target frame.");
document.exitPointerLock();

on_event(target1, "click", function(event) {
target1.requestPointerLock();
});

on_event(innerframe.contentDocument, "pointerlockchange", function(event) {
if (innerframe.contentDocument.pointerLockElement == target1) {
on_event(target1, "pointermove", function (event) {
innerframe_pointermoveReceived = true;
test_pointermove.step(function() {
assert_equals(event.view.name, "innerframe", "View attribute of pointermove should be the target frame.");
}, "View attribute of pointermove should be the target frame.");
innerframe.contentDocument.exitPointerLock();
test_pointermove.done();
});
}
});
});
}
});
on_event(target0, "click", function(event) {
target0.requestPointerLock();
});
}

</script>
<div id="complete-notice">
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!doctype html>
<html>
<head>
<title>Pointermove on button state changes</title>
<meta name="viewport" content="width=device-width">
<meta name="assert" content="When a pointer changes button state and does not produce a different event, the pointermove event must be dispatched."/>
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="../pointerevent_support.js"></script>
</head>
<body onload="run()">
<h2>PointerMove</h2>
<h4>Test Description: This test checks if pointermove event are triggered by button state changes
<ol>
<li>Lick on the black rectangle to lock the pointer </li>
<li>Press a button and hold it</li>
<li>Press a second button</li>
<li>Release the second button</li>
<li>Release the first button to complete the test</li>
</ol>
</h4>
<div id="target0" style="background:black"></div>
<script>
var eventTested = false;
var detected_pointertypes = {};
var test_pointermove = async_test("pointer locked pointermove events received for button state changes");
add_completion_callback(showPointerTypes);

var step = 0;
var firstButton = 0;
var pointer_locked = false;

function run() {
var target0 = document.getElementById("target0");

// When a pointer changes button state and the circumstances produce no other pointer event, the pointermove event must be dispatched.
// 5.2.6

on_event(target0, "pointerdown", function (event) {
if (pointer_locked) {
detected_pointertypes[event.pointerType] = true;
test_pointermove.step(function() {assert_true(step === 0, "There must not be more than one pointer down event.");});
if (step == 0) {
step = 1;
firstButton = event.buttons;
}
}
});
on_event(target0, "pointermove", function (event) {
if (pointer_locked) {
detected_pointertypes[event.pointerType] = true;

if (step == 1 && event.button != -1) { // second button pressed
test_pointermove.step(function() {assert_true(event.buttons !== firstButton, "The pointermove event must be triggered by pressing a second button.");});
test_pointermove.step(function() {assert_true((event.buttons & firstButton) != 0, "The first button must still be reported pressed.");});
step = 2;
} else if (step == 2 && event.button != -1) { // second button released
test_pointermove.step(function() {assert_true(event.buttons === firstButton, "The pointermove event must be triggered by releasing the second button.");});
step = 3;
}
}
});
on_event(target0, "pointerup", function (event) {
if (pointer_locked) {
detected_pointertypes[event.pointerType] = true;
test_pointermove.step(function() {assert_true(step === 3, "The pointerup event must be triggered after pressing and releasing the second button.");});
test_pointermove.step(function() {assert_true(event.buttons === 0, "The pointerup event must be triggered by releasing the last pressed button.");});
document.exitPointerLock();
test_pointermove.done();
eventTested = true;
} else {
target0.requestPointerLock();
}
});
on_event(document, 'pointerlockchange', function(event) {
if (document.pointerLockElement == target0)
pointer_locked = true;
else
pointer_locked = false;
});
on_event(target0, "mouseup", function (event) {
event.preventDefault();
});
on_event(target0, "contextmenu", function (event) {
event.preventDefault();
});
}
</script>
<h1>Pointer Lock Pointer Events pointermove on button state changes Tests</h1>
<div id="complete-notice">
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
<p>Refresh the page to run the tests again.</p>
</div>
<div id="log"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="../../pointerevent_styles.css">
</head>
<body>
<div id="target1"></div>
</body>
</html>

0 comments on commit ebb6385

Please sign in to comment.