<!DOCTYPE html>
<script src='../../../resources/testharness.js'></script>
<script src='../../../resources/testharnessreport.js'></script>
<style>
#first {width: 100px; height: 50px; }
</style>
<body>
<div id=first />
<script>
test(function() {
var gotTouchMove = false;
var touchEvent;
var handler = function(event) {
assert_false(gotTouchMove);
gotTouchMove = true;
touchEvent = event;
assert_false(touchEvent.defaultPrevented);
console.log('Calling preventDefault on TouchEvent with cancelable=' + event.cancelable);
touchEvent.preventDefault();
};
document.addEventListener('touchmove', handler, {passive: false});
eventSender.addTouchPoint(152, 152);
eventSender.touchStart();
eventSender.updateTouchPoint(0, 155, 155);
eventSender.setTouchCancelable(true);
console.log('Sending cancelable touchmove');
eventSender.touchMove();
assert_true(gotTouchMove, "Got touch move");
assert_true(touchEvent.cancelable, "Event was cancelable");
assert_true(touchEvent.defaultPrevented, "Event was prevented");
gotTouchMove = false;
console.log('Sending uncancelable touchmove');
eventSender.setTouchCancelable(false);
eventSender.updateTouchPoint(0, 160, 160);
eventSender.touchMove();
assert_true(gotTouchMove, "Got touch move");
assert_false(touchEvent.cancelable, "Event was not cancelable");
assert_false(touchEvent.defaultPrevented, "Event was not prevented");
document.removeEventListener('touchmove', handler);
eventSender.clearTouchPoints();
}, 'Test that touch events may or may not be marked cancelable. http://crbug.com/365681');
test(function() {
var gotTouchMove = false;
var touchEvent;
var handler = function(event) {
gotTouchMove = true;
touchEvent = event;
event.preventDefault();
};
eventSender.addTouchPoint(15, 15);
eventSender.touchStart();
document.getElementById('first').addEventListener('touchmove', handler);
eventSender.setTouchCancelable(false);
eventSender.updateTouchPoint(0, 30, 30);
console.log('Sending uncancelable touchmove');
eventSender.touchMove();
assert_true(gotTouchMove, "Got touch move");
assert_false(touchEvent.cancelable, "Event was not cancelable");
assert_false(touchEvent.defaultPrevented, "Event was not prevented");
}, 'Test that warning occurs in default mode');
</script>
</body>