Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / change-frame-focus.html
blob351bd875d7683784bb95368192ccf4387ef6d019
1 <html>
2 <head>
3 <script>
4 function log(msg)
6 document.getElementById("log").appendChild(
7 document.createTextNode(msg + "\n"));
10 function setFrameHandler(frameId)
12 if (frameId == "") {
13 window.onfocus = function()
15 log("main frame focused.");
18 window.onblur = function()
20 log("main frame blurred.");
22 } else {
23 var frameWin = document.getElementById(frameId).contentWindow;
24 frameWin.onfocus = function()
26 log(frameId + " focused.");
29 frameWin.onblur = function()
31 log(frameId + " blurred.");
36 function setFrameFocus(frameId)
38 if (frameId == "") {
39 window.focus();
40 } else {
41 var frameWin = document.getElementById(frameId).contentWindow;
42 frameWin.focus();
46 function testMainFrameToIFrameFocus()
48 log("\nTest: main frame to iframe.");
49 setFrameFocus("");
50 setFrameFocus("iframe1");
53 function testIFrameToMainFrameFocus()
55 log("\nTest: iframe to main frame.");
56 setFrameFocus("iframe1");
57 setFrameFocus("");
60 function testIFrameToIFrameFocus()
62 log("\nTest: iframe1 to iframe2.");
63 setFrameFocus("iframe1");
64 setFrameFocus("iframe2");
65 setFrameFocus("iframe1");
68 function testFrame1OnBlurSetFrame2Focus()
70 var frameWin1 = document.getElementById("iframe1").contentWindow;
71 frameWin1.onfocus = function()
73 log("iframe1 focused.");
76 frameWin1.onblur = function()
78 log("iframe1 blurred.");
79 // This set focus request will be ignored because the FocusController
80 // is in the middle of changing focused frame.
81 setFrameFocus("iframe2");
84 log("\nTest: iframe1 onblur sets iframe2 focus.");
85 setFrameFocus("");
86 setFrameFocus("iframe1");
87 setFrameFocus("");
90 function testFrame1OnBlurSetFrame1Focus()
92 var frameWin1 = document.getElementById("iframe1").contentWindow;
93 frameWin1.onfocus = function()
95 log("iframe1 focused.");
98 frameWin1.onblur = function()
100 log("iframe1 blurred.");
101 // This set focus request will be ignored because the FocusController
102 // is in the middle of changing focused frame.
103 setFrameFocus("iframe1");
106 log("\nTest: iframe1 onblur sets iframe1 focus.");
107 setFrameFocus("");
108 setFrameFocus("iframe1");
109 setFrameFocus("");
112 function testFrame1OnFocusSetFrame2Focus()
114 var frameWin1 = document.getElementById("iframe1").contentWindow;
115 frameWin1.onfocus = function()
117 log("iframe1 focused.");
118 // This set focus request will be ignored because the FocusController
119 // is in the middle of changing focused frame.
120 setFrameFocus("iframe2");
123 frameWin1.onblur = function()
125 log("iframe1 blurred.");
128 log("\nTest: iframe1 onfocus sets iframe2 focus.");
129 setFrameFocus("");
130 setFrameFocus("iframe1");
133 function testFrame1OnFocusSetFrame1Focus()
135 var frameWin1 = document.getElementById("iframe1").contentWindow;
136 frameWin1.onfocus = function()
138 log("iframe1 focused.");
139 // This set focus request will be ignored because the FocusController
140 // is in the middle of changing focused frame.
141 setFrameFocus("iframe1");
144 frameWin1.onblur = function()
146 log("iframe1 blurred.");
149 log("\nTest: iframe1 onfocus sets iframe1 focus.");
150 setFrameFocus("");
151 setFrameFocus("iframe1");
154 function test()
156 if (window.testRunner) {
157 testRunner.dumpAsText();
160 setFrameHandler("");
161 setFrameHandler("iframe1");
162 setFrameHandler("iframe2");
164 // Test the correct frame is focused when switching focus from
165 // one frame to another.
166 testMainFrameToIFrameFocus();
167 testIFrameToMainFrameFocus();
168 testIFrameToIFrameFocus();
170 // New setting focus request will be ignored if the focus controller
171 // is in the middle of switching focused frame (onblur, onfocus events).
172 testFrame1OnBlurSetFrame2Focus();
173 testFrame1OnBlurSetFrame1Focus();
174 testFrame1OnFocusSetFrame2Focus();
175 testFrame1OnFocusSetFrame1Focus();
177 // Restore iframe1 onfocus and onblur handlers.
178 setFrameHandler("iframe1");
181 </script>
182 </head>
183 <body onload="test()">
184 <iframe id="iframe1" style="width: 100px; height: 100px;"></iframe>
185 <iframe id="iframe2" style="width: 100px; height: 100px;"></iframe>
186 <p>Test the focus controller working properly when switching focused frame. Here are the cases tested:
187 <br>
188 <br>-. Correct frame is focused when switching focus from one frame to another:
189 <br>1. main frame -> iframe
190 <br>2. iframe to main frame
191 <br>3. iframe 1 to iframe 2
192 <br>
193 <br>-. New setting focus request will be ignored if the focus controller is in the middle of switching focused frame (onblur, onfocus events):
194 <br>1. iframe 1 onblur sets iframe 2 focus.
195 <br>2. iframe 1 onblur sets iframe 1 focus.
196 <br>3. iframe 1 onfocus sets iframe 2 focus.
197 <br>4. iframe 1 onfocus sets iframe 1 focus.
198 </p>
199 <pre id="log"></pre>
200 </body>
201 </html>