| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| var outerInput = document.createElement("input"); |
| outerInput.id = "Outer" |
| |
| var input1 = document.createElement("input"); |
| input1.id = "Input1"; |
| var input2 = document.createElement("input"); |
| input2.id = "Input2"; |
| var input3 = document.createElement("input"); |
| input3.id = "Input3"; |
| var input4 = document.createElement("input"); |
| input4.id = "Input4"; |
| |
| UI.inspectorView.element.appendChild(outerInput); |
| |
| var mainWidget = new UI.Widget(); |
| mainWidget.show(UI.inspectorView.element); |
| |
| var widget1 = new UI.Widget(); |
| widget1.show(mainWidget.element); |
| widget1.element.appendChild(input1); |
| widget1.setDefaultFocusedElement(input1); |
| |
| var widget2 = new UI.Widget(); |
| widget2.show(mainWidget.element); |
| widget2.element.appendChild(input2); |
| widget2.setDefaultFocusedElement(input2); |
| |
| InspectorTest.addResult("Focusing outer input..."); |
| outerInput.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing widget1..."); |
| widget1.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing widget2..."); |
| input2.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing outer input again..."); |
| outerInput.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing main widget..."); |
| mainWidget.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing outer input again..."); |
| outerInput.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Hiding widget2 and focusing main widget..."); |
| widget2.hideWidget(); |
| mainWidget.focus(); |
| dumpFocus(); |
| |
| var splitWidget = new UI.SplitWidget(); |
| splitWidget.show(mainWidget.element); |
| |
| var widget3 = new UI.Widget(); |
| widget3.element.appendChild(input3); |
| widget3.setDefaultFocusedElement(input3); |
| splitWidget.setSidebarWidget(widget3); |
| |
| var widget4 = new UI.Widget(); |
| widget4.element.appendChild(input4); |
| widget4.setDefaultFocusedElement(input4); |
| splitWidget.setMainWidget(widget4); |
| splitWidget.setDefaultFocusedChild(widget4); |
| |
| InspectorTest.addResult("Focusing split widget in main that has 3 and 4 inputs..."); |
| splitWidget.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing widget 3..."); |
| widget3.focus(); |
| dumpFocus(); |
| |
| InspectorTest.addResult("Focusing main widget again..."); |
| mainWidget.focus(); |
| dumpFocus(); |
| |
| InspectorTest.completeTest(); |
| |
| function dumpFocus() |
| { |
| var focused = document.deepActiveElement(); |
| var id = focused ? focused.id : ""; |
| InspectorTest.addResult(id ? id + " Focused" : "No focus"); |
| } |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests whether focus is properly remembered on widgets.</p> |
| </body> |
| </html> |