| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script> | |
| 6 description('Tests inert node focusing across frames and iframes.'); | |
| 7 if (window.testRunner) | |
| 8 testRunner.waitUntilDone(); | |
| 9 </script> | |
| 10 </head> | |
| 11 <iframe height=400 width=600 id="main-iframe"> | |
| 12 <frameset rows="*" cols="50,50"> | |
| 13 <frame src="resources/inert-focus-in-frames-frame1.html"> | |
| 14 <frame src='data:text/html,<div id="frame2-div" class="target" tabindex="0">
Hello</div>'> | |
| 15 </frameset> | |
| 16 </iframe> | |
| 17 <script> | |
| 18 framesLoaded = 0; | |
| 19 numFrames = 4; | |
| 20 | |
| 21 function frameLoaded() { | |
| 22 framesLoaded++; | |
| 23 if (framesLoaded == numFrames) | |
| 24 test(); | |
| 25 } | |
| 26 | |
| 27 function testFocus(element, expectFocus) { | |
| 28 focusedElement = null; | |
| 29 element.addEventListener('focus', function() { focusedElement = element; },
false); | |
| 30 element.focus(); | |
| 31 expected = expectFocus ? "true" : "false" | |
| 32 theElement = element; | |
| 33 shouldBe('"' + element.id + '"; focusedElement === theElement', expected); | |
| 34 } | |
| 35 | |
| 36 function test() { | |
| 37 debug('Opening a modal dialog in frame1. It blocks other nodes in its docume
nt.'); | |
| 38 var frame1 = mainIframe.contentWindow.frames[0].document; | |
| 39 frame1.querySelector('dialog').showModal(); | |
| 40 | |
| 41 testFocus(frame1.querySelector('.target'), false); | |
| 42 var iframe = frame1.querySelector('iframe').contentDocument; | |
| 43 testFocus(iframe.querySelector('.target'), false); | |
| 44 | |
| 45 debug('Even a modal dialog in the iframe is blocked by the modal dialog in t
he parent frame1.'); | |
| 46 iframe.querySelector('dialog').showModal(); | |
| 47 testFocus(iframe.querySelector('button'), false); | |
| 48 | |
| 49 debug('A modal dialog does not block nodes in a sibling frame.'); | |
| 50 var frame2 = mainIframe.contentWindow.frames[1].document; | |
| 51 testFocus(frame2.querySelector('.target'), true); | |
| 52 | |
| 53 debug('Closing the dialog in frame1. The modal dialog in the iframe does not
block nodes in its parent.'); | |
| 54 frame1.querySelector('dialog').close(); | |
| 55 testFocus(iframe.querySelector('.target'), false); | |
| 56 testFocus(frame1.querySelector('.target'), true); | |
| 57 | |
| 58 if (window.testRunner) | |
| 59 testRunner.notifyDone(); | |
| 60 } | |
| 61 | |
| 62 var mainIframe = document.getElementById('main-iframe'); | |
| 63 mainIframe.contentDocument.write(mainIframe.textContent); | |
| 64 mainIframe.contentDocument.close(); | |
| 65 | |
| 66 mainIframe.contentWindow.frames[1].window.onload = frameLoaded; | |
| 67 | |
| 68 window.onload = frameLoaded; | |
| 69 </script> | |
| 70 </body> | |
| 71 </html> | |
| OLD | NEW |