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