| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 function test() | 6 function test() |
| 7 { | 7 { |
| 8 var outerInput = document.createElement("input"); | 8 var outerInput = document.createElement("input"); |
| 9 outerInput.id = "Outer" |
| 10 |
| 11 var input1 = document.createElement("input"); |
| 12 input1.id = "Input1"; |
| 13 var input2 = document.createElement("input"); |
| 14 input2.id = "Input2"; |
| 15 var input3 = document.createElement("input"); |
| 16 input3.id = "Input3"; |
| 17 var input4 = document.createElement("input"); |
| 18 input4.id = "Input4"; |
| 19 |
| 9 UI.inspectorView.element.appendChild(outerInput); | 20 UI.inspectorView.element.appendChild(outerInput); |
| 10 | 21 |
| 11 var mainWidget = new UI.Widget(); | 22 var mainWidget = new UI.Widget(); |
| 12 mainWidget.show(UI.inspectorView.element); | 23 mainWidget.show(UI.inspectorView.element); |
| 13 | 24 |
| 14 var widget1 = new UI.Widget(); | 25 var widget1 = new UI.Widget(); |
| 15 widget1.show(mainWidget.element); | 26 widget1.show(mainWidget.element); |
| 16 var input1 = document.createElement("input"); | |
| 17 input1.id = "input1"; | |
| 18 widget1.element.appendChild(input1); | 27 widget1.element.appendChild(input1); |
| 19 widget1.setDefaultFocusedElement(input1); | 28 widget1.setDefaultFocusedElement(input1); |
| 20 | 29 |
| 21 var widget2 = new UI.Widget(); | 30 var widget2 = new UI.Widget(); |
| 22 widget2.show(mainWidget.element); | 31 widget2.show(mainWidget.element); |
| 23 var input2 = document.createElement("input"); | |
| 24 input2.id = "input2"; | |
| 25 widget2.element.appendChild(input2); | 32 widget2.element.appendChild(input2); |
| 26 widget2.setDefaultFocusedElement(input2); | 33 widget2.setDefaultFocusedElement(input2); |
| 27 | 34 |
| 35 InspectorTest.addResult("Focusing outer input..."); |
| 28 outerInput.focus(); | 36 outerInput.focus(); |
| 29 dumpFocus(); | 37 dumpFocus(); |
| 30 | 38 |
| 39 InspectorTest.addResult("Focusing widget1..."); |
| 31 widget1.focus(); | 40 widget1.focus(); |
| 32 dumpFocus(); | 41 dumpFocus(); |
| 33 | 42 |
| 43 InspectorTest.addResult("Focusing widget2..."); |
| 34 input2.focus(); | 44 input2.focus(); |
| 35 dumpFocus(); | 45 dumpFocus(); |
| 36 | 46 |
| 47 InspectorTest.addResult("Focusing outer input again..."); |
| 37 outerInput.focus(); | 48 outerInput.focus(); |
| 38 dumpFocus(); | 49 dumpFocus(); |
| 39 | 50 |
| 51 InspectorTest.addResult("Focusing main widget..."); |
| 40 mainWidget.focus(); | 52 mainWidget.focus(); |
| 41 dumpFocus(); | 53 dumpFocus(); |
| 42 | 54 |
| 55 InspectorTest.addResult("Focusing outer input again..."); |
| 43 outerInput.focus(); | 56 outerInput.focus(); |
| 44 dumpFocus(); | 57 dumpFocus(); |
| 45 | 58 |
| 59 InspectorTest.addResult("Hiding widget2 and focusing main widget..."); |
| 46 widget2.hideWidget(); | 60 widget2.hideWidget(); |
| 47 mainWidget.focus(); | 61 mainWidget.focus(); |
| 48 dumpFocus(); | 62 dumpFocus(); |
| 49 | 63 |
| 50 var splitWidget = new UI.SplitWidget(); | 64 var splitWidget = new UI.SplitWidget(); |
| 51 splitWidget.show(mainWidget.element); | 65 splitWidget.show(mainWidget.element); |
| 66 |
| 52 var widget3 = new UI.Widget(); | 67 var widget3 = new UI.Widget(); |
| 53 var input3 = document.createElement("input"); | |
| 54 input1.id = "input3"; | |
| 55 widget3.element.appendChild(input3); | 68 widget3.element.appendChild(input3); |
| 56 widget3.setDefaultFocusedElement(input3); | 69 widget3.setDefaultFocusedElement(input3); |
| 57 splitWidget.setSidebarWidget(widget3); | 70 splitWidget.setSidebarWidget(widget3); |
| 71 |
| 58 var widget4 = new UI.Widget(); | 72 var widget4 = new UI.Widget(); |
| 59 var input4 = document.createElement("input"); | |
| 60 input4.id = "input4"; | |
| 61 widget4.element.appendChild(input4); | 73 widget4.element.appendChild(input4); |
| 62 widget4.setDefaultFocusedElement(input4); | 74 widget4.setDefaultFocusedElement(input4); |
| 63 splitWidget.setMainWidget(widget4); | 75 splitWidget.setMainWidget(widget4); |
| 76 splitWidget.setDefaultFocusedChild(widget4); |
| 64 | 77 |
| 78 InspectorTest.addResult("Focusing split widget in main that has 3 and 4 inpu
ts..."); |
| 65 splitWidget.focus(); | 79 splitWidget.focus(); |
| 66 dumpFocus(); | 80 dumpFocus(); |
| 67 | 81 |
| 82 InspectorTest.addResult("Focusing widget 3..."); |
| 68 widget3.focus(); | 83 widget3.focus(); |
| 69 dumpFocus(); | 84 dumpFocus(); |
| 70 | 85 |
| 86 InspectorTest.addResult("Focusing main widget again..."); |
| 71 mainWidget.focus(); | 87 mainWidget.focus(); |
| 72 dumpFocus(); | 88 dumpFocus(); |
| 73 | 89 |
| 74 InspectorTest.completeTest(); | 90 InspectorTest.completeTest(); |
| 75 | 91 |
| 76 function dumpFocus() | 92 function dumpFocus() |
| 77 { | 93 { |
| 78 var focused = document.deepActiveElement(); | 94 var focused = document.deepActiveElement(); |
| 79 if (focused === outerInput) { | 95 var id = focused ? focused.id : ""; |
| 80 InspectorTest.addResult("Outer Focused"); | 96 InspectorTest.addResult(id ? id + " Focused" : "No focus"); |
| 81 } else if (focused === input1) { | |
| 82 InspectorTest.addResult("Input1 Focused"); | |
| 83 } else if (focused === input2) { | |
| 84 InspectorTest.addResult("Input2 Focused"); | |
| 85 } else if (focused === input3) { | |
| 86 InspectorTest.addResult("Input3 Focused"); | |
| 87 } else if (focused === input4) { | |
| 88 InspectorTest.addResult("Input4 Focused"); | |
| 89 } else { | |
| 90 InspectorTest.addResult("No focus"); | |
| 91 } | |
| 92 } | 97 } |
| 93 } | 98 } |
| 94 </script> | 99 </script> |
| 95 </head> | 100 </head> |
| 96 <body onload="runTest()"> | 101 <body onload="runTest()"> |
| 97 <p>Tests whether focus is properly remembered on widgets.</p> | 102 <p>Tests whether focus is properly remembered on widgets.</p> |
| 98 </body> | 103 </body> |
| 99 </html> | 104 </html> |
| OLD | NEW |