OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/protocol-test.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 window.addEventListener("load", function() { | 6 function logActiveElement() { |
7 document.querySelector("#second").addEventListener("focus", onFocus); | 7 var el = document.activeElement; |
8 | 8 log(el ? (el.id || el.tagName) : "(none)"); |
9 function onFocus() { | 9 } |
10 log("focused"); | |
11 } | |
12 }); | |
13 | 10 |
14 function test() | 11 function test() |
15 { | 12 { |
| 13 InspectorTest.sendCommand("Runtime.evaluate", { "expression": "logActiveElem
ent()" }); |
| 14 |
16 InspectorTest.sendCommand("DOM.getDocument", {}, onGotDocument); | 15 InspectorTest.sendCommand("DOM.getDocument", {}, onGotDocument); |
17 | 16 |
18 function onGotDocument(msg) { | 17 function onGotDocument(msg) { |
19 if (msg.error) { | 18 if (msg.error) { |
20 InspectorTest.log(msg.error.message); | 19 InspectorTest.log(msg.error.message); |
21 InspectorTest.completeTest(); | 20 InspectorTest.completeTest(); |
22 return; | 21 return; |
23 } | 22 } |
24 var node = msg.result.root; | 23 var node = msg.result.root; |
25 InspectorTest.sendCommand("DOM.querySelector", { "nodeId": node.nodeId,
"selector": "#second" }, onQuerySelector); | 24 InspectorTest.sendCommand("DOM.querySelector", { "nodeId": node.nodeId,
"selector": "#second" }, onQuerySelector); |
26 } | 25 } |
27 | 26 |
28 function onQuerySelector(msg) { | 27 function onQuerySelector(msg) { |
29 if (msg.error) { | 28 if (msg.error) { |
30 InspectorTest.log(msg.error.message); | 29 InspectorTest.log(msg.error.message); |
31 InspectorTest.completeTest(); | 30 InspectorTest.completeTest(); |
32 return; | 31 return; |
33 } | 32 } |
34 var node = msg.result; | 33 var node = msg.result; |
35 InspectorTest.sendCommand("DOM.focus", { "nodeId": node.nodeId }, onFocu
s); | 34 InspectorTest.sendCommand("DOM.focus", { "nodeId": node.nodeId }, onFocu
s); |
36 } | 35 } |
37 | 36 |
38 function onFocus(msg) { | 37 function onFocus(msg) { |
39 if (msg.error) | 38 if (msg.error) |
40 InspectorTest.log(msg.error); | 39 InspectorTest.log(msg.error); |
| 40 |
| 41 InspectorTest.sendCommand("Runtime.evaluate", { expression: 'logActiveEl
ement()' }); |
41 InspectorTest.completeTest(); | 42 InspectorTest.completeTest(); |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
45 </script> | 46 </script> |
46 </head> | 47 </head> |
47 <body onload="runTest()"> | 48 <body onload="runTest()"> |
48 <input></input> | 49 <input></input> |
49 <input id="second"></input> | 50 <input id="second"></input> |
50 </body> | 51 </body> |
51 </html> | 52 </html> |
OLD | NEW |