4 <script src=
"../../../resources/js-test.js"></script>
6 description('Tests inert node focusing across frames and iframes.');
8 testRunner
.waitUntilDone();
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>'
>
21 function frameLoaded() {
23 if (framesLoaded
== numFrames
)
27 function testFocus(element
, expectFocus
) {
28 focusedElement
= null;
29 element
.addEventListener('focus', function() { focusedElement
= element
; }, false);
31 expected
= expectFocus
? "true" : "false"
33 shouldBe('"' + element
.id
+ '"; focusedElement === theElement', expected
);
37 debug('Opening a modal dialog in frame1. It blocks other nodes in its document.');
38 var frame1
= mainIframe
.contentWindow
.frames
[0].document
;
39 frame1
.querySelector('dialog').showModal();
41 testFocus(frame1
.querySelector('.target'), false);
42 var iframe
= frame1
.querySelector('iframe').contentDocument
;
43 testFocus(iframe
.querySelector('.target'), false);
45 debug('Even a modal dialog in the iframe is blocked by the modal dialog in the parent frame1.');
46 iframe
.querySelector('dialog').showModal();
47 testFocus(iframe
.querySelector('button'), false);
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);
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);
58 if (window
.testRunner
)
59 testRunner
.notifyDone();
62 var mainIframe
= document
.getElementById('main-iframe');
63 mainIframe
.contentDocument
.write(mainIframe
.textContent
);
64 mainIframe
.contentDocument
.close();
66 mainIframe
.contentWindow
.frames
[1].window
.onload
= frameLoaded
;
68 window
.onload
= frameLoaded
;