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

Side by Side Diff: LayoutTests/fast/dom/HTMLDialogElement/modal-dialog-ancestor-is-inert.html

Issue 133393002: Make ancestors of modal <dialog> inert (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: save a tree walk if able Created 6 years, 11 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
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <style>
5 #ancestor {
6 position: absolute;
7 height: 50px;
8 width: 50px;
9 top: 200px;
10 left: 100px;
11 border: 1px solid;
12 }
13
14 dialog {
15 height: 50px;
16 width: 50px;
17 top: 200px;
18 left: 200px;
19 margin: 0;
20 }
21
22 dialog::backdrop {
23 display: none;
24 }
25 </style>
26 <script src="../../../resources/js-test.js"></script>
27 </head>
28 <body>
29 <div id="ancestor">
30 <dialog></dialog>
31 </div>
32 <script>
33 function clickOn(element)
34 {
35 var rect = element.getBoundingClientRect();
36 eventSender.mouseMoveTo(rect.top + rect.height / 2, rect.left + rect.width / 2);
37 eventSender.mouseDown();
38 eventSender.mouseUp();
39 }
40
41 // For manual testing, indicate success only if automatic testing would also
42 // print success for all ancestor nodes.
43 function turnDivGreenOnSuccess()
44 {
45 if (document.handledEvent && document.body.handledEvent && div.handledEvent)
46 div.style.backgroundColor = 'green';
47 }
48
49 description('Test that ancestors of modal &lt;dialog&gt; are inert. To test manu ally, ' +
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');
54 dialog.showModal();
55 document.addEventListener('click', function(event) {
56 document.handledEvent = true;
57 turnDivGreenOnSuccess();
58 });
59
60 document.body.addEventListener('click', function(event) {
61 document.body.handledEvent = true;
62 turnDivGreenOnSuccess();
63 // body should get a event only via bubbling.
64 if (event.target != dialog) {
65 testFailed('body was targeted for an click event');
66 div.style.backgroundColor = 'red';
67 }
68 });
69
70 div.addEventListener('click', function(event) {
71 div.handledEvent = true;
72 turnDivGreenOnSuccess();
73 // div should get a event only via bubbling.
74 if (event.target != dialog) {
75 testFailed('div was targeted for an click event');
76 div.style.backgroundColor = 'red';
77 }
78 });
79
80 dialog.addEventListener('click', function(event) {
81 dialog.handledEvent = true;
82 dialog.style.backgroundColor = 'green';
83 if (event.target != dialog) {
84 testFailed('dialog was not targeted for a click event');
85 dialog.style.backgroundColor = 'red';
86 }
87 });
88
89 if (window.eventSender) {
90 nodes = [ document, document.body, div, dialog ];
91 nodes.map(function(node) { node.handledEvent = false; });
92 debug('Clicking on ancestor');
93 clickOn(div);
94 shouldBeTrue('document.handledEvent');
95 shouldBeFalse('document.body.handledEvent');
96 shouldBeFalse('dialog.handledEvent');
97 shouldBeFalse('div.handledEvent');
98 document.handledEvent = false;
99
100 debug('Clicking on dialog');
101 clickOn(dialog);
102 shouldBeTrue('document.handledEvent');
103 shouldBeTrue('document.body.handledEvent');
104 shouldBeTrue('dialog.handledEvent');
105 shouldBeTrue('div.handledEvent');
106 }
107 </script>
108 </body>
109 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698