Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: LayoutTests/fast/events/touch/gesture/gesture-tap-frame-removed.html

Issue 466143005: Fix crash on GestureTap in Node::commonAncestor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix comment typo Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 <script src="../../../../resources/js-test.js"></script> 2 <script src="../../../../resources/js-test.js"></script>
3 <style> 3 <style>
4 #target { 4 #target {
5 width: 50px; 5 width: 50px;
6 height: 50px; 6 height: 50px;
7 } 7 }
8 </style> 8 </style>
9 <iframe id="target" src="resources/event-delegator.html"></iframe> 9 <iframe id="target" src="resources/event-delegator.html"></iframe>
10 <div id=console></div> 10 <div id=console></div>
11 <script> 11 <script>
12 var removalEventType;
13
12 function onEventInFrame(e) { 14 function onEventInFrame(e) {
13 debug("Received " + e.type + " in child frame"); 15 debug("Received " + e.type + " in child frame");
14 if (e.type == 'mousemove') { 16 if (e.type == removalEventType) {
15 debug('Removing iframe'); 17 debug('Removing iframe');
16 target.parentNode.removeChild(target); 18 target.parentNode.removeChild(target);
17 internals.gc(); 19 internals.gc();
18 } 20 }
19 } 21 }
20 22
21 function eventLogger(e) { 23 function eventLogger(e) {
22 debug("Received " + e.type + " in main frame"); 24 debug("Received " + e.type + " in main frame");
23 } 25 }
24 26
25 document.addEventListener('mousemove', eventLogger); 27 document.addEventListener('mousemove', eventLogger);
26 document.addEventListener('mousedown', eventLogger); 28 document.addEventListener('mousedown', eventLogger);
27 document.addEventListener('mouseup', eventLogger); 29 document.addEventListener('mouseup', eventLogger);
28 document.addEventListener('click', eventLogger); 30 document.addEventListener('click', eventLogger);
29 31
32 description("Verifies that a tap occuring on an iframe that gets removed during tap handling doesn't cause a crash.");
33
30 var rect = target.getBoundingClientRect(); 34 var rect = target.getBoundingClientRect();
31 var point = { 35 var point = {
32 x: rect.left + rect.width / 2, 36 x: rect.left + rect.width / 2,
33 y: rect.top + rect.height / 2 37 y: rect.top + rect.height / 2
34 }; 38 };
35 39
36 description("Verifies that a tap occuring on an iframe that gets removed during tap handling doesn't cause a crash."); 40 function doTapAndRemove(type)
41 {
42 return new Promise(function(resolve, reject) {
43
44 var clone = target.cloneNode();
45 var insertionPoint = target.nextSibling;
46
47 debug('Test case: Remove during ' + type);
48 removalEventType = type;
49
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);
54
55 // Verify that the iframe was removed.
56 shouldBeNull("document.getElementById('target')");
57
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 });
70 }
37 71
38 if (window.eventSender) { 72 if (window.eventSender) {
39 jsTestIsAsync = true; 73 jsTestIsAsync = true;
40 target.onload = function() { 74 target.onload = function() {
41 debug("Sending GestureTapDown"); 75 doTapAndRemove('mousemove')
42 eventSender.gestureTapDown(point.x, point.y); 76 .then(function() { return doTapAndRemove('mousedown'); })
43 77 .then(function() { return doTapAndRemove('mouseup'); })
44 debug("Sending GestureShowPress"); 78 .catch(function(err) {
45 eventSender.gestureShowPress(point.x, point.y); 79 testFailed("Promise rejected: " + err.message);
46 80 }).then(finishJSTest);
47 debug("Sending GestureTap");
48 eventSender.gestureTap(point.x, point.y);
49
50 shouldBeNull("document.getElementById('target')");
51
52 setTimeout(finishJSTest, 0);
53 } 81 }
54 } else { 82 } else {
55 debug("This test requires eventSender"); 83 debug("This test requires eventSender");
56 } 84 }
57 </script> 85 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698