Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / gesture-tap-frame-removed.html
blobea45674891eadad28d3f8ae3fd501161c9771a68
1 <!DOCTYPE HTML>
2 <script src="../../../../resources/js-test.js"></script>
3 <style>
4 #target {
5 width: 50px;
6 height: 50px;
8 </style>
9 <iframe id="target" src="resources/event-delegator.html"></iframe>
10 <div id=console></div>
11 <script>
12 var removalEventType;
14 function onEventInFrame(e) {
15 debug("Received " + e.type + " in child frame");
16 if (e.type == removalEventType) {
17 debug('Removing iframe');
18 target.parentNode.removeChild(target);
19 internals.gc();
23 function eventLogger(e) {
24 debug("Received " + e.type + " in main frame");
27 document.addEventListener('mousemove', eventLogger);
28 document.addEventListener('mousedown', eventLogger);
29 document.addEventListener('mouseup', eventLogger);
30 document.addEventListener('click', eventLogger);
32 description("Verifies that a tap occuring on an iframe that gets removed during tap handling doesn't cause a crash.");
34 var rect = target.getBoundingClientRect();
35 var point = {
36 x: rect.left + rect.width / 2,
37 y: rect.top + rect.height / 2
40 function doTapAndRemove(type)
42 return new Promise(function(resolve, reject) {
44 var clone = target.cloneNode();
45 var insertionPoint = target.nextSibling;
47 debug('Test case: Remove during ' + type);
48 removalEventType = type;
50 eventSender.gestureTapDown(point.x, point.y);
51 eventSender.gestureShowPress(point.x, point.y);
52 debug("Sending GestureTap");
53 eventSender.gestureTap(point.x, point.y);
55 // Verify that the iframe was removed.
56 shouldBeNull("document.getElementById('target')");
58 // Ensure the event is done being processed.
59 setTimeout(function() {
60 // Reinsert the target node for the next run.
61 insertionPoint.parentNode.insertBefore(clone, insertionPoint);
62 clone.addEventListener('load', function() {
63 debug('iframe loaded');
64 debug('');
65 setTimeout(resolve, 0);
66 });
67 window.target = clone;
68 }, 0);
69 });
72 if (window.eventSender) {
73 jsTestIsAsync = true;
74 target.onload = function() {
75 doTapAndRemove('mousemove')
76 .then(function() { return doTapAndRemove('mousedown'); })
77 .then(function() { return doTapAndRemove('mouseup'); })
78 .catch(function(err) {
79 testFailed("Promise rejected: " + err.message);
80 }).then(finishJSTest);
82 } else {
83 debug("This test requires eventSender");
85 </script>