26 <script src=
"../../../resources/js-test.js"></script>
33 function clickOn(element
)
35 var rect
= element
.getBoundingClientRect();
36 eventSender
.mouseMoveTo(rect
.left
+ rect
.width
/ 2, rect
.top
+ rect
.height
/ 2);
37 eventSender
.mouseDown();
38 eventSender
.mouseUp();
41 // For manual testing, indicate success only if automatic testing would also
42 // print success for all ancestor nodes.
43 function turnDivGreenOnSuccess()
45 if (handledEvent
['document'] && handledEvent
['body'] && handledEvent
['div'])
46 div
.style
.backgroundColor
= 'green';
49 description('Test that ancestors of modal <dialog> are inert. To test manually, ' +
50 'click the left box. There should be no change. Then click the right box. ' +
51 'If both boxes turn green, the test passes.');
52 div
= document
.querySelector('#ancestor');
53 dialog
= document
.querySelector('dialog');
57 document
.addEventListener('click', function(event
) {
58 handledEvent
['document'] = true;
59 turnDivGreenOnSuccess();
62 document
.body
.addEventListener('click', function(event
) {
63 handledEvent
['body'] = true;
64 turnDivGreenOnSuccess();
65 // body should get a event only via bubbling.
66 if (event
.target
!= dialog
) {
67 testFailed('body was targeted for an click event');
68 div
.style
.backgroundColor
= 'red';
72 div
.addEventListener('click', function(event
) {
73 handledEvent
['div'] = true;
74 turnDivGreenOnSuccess();
75 // div should get a event only via bubbling.
76 if (event
.target
!= dialog
) {
77 testFailed('div was targeted for an click event');
78 div
.style
.backgroundColor
= 'red';
82 dialog
.addEventListener('click', function(event
) {
83 handledEvent
['dialog'] = true;
84 dialog
.style
.backgroundColor
= 'green';
85 if (event
.target
!= dialog
) {
86 testFailed('dialog was not targeted for a click event');
87 dialog
.style
.backgroundColor
= 'red';
91 if (window
.eventSender
) {
92 nodes
= [ 'document', 'body', 'div', 'dialog' ];
93 nodes
.map(function(node
) { handledEvent
[node
] = false; });
94 debug('Clicking on ancestor');
96 shouldBeTrue('handledEvent.document');
97 shouldBeFalse('handledEvent.body');
98 shouldBeFalse('handledEvent.dialog');
99 shouldBeFalse('handledEvent.div');
100 handledEvent
.document
= false;
102 debug('Clicking on dialog');
104 shouldBeTrue('handledEvent.document');
105 shouldBeTrue('handledEvent.body');
106 shouldBeTrue('handledEvent.dialog');
107 shouldBeTrue('handledEvent.div');