OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../fullscreen/full-screen-test.js"></script> |
| 5 <style> |
| 6 ::backdrop { |
| 7 display: none; |
| 8 } |
| 9 |
| 10 #bottom-dialog { |
| 11 top: 100px; |
| 12 left: 100px; |
| 13 } |
| 14 |
| 15 #top-dialog { |
| 16 top: 100px; |
| 17 left: 200px; |
| 18 } |
| 19 |
| 20 #inert-element { |
| 21 top: 100px; |
| 22 left: 300px; |
| 23 } |
| 24 |
| 25 .box { |
| 26 position: absolute; |
| 27 height: 50px; |
| 28 width: 50px; |
| 29 background: green; |
| 30 } |
| 31 </style> |
| 32 </head> |
| 33 <body> |
| 34 <p>Tests that the active modal dialog is as expected when fullscreen |
| 35 elements are added to the top layer. This test requires testRunner.</p> |
| 36 |
| 37 <dialog class="box" id="bottom-dialog"></dialog> |
| 38 <dialog class="box" id="top-dialog"></dialog> |
| 39 <div class="box" id="bottom-div"> |
| 40 <div class="box" id="top-div"></div> |
| 41 </div> |
| 42 <div class="box" id="inert-element"></div> |
| 43 <script> |
| 44 bottomDialog = document.querySelector('#bottom-dialog'); |
| 45 topDialog = document.querySelector('#top-dialog'); |
| 46 bottomDiv = document.querySelector('#bottom-div'); |
| 47 topDiv = document.querySelector('#top-div'); |
| 48 inertDiv = document.querySelector('#inert-element'); |
| 49 |
| 50 expectClick = null; |
| 51 document.addEventListener('click', function(e) { |
| 52 clickedOn = e.target; |
| 53 testExpected('clickedOn', expectClick); |
| 54 }); |
| 55 |
| 56 function clickOn(element) |
| 57 { |
| 58 if (!window.eventSender) |
| 59 return; |
| 60 var rect = element.getBoundingClientRect(); |
| 61 eventSender.mouseMoveTo(rect.left + rect.width / 2, rect.top + rect.height /
2); |
| 62 eventSender.mouseDown(); |
| 63 eventSender.mouseUp(); |
| 64 } |
| 65 |
| 66 function makeFullscreen(element) |
| 67 { |
| 68 runWithKeyDown(function() { element.webkitRequestFullscreen(); }); |
| 69 } |
| 70 |
| 71 function shouldBeActiveModalDialog(expected) |
| 72 { |
| 73 consoleWrite('the active modal dialog should be: ' + expected.id); |
| 74 expectClick = expected; |
| 75 clickOn(expected); |
| 76 expectClick = document.documentElement; |
| 77 clickOn(inertDiv); |
| 78 } |
| 79 |
| 80 function shouldBeNoModalDialog() |
| 81 { |
| 82 consoleWrite('there should be no modal dialog'); |
| 83 expectClick = inertDiv; |
| 84 clickOn(inertDiv); |
| 85 } |
| 86 |
| 87 document.addEventListener('webkitfullscreenchange', function(e) { |
| 88 if (document.webkitFullscreenElement == bottomDiv) { |
| 89 topDialog.showModal(); |
| 90 makeFullscreen(topDiv); |
| 91 } else if (document.webkitFullscreenElement == topDiv) { |
| 92 // Hide to simplify hit testing on the inert element. |
| 93 bottomDiv.style.display = 'none'; |
| 94 topDiv.style.display = 'none'; |
| 95 |
| 96 shouldBeActiveModalDialog(topDialog); |
| 97 topDialog.close(); |
| 98 shouldBeActiveModalDialog(bottomDialog); |
| 99 bottomDialog.close(); |
| 100 shouldBeNoModalDialog(); |
| 101 endTest(); |
| 102 } |
| 103 }); |
| 104 |
| 105 bottomDialog.showModal(); |
| 106 makeFullscreen(bottomDiv); |
| 107 </script> |
| 108 </body> |
| 109 </html> |
OLD | NEW |