зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1296185 - Part 1: [Pointer Event] Import new web-platform-tests to pointer events mochitest. r=smaug
--HG-- extra : rebase_source : 813bab7d433fac7a166f6ff320dec3039e152b86
This commit is contained in:
Родитель
7b55a7b52d
Коммит
d4de3956f3
|
@ -6,8 +6,9 @@ support-files =
|
|||
pointerevent_styles.css
|
||||
pointerevent_support.js
|
||||
|
||||
[test_pointerevent_button_attribute_mouse-manual.html]
|
||||
support-files = pointerevent_button_attribute_mouse-manual.html
|
||||
[test_pointerevent_attributes_mouse-manual.html]
|
||||
support-files = pointerevent_attributes_mouse-manual.html
|
||||
disabled = should be investigated
|
||||
[test_pointerevent_capture_mouse-manual.html]
|
||||
support-files = pointerevent_capture_mouse-manual.html
|
||||
[test_pointerevent_capture_suppressing_mouse-manual.html]
|
||||
|
@ -26,6 +27,9 @@ support-files =
|
|||
support-files = pointerevent_lostpointercapture_for_disconnected_node-manual.html
|
||||
[test_pointerevent_lostpointercapture_is_first-manual.html]
|
||||
support-files = pointerevent_lostpointercapture_is_first-manual.html
|
||||
[test_pointerevent_multiple_primary_pointers_boundary_events-manual.html]
|
||||
support-files = pointerevent_multiple_primary_pointers_boundary_events-manual.html
|
||||
disabled = should be investigated
|
||||
[test_pointerevent_pointercancel_touch-manual.html]
|
||||
support-files = pointerevent_pointercancel_touch-manual.html
|
||||
[test_pointerevent_pointerdown-manual.html]
|
||||
|
@ -34,6 +38,11 @@ support-files =
|
|||
support-files = pointerevent_pointerenter_does_not_bubble-manual.html
|
||||
[test_pointerevent_pointerenter_nohover-manual.html]
|
||||
support-files = pointerevent_pointerenter_nohover-manual.html
|
||||
[test_pointerevent_pointerId_scope-manual.html]
|
||||
support-files =
|
||||
test_pointerevent_pointerId_scope-manual.html
|
||||
./resources/pointerevent_pointerId_scope-iframe.html
|
||||
disabled = should be investigated
|
||||
[test_pointerevent_pointerenter-manual.html]
|
||||
support-files = pointerevent_pointerenter-manual.html
|
||||
[test_pointerevent_pointerleave_after_pointercancel_touch-manual.html]
|
||||
|
@ -57,6 +66,9 @@ support-files =
|
|||
support-files = pointerevent_pointermove-manual.html
|
||||
[test_pointerevent_pointermove_isprimary_same_as_pointerdown-manual.html]
|
||||
support-files = pointerevent_pointermove_isprimary_same_as_pointerdown-manual.html
|
||||
[test_pointerevent_pointermove-on-chorded-mouse-button.html]
|
||||
support-files = pointerevent_pointermove-on-chorded-mouse-button.html
|
||||
disabled = should be investigated
|
||||
[test_pointerevent_pointermove_pointertype-manual.html]
|
||||
support-files = pointerevent_pointermove_pointertype-manual.html
|
||||
[test_pointerevent_pointerout-manual.html]
|
||||
|
@ -100,6 +112,12 @@ support-files =
|
|||
support-files = pointerevent_setpointercapture_invalid_pointerid-manual.html
|
||||
[test_pointerevent_setpointercapture_relatedtarget-manual.html]
|
||||
support-files = pointerevent_setpointercapture_relatedtarget-manual.html
|
||||
[test_pointerevent_suppress_compat_events_on_click.html]
|
||||
support-files = pointerevent_suppress_compat_events_on_click.html
|
||||
disabled = should be investigated
|
||||
[test_pointerevent_suppress_compat_events_on_drag_mouse.html]
|
||||
support-files = pointerevent_suppress_compat_events_on_drag_mouse.html
|
||||
disabled = should be investigated
|
||||
[test_touch_action.html]
|
||||
# Windows touch injection doesn't work in automation, but this test can be run locally on a windows touch device.
|
||||
skip-if = (toolkit == 'windows')
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pointer Events properties 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-->
|
||||
<!-- Additional helper script for common checks across event types -->
|
||||
<script type="text/javascript" src="pointerevent_support.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script>
|
||||
var detected_pointertypes = {};
|
||||
var detected_eventTypes = {};
|
||||
var test_pointerEvent = async_test("pointerevent attributes");
|
||||
// showPointerTypes is defined in pointerevent_support.js
|
||||
// Requirements: the callback function will reference the test_pointerEvent object and
|
||||
// will fail unless the async_test is created with the var name "test_pointerEvent".
|
||||
add_completion_callback(showPointerTypes);
|
||||
|
||||
function run() {
|
||||
var square1 = document.getElementById("square1");
|
||||
var rectSquare1 = square1.getBoundingClientRect();
|
||||
var pointerover_event;
|
||||
|
||||
var eventList = ['pointerenter', 'pointerover', 'pointermove', 'pointerdown', 'pointerup', 'pointerout', 'pointerleave'];
|
||||
eventList.forEach(function(eventName) {
|
||||
on_event(square1, eventName, function (event) {
|
||||
if (detected_eventTypes[event.type])
|
||||
return;
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
test(function () {
|
||||
assert_equals(event.pointerType, 'mouse', 'pointerType should be mouse');
|
||||
}, event.type + ".pointerType attribute is correct.");
|
||||
|
||||
// Test button and buttons
|
||||
if (event.type == 'pointerdown') {
|
||||
test(function() {
|
||||
assert_true(event.button == 0, "If left mouse button is pressed button attribute is 0")
|
||||
}, event.type + "'s button attribute is 0 when left mouse button is pressed.");
|
||||
test(function() {
|
||||
assert_true(event.buttons == 1, "If left mouse button is pressed buttons attribute is 1")
|
||||
}, event.type + "'s buttons attribute is 1 when left mouse button is pressed.");
|
||||
} else if (event.type == 'pointerup') {
|
||||
test(function() {
|
||||
assert_true(event.button == 0, "If left mouse button is just released button attribute is 0")
|
||||
}, event.type + "'s button attribute is 0 when left mouse button is just released.");
|
||||
test(function() {
|
||||
assert_true(event.buttons == 0, "If left mouse button is just released buttons attribute is 0")
|
||||
}, event.type + "'s buttons attribute is 0 when left mouse button is just released.");
|
||||
} else {
|
||||
test(function() {
|
||||
assert_true(event.button == -1, "If mouse buttons are released button attribute is -1")
|
||||
}, event.type + "'s button is -1 when mouse buttons are released.");
|
||||
test(function() {
|
||||
assert_true(event.buttons == 0, "If mouse buttons are released buttons attribute is 0")
|
||||
}, event.type + "'s buttons is 0 when mouse buttons are released.");
|
||||
}
|
||||
|
||||
// Test clientX and clientY
|
||||
if (event.type != 'pointerout' && event.type != 'pointerleave' ) {
|
||||
test(function () {
|
||||
assert_true(event.clientX >= rectSquare1.left && event.clientX < rectSquare1.right, "ClientX should be in the boundaries of the black box");
|
||||
}, event.type + ".clientX attribute is correct.");
|
||||
test(function () {
|
||||
assert_true(event.clientY >= rectSquare1.top && event.clientY < rectSquare1.bottom, "ClientY should be in the boundaries of the black box");
|
||||
}, event.type + ".clientY attribute is correct.");
|
||||
} else {
|
||||
test(function () {
|
||||
assert_true(event.clientX < rectSquare1.left || event.clientX > rectSquare1.right - 1 || event.clientY < rectSquare1.top || event.clientY > rectSquare1.bottom - 1, "ClientX/Y should be out of the boundaries of the black box");
|
||||
}, event.type + "'s ClientX and ClientY attributes are correct.");
|
||||
}
|
||||
|
||||
// Test isPrimary
|
||||
test(function () {
|
||||
assert_equals(event.isPrimary, true, "isPrimary should be true");
|
||||
}, event.type + ".isPrimary attribute is correct.");
|
||||
|
||||
check_PointerEvent(event);
|
||||
detected_eventTypes[event.type] = true;
|
||||
if (Object.keys(detected_eventTypes).length == eventList.length)
|
||||
test_pointerEvent.done();
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Events pointerdown tests</h1>
|
||||
<!--
|
||||
<h4>
|
||||
Test Description: This test checks the properties of mouse pointer events. Move your mouse over the black square and click on it. Then move it off the black square.
|
||||
</h4>
|
||||
-->
|
||||
Test passes if the proper behavior of the events is observed.
|
||||
<div id="square1" class="square"></div>
|
||||
<div class="spacer"></div>
|
||||
<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 with a different pointer type.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Button and buttons attribute test for mouse</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>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Button attribute test for mouse</h1>
|
||||
<!--
|
||||
<h2>This test is for mouse only</h2>
|
||||
<h4>
|
||||
Test Description: This test checks if button attribute for mouse handled properly.
|
||||
<p>Put your mouse over the black rectangle</p>
|
||||
</h4>
|
||||
<p>
|
||||
-->
|
||||
<div id="target0" style="background:black"></div>
|
||||
<div id="target1" style="background:yellow"></div>
|
||||
<script>
|
||||
var eventTested = false;
|
||||
var detected_pointertypes = {};
|
||||
|
||||
setup({ explicit_done: true });
|
||||
add_completion_callback(showPointerTypes);
|
||||
|
||||
function run() {
|
||||
var target0 = document.getElementById("target0");
|
||||
|
||||
// If pointerType is "mouse" and no mouse button is depressed, then the button attribute of the pointermove event must be -1 and the buttons attribute must be 0.
|
||||
// TA: 5.8
|
||||
on_event(target0, "pointerover", function (event) {
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
if(event.pointerType != "mouse") {
|
||||
alert("Use mouse for this test please!");
|
||||
return;
|
||||
}
|
||||
if (eventTested == false) {
|
||||
test(function() {
|
||||
assert_true(event.button == -1, "If mouse buttons are released button attribute is -1")
|
||||
}, "If mouse buttons are released button attribute is -1");
|
||||
test(function() {
|
||||
assert_true(event.buttons == 0, "If mouse buttons are released buttons attribute is 0")
|
||||
}, "If mouse buttons are released buttons attribute is 0");
|
||||
eventTested = true;
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<h1>Pointer Events button attribute test for mouse test</h1>
|
||||
<div id="complete-notice">
|
||||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,148 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pointer Event: Boundary compatibility events for multiple primary pointers</title>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
|
||||
<link rel="author" title="Google" href="http://www.google.com "/>
|
||||
<meta name="assert" content="When more than one primary pointers are active, each will have an independent sequence of pointer boundary events but the compatibilty mouse boundary events have their own sequence."/>
|
||||
<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>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script type="text/javascript">
|
||||
var test_pointerEvent = async_test("Multi-pointer boundary compat events");
|
||||
add_completion_callback(end_of_test);
|
||||
|
||||
var detected_pointertypes = {};
|
||||
var event_log = [];
|
||||
|
||||
// These two ids help us detect two different pointing devices.
|
||||
var first_entry_pointer_id = -1;
|
||||
var second_entry_pointer_id = -1;
|
||||
|
||||
// Current node for each pointer id
|
||||
var current_node_for_id = {};
|
||||
|
||||
function end_of_test() {
|
||||
showLoggedEvents();
|
||||
showPointerTypes();
|
||||
}
|
||||
|
||||
function end_of_interaction() {
|
||||
test(function () {
|
||||
assert_equals(event_log.join(", "),
|
||||
"mouseover@target0, mouseenter@target0, mouseout@target0, mouseleave@target0, " +
|
||||
"mouseover@target1, mouseenter@target1, mouseout@target1, mouseleave@target1, " +
|
||||
"mouseover@target0, mouseenter@target0, mouseout@target0, mouseleave@target0"
|
||||
);
|
||||
}, "Event log");
|
||||
|
||||
test_pointerEvent.done(); // complete test
|
||||
}
|
||||
|
||||
function log_event(label) {
|
||||
event_log.push(label);
|
||||
}
|
||||
|
||||
function run() {
|
||||
on_event(document.getElementById("done"), "click", end_of_interaction);
|
||||
|
||||
var target_list = ["target0", "target1"];
|
||||
var pointer_event_list = ["pointerenter", "pointerleave", "pointerover", "pointerout", "pointerdown"];
|
||||
var mouse_event_list = ["mouseenter", "mouseleave", "mouseover", "mouseout"];
|
||||
|
||||
target_list.forEach(function(targetId) {
|
||||
var target = document.getElementById(targetId);
|
||||
|
||||
pointer_event_list.forEach(function(eventName) {
|
||||
on_event(target, eventName, function (event) {
|
||||
var label = event.type + "@" + targetId;
|
||||
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
|
||||
if (!event.isPrimary) {
|
||||
test(function () {
|
||||
assert_unreached("Non-primary pointer " + label);
|
||||
}, "Non-primary pointer " + label);
|
||||
}
|
||||
|
||||
if (event.type === "pointerenter") {
|
||||
var pointer_id = event.pointerId;
|
||||
if (current_node_for_id[pointer_id] !== undefined) {
|
||||
test(function () {
|
||||
assert_unreached("Double entry " + label);
|
||||
}, "Double entry " + label);
|
||||
}
|
||||
current_node_for_id[pointer_id] = event.target;
|
||||
|
||||
// Test that two different pointing devices are used
|
||||
if (first_entry_pointer_id === -1) {
|
||||
first_entry_pointer_id = pointer_id;
|
||||
} else if (second_entry_pointer_id === -1) {
|
||||
second_entry_pointer_id = pointer_id;
|
||||
test(function () {
|
||||
assert_true(first_entry_pointer_id !== second_entry_pointer_id);
|
||||
}, "Different pointing devices");
|
||||
}
|
||||
} else if (event.type === "pointerleave") {
|
||||
var pointer_id = event.pointerId;
|
||||
if (current_node_for_id[pointer_id] !== event.target) {
|
||||
test(function () {
|
||||
assert_unreached("Double exit " + label);
|
||||
}, "Double exit " + label);
|
||||
}
|
||||
current_node_for_id[pointer_id] = undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mouse_event_list.forEach(function(eventName) {
|
||||
on_event(target, eventName, function (event) {
|
||||
log_event(event.type + "@" + targetId);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#target0, #target1 {
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
#done {
|
||||
margin: 20px;
|
||||
border: 2px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Event: Boundary compatibility events for multiple primary pointers</h1>
|
||||
<!--
|
||||
<h4>
|
||||
When more than one primary pointers are active, each will have an independent sequence of pointer boundary events but the compatibilty mouse boundary events have their own sequence.
|
||||
</h4>
|
||||
Instruction:
|
||||
<ol>
|
||||
<li>Move the mouse directly into Target0 (without going through Target1), and then leave the mouse there unmoved.</li>
|
||||
<li>Tap directly on Target1 with a finger or a stylus, and then lift the finger/stylus off the screen/digitizer without crossing Target1 boundary.</li>
|
||||
<li>Move the mouse into Target0 (if not there already) and move inside it.</li>
|
||||
<li>Click Done (without passing over Target1).</li>
|
||||
</ol>
|
||||
-->
|
||||
<div id="done">
|
||||
Done
|
||||
</div>
|
||||
<div id="target0">
|
||||
Target0
|
||||
</div>
|
||||
<div id="target1">
|
||||
Target1
|
||||
</div>
|
||||
<div id="complete-notice">
|
||||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
|
||||
<p>The following events were logged: <span id="event-log"></span>.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,85 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<!--
|
||||
Test cases for Pointer Events v1 spec
|
||||
This document references Test Assertions (abbrev TA below) written by Cathy Chan
|
||||
http://www.w3.org/wiki/PointerEvents/TestAssertions
|
||||
-->
|
||||
<head>
|
||||
<title>Pointer Events pointerdown 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-->
|
||||
<!-- Additional helper script for common checks across event types -->
|
||||
<script type="text/javascript" src="pointerevent_support.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script>
|
||||
var detected_pointertypes = {};
|
||||
var test_pointerEvent = async_test("pointerId of an active pointer is the same across iframes");
|
||||
// showPointerTypes is defined in pointerevent_support.js
|
||||
// Requirements: the callback function will reference the test_pointerEvent object and
|
||||
// will fail unless the async_test is created with the var name "test_pointerEvent".
|
||||
add_completion_callback(showPointerTypes);
|
||||
var detected_pointertypes = {};
|
||||
|
||||
function run() {
|
||||
var target0 = document.getElementById("target0");
|
||||
var pointerover_pointerId = null;
|
||||
var pointerover_pointerType = null;
|
||||
|
||||
var eventList = ['pointerenter', 'pointerover', 'pointermove', 'pointerout', 'pointerleave'];
|
||||
var receivedEvents = {};
|
||||
var receivedEventsInnerFrame = {};
|
||||
|
||||
|
||||
function checkPointerId(event, inner) {
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
var eventName = (inner ? "inner frame " : "" ) + event.type;
|
||||
test_pointerEvent.step(function() {
|
||||
assert_equals(event.pointerId, pointerover_pointerId, "PointerId of " + eventName + " is not correct");
|
||||
assert_equals(event.pointerType, pointerover_pointerType, "PointerType of " + eventName + " is not correct");
|
||||
}, eventName + ".pointerId were the same as first pointerover");
|
||||
}
|
||||
|
||||
on_event(window, "message", function(event) {
|
||||
var pe_event = JSON.parse(event.data);
|
||||
receivedEventsInnerFrame[pe_event.type] = 1;
|
||||
checkPointerId(pe_event, true);
|
||||
if (Object.keys(receivedEvents).length == eventList.length && Object.keys(receivedEventsInnerFrame).length == eventList.length)
|
||||
test_pointerEvent.done();
|
||||
});
|
||||
|
||||
eventList.forEach(function(eventName) {
|
||||
on_event(target0, eventName, function (event) {
|
||||
if (pointerover_pointerId === null && event.type == 'pointerover') {
|
||||
pointerover_pointerId = event.pointerId;
|
||||
pointerover_pointerType = event.pointerType;
|
||||
} else {
|
||||
checkPointerId(event, false);
|
||||
}
|
||||
receivedEvents[event.type] = 1;
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Events pointerdown tests</h1>
|
||||
Complete the following actions:
|
||||
<!--
|
||||
<ol>
|
||||
<li>Start with your pointing device outside of black box, then move it into black box. If using touch just press in black box and don't release.
|
||||
<li>Move your pointing device into purple box (without leaving the digitizer range if you are using hover supported pen or without releasing touch if using touch). Then move it out of the purple box.
|
||||
</ol>
|
||||
-->
|
||||
<div id="target0" class="touchActionNone">
|
||||
</div>
|
||||
<iframe src="resources/pointerevent_pointerId_scope-iframe.html" id="innerframe"></iframe>
|
||||
<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 with a different pointer type.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,77 @@
|
|||
<!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>
|
||||
<script type="text/javascript" src="mochitest_support_internal.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>Put your mouse over the black rectangle</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("pointermove events received for button state changes");
|
||||
add_completion_callback(showPointerTypes);
|
||||
|
||||
var step = 0;
|
||||
var firstButton = 0;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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.");});
|
||||
test_pointermove.done();
|
||||
eventTested = true;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<h1>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>
|
|
@ -1,3 +1,20 @@
|
|||
.spacer {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
#square1 {
|
||||
background: black;
|
||||
top: 150px;
|
||||
left: 100px;
|
||||
}
|
||||
|
||||
.square {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
position: absolute;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#target0 {
|
||||
background: black;
|
||||
color: white;
|
||||
|
@ -14,6 +31,17 @@ overflow-y: auto;
|
|||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.touchActionNone {
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
#innerframe {
|
||||
width: 90%;
|
||||
margin: 10px;
|
||||
margin-left: 10%;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.scroller {
|
||||
width: 700px;
|
||||
height: 430px;
|
||||
|
@ -49,6 +77,10 @@ display: none;
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
#event-log {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#listener {
|
||||
background: orange;
|
||||
border: 1px solid orange;
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pointer Event: Suppress compatibility mouse events on click</title>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
|
||||
<link rel="author" title="Google" href="http://www.google.com "/>
|
||||
<meta name="assert" content="When a pointerdown is canceled, a click/tap shouldn't fire any compatibility mouse events."/>
|
||||
<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>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script type="text/javascript">
|
||||
var test_pointerEvent = async_test("Suppress compat mouse events on click");
|
||||
add_completion_callback(end_of_test);
|
||||
|
||||
var detected_pointertypes = {};
|
||||
var event_log = [];
|
||||
|
||||
function end_of_test() {
|
||||
showLoggedEvents();
|
||||
showPointerTypes();
|
||||
}
|
||||
|
||||
function end_of_interaction() {
|
||||
test(function () {
|
||||
assert_equals(event_log.join(", "),
|
||||
"mousedown@target1, mouseup@target1");
|
||||
}, "Event log");
|
||||
|
||||
test_pointerEvent.done(); // complete test
|
||||
}
|
||||
|
||||
function run() {
|
||||
on_event(document.getElementById("done"), "click", end_of_interaction);
|
||||
|
||||
var target_list = ["target0", "target1"];
|
||||
var pointer_event_list = ["pointerdown"];
|
||||
var mouse_event_list = ["mousedown", "mouseup"];
|
||||
|
||||
target_list.forEach(function(targetId) {
|
||||
var target = document.getElementById(targetId);
|
||||
|
||||
pointer_event_list.forEach(function(eventName) {
|
||||
on_event(target, eventName, function (event) {
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
var label = event.type + "@" + targetId;
|
||||
|
||||
test(function () {
|
||||
assert_true(event.isPrimary);
|
||||
}, "primary pointer " + label);
|
||||
|
||||
if (label === "pointerdown@target0")
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
mouse_event_list.forEach(function(eventName) {
|
||||
on_event(target, eventName, function (event) {
|
||||
event_log.push(event.type + "@" + targetId);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#target0, #target1 {
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
#done {
|
||||
margin: 20px;
|
||||
border: 2px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Event: Suppress compatibility mouse events on click</h1>
|
||||
<h4>
|
||||
When a pointerdown is canceled, a click/tap shouldn't fire any compatibility mouse events.
|
||||
</h4>
|
||||
<!--
|
||||
<ol>
|
||||
<li> Click or tap on Target0.</li>
|
||||
<li> Click or tap on Target1.</li>
|
||||
<li> Click Done.</li>
|
||||
</ol>
|
||||
-->
|
||||
<div id="target0">
|
||||
Target0
|
||||
</div>
|
||||
<div id="target1">
|
||||
Target1
|
||||
</div>
|
||||
<div id="done">
|
||||
Done
|
||||
</div>
|
||||
<div id="complete-notice">
|
||||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
|
||||
<p>The following events were logged: <span id="event-log"></span>.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,117 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pointer Event: Suppress compatibility mouse events on drag</title>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
|
||||
<link rel="author" title="Google" href="http://www.google.com "/>
|
||||
<meta name="assert" content="When a pointerdown is canceled, a mouse drag shouldn't fire any compatibility mouse events."/>
|
||||
<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>
|
||||
<script type="text/javascript" src="mochitest_support_internal.js"></script>
|
||||
<script type="text/javascript">
|
||||
var test_pointerEvent = async_test("Suppress compat mouse events on drag");
|
||||
add_completion_callback(end_of_test);
|
||||
|
||||
var detected_pointertypes = {};
|
||||
var event_log = [];
|
||||
|
||||
function end_of_test() {
|
||||
showLoggedEvents();
|
||||
showPointerTypes();
|
||||
}
|
||||
|
||||
var include_next_mousemove = false;
|
||||
|
||||
// Limits logging/testing of mousemove.
|
||||
function drop_event(event_type) {
|
||||
return (event_type == "mousemove" && !include_next_mousemove);
|
||||
}
|
||||
|
||||
function end_of_interaction() {
|
||||
test(function () {
|
||||
assert_equals(event_log.join(", "),
|
||||
"mousedown@target1, mousemove@target1, mouseup@target1");
|
||||
}, "Event log");
|
||||
|
||||
test_pointerEvent.done(); // complete test
|
||||
}
|
||||
|
||||
function run() {
|
||||
on_event(document.getElementById("done"), "click", end_of_interaction);
|
||||
|
||||
var target_list = ["target0", "target1"];
|
||||
var pointer_event_list = ["pointerdown"];
|
||||
var mouse_event_list = ["mousedown", "mouseup", "mousemove"];
|
||||
|
||||
target_list.forEach(function(targetId) {
|
||||
var target = document.getElementById(targetId);
|
||||
|
||||
pointer_event_list.forEach(function(eventName) {
|
||||
on_event(target, eventName, function (event) {
|
||||
detected_pointertypes[event.pointerType] = true;
|
||||
var label = event.type + "@" + targetId;
|
||||
|
||||
test(function () {
|
||||
assert_true(event.isPrimary);
|
||||
}, "primary pointer " + label);
|
||||
|
||||
if (label === "pointerdown@target0")
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
mouse_event_list.forEach(function(eventName) {
|
||||
on_event(target, eventName, function (event) {
|
||||
if (drop_event(event.type))
|
||||
return;
|
||||
|
||||
event_log.push(event.type + "@" + targetId);
|
||||
|
||||
include_next_mousemove = (event.type == "mousedown");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#target0, #target1 {
|
||||
margin: 20px;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
#done {
|
||||
margin: 20px;
|
||||
border: 2px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>Pointer Event: Suppress compatibility mouse events on drag</h1>
|
||||
<!--
|
||||
<h4>
|
||||
When a pointerdown is canceled, a mouse drag shouldn't fire any compatibility mouse events.
|
||||
</h4>
|
||||
<ol>
|
||||
<li> Drag mouse within Target0 & release.</li>
|
||||
<li> Drag mouse within Target1 & release.</li>
|
||||
<li> Click Done.</li>
|
||||
</ol>
|
||||
-->
|
||||
<div id="target0">
|
||||
Target0
|
||||
</div>
|
||||
<div id="target1">
|
||||
Target1
|
||||
</div>
|
||||
<div id="done">
|
||||
Done
|
||||
</div>
|
||||
<div id="complete-notice">
|
||||
<p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
|
||||
<p>The following events were logged: <span id="event-log"></span>.</p>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<!--
|
||||
Test cases for Pointer Events v1 spec
|
||||
This document references Test Assertions (abbrev TA below) written by Cathy Chan
|
||||
http://www.w3.org/wiki/PointerEvents/TestAssertions
|
||||
-->
|
||||
<head>
|
||||
<title>Pointer Events pointerdown tests</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
|
||||
<script>
|
||||
function run() {
|
||||
var target1 = document.getElementById("target1");
|
||||
var pointerover_event;
|
||||
var ponterId = null;
|
||||
|
||||
var eventList = ['pointerenter', 'pointerover', 'pointermove', 'pointerout', 'pointerleave'];
|
||||
|
||||
eventList.forEach(function(eventName) {
|
||||
target1.addEventListener(eventName, function (event) {
|
||||
var pass_data = {
|
||||
'pointerId' : event.pointerId,
|
||||
'type' : event.type,
|
||||
'pointerType' : event.pointerType
|
||||
};
|
||||
top.postMessage(JSON.stringify(pass_data), "*");
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<div id="target1" class="touchActionNone">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1000870</title>
|
||||
<meta name="author" content="Maksim Lebedev" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "pointerevent_attributes_mouse-manual.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
var square1 = int_win.document.getElementById("square1");
|
||||
var rect = square1.getBoundingClientRect();
|
||||
var x = rect.left + rect.width / 4;
|
||||
var y = rect.top + rect.height / 2
|
||||
synthesizeMouseAtPoint(x, y, {type: "mousemove", button:-1}, int_win);
|
||||
synthesizeMouseAtPoint(x, y, {type: "mousedown", button:0}, int_win);
|
||||
synthesizeMouseAtPoint(x, y, {type: "mouseup", button:0}, int_win);
|
||||
synthesizeMouseAtPoint(x, y, {type: "mousemove", button:-1}, int_win);
|
||||
synthesizeMouseAtPoint(rect.left-1, rect.top-1, {type: "mousemove", button:-1}, int_win);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1000870</title>
|
||||
<meta name="author" content="Maksim Lebedev" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "pointerevent_multiple_primary_pointers_boundary_events-manual.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendMouseEvent(int_win, "target0", "mousemove");
|
||||
sendTouchEvent(int_win, "target1", "touchstart");
|
||||
sendTouchEvent(int_win, "target1", "touchend");
|
||||
sendMouseEvent(int_win, "target0", "mousemove");
|
||||
sendMouseEvent(int_win, "done", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "done", "mouseup", {button:0});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -15,11 +15,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "pointerevent_button_attribute_mouse-manual.html";
|
||||
iframe.src = "pointerevent_pointerId_scope-manual.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendPointerEvent(int_win, "target1", "pointermove", MouseEvent.MOZ_SOURCE_MOUSE);
|
||||
sendPointerEvent(int_win, "target0", "pointermove", MouseEvent.MOZ_SOURCE_MOUSE, {button:-1});
|
||||
sendTouchEvent(int_win, "target0", "touchstart");
|
||||
sendTouchEvent(int_win, "target0", "touchend");
|
||||
}
|
||||
</script>
|
||||
</head>
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1000870</title>
|
||||
<meta name="author" content="Maksim Lebedev" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "pointerevent_pointermove-on-chorded-mouse-button.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendMouseEvent(int_win, "target0", "mousedown");
|
||||
sendMouseEvent(int_win, "target0", "mouseup");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1000870</title>
|
||||
<meta name="author" content="Maksim Lebedev" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "pointerevent_suppress_compat_events_on_click.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendMouseEvent(int_win, "target0", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "target0", "mouseup", {button:0});
|
||||
sendMouseEvent(int_win, "target1", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "target1", "mouseup", {button:0});
|
||||
sendMouseEvent(int_win, "done", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "done", "mouseup", {button:0});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1000870
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1000870</title>
|
||||
<meta name="author" content="Maksim Lebedev" />
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="text/javascript" src="mochitest_support_external.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="text/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function startTest() {
|
||||
var iframe = document.getElementById("testFrame");
|
||||
iframe.src = "pointerevent_suppress_compat_events_on_drag_mouse.html";
|
||||
}
|
||||
function executeTest(int_win) {
|
||||
sendMouseEvent(int_win, "target0", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "target0", "mousemove", {button:0});
|
||||
sendMouseEvent(int_win, "target0", "mouseup", {button:0});
|
||||
sendMouseEvent(int_win, "target1", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "target1", "mousemove", {button:0});
|
||||
sendMouseEvent(int_win, "target1", "mouseup", {button:0});
|
||||
sendMouseEvent(int_win, "done", "mousedown", {button:0});
|
||||
sendMouseEvent(int_win, "done", "mouseup", {button:0});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="testFrame" height="800" width="1000"></iframe>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче