servo/tests/wpt/web-platform-tests/touch-events/create-touch-touchlist.html

39 lines
1.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>document.createTouch and document.createTouchList Tests</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="touch-support.js"></script>
<body>
<div id="target0"></div>
<script>
test(function() {
var touchList = document.createTouchList();
assert_equals(touchList.length, 0, "touchList.length is 0");
check_TouchList_object(touchList);
}, "document.createTouchList exists and correctly creates a TouchList from zero Touch objects");
test(function() {
var testTarget = document.getElementById('target0');
var touch1 = new Touch({identifier: 123, target: testTarget});
var touchList = document.createTouchList(touch1);
assert_equals(touchList.length, 1, "touchList.length is 1");
assert_equals(touchList.item(0), touch1, "touchList.item(0) is touch1");
check_TouchList_object(touchList);
}, "document.createTouchList exists and correctly creates a TouchList from a single Touch");
test(function() {
var testTarget = document.getElementById('target0');
var touch1 = new Touch({identifier: 123, target: testTarget});
var touch2 = new Touch({identifier: 124, target: target0});
var touchList = document.createTouchList(touch1, touch2);
assert_equals(touchList.length, 2, "touchList.length is 2");
assert_equals(touchList.item(0), touch1, "touchList.item(0) is touch1");
assert_equals(touchList.item(1), touch2, "touchList.item(1) is touch2");
check_TouchList_object(touchList);
}, "document.createTouchList exists and correctly creates a TouchList from two Touch objects");
</script>
</head>
</body>
</html>