2 <script src=
"../../../../resources/js-test.js"></script>
9 <iframe id=
"target" src=
"resources/event-delegator.html"></iframe>
10 <div id=console
></div>
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
);
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();
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');
65 setTimeout(resolve
, 0);
67 window
.target
= clone
;
72 if (window
.eventSender
) {
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
);
83 debug("This test requires eventSender");