60 lines
1.5 KiB
HTML
60 lines
1.5 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
|
|
<script>
|
|
|
|
function focusListener()
|
|
{
|
|
log("focused");
|
|
}
|
|
|
|
window.addEventListener("load", function() {
|
|
document.querySelector("#second").addEventListener("focus", focusListener);
|
|
});
|
|
|
|
function removeFocusListener()
|
|
{
|
|
document.querySelector("#second").removeEventListener("focus", focusListener);
|
|
}
|
|
|
|
function test()
|
|
{
|
|
InspectorProtocol.sendCommand("DOM.getDocument", {}, onGotDocument);
|
|
|
|
function onGotDocument(msg) {
|
|
if (msg.error) {
|
|
ProtocolTest.log(msg.error.message);
|
|
ProtocolTest.completeTest();
|
|
return;
|
|
}
|
|
var node = msg.result.root;
|
|
InspectorProtocol.sendCommand("DOM.querySelector", { "nodeId": node.nodeId, "selector": "#second" }, onQuerySelector);
|
|
}
|
|
|
|
function onQuerySelector(msg) {
|
|
if (msg.error) {
|
|
ProtocolTest.log(msg.error.message);
|
|
ProtocolTest.completeTest();
|
|
return;
|
|
}
|
|
var node = msg.result;
|
|
InspectorProtocol.sendCommand("DOM.focus", { "nodeId": node.nodeId }, onFocus);
|
|
}
|
|
|
|
function onFocus(msg) {
|
|
if (msg.error)
|
|
ProtocolTest.log(msg.error);
|
|
ProtocolTest.evaluateInPage("removeFocusListener()")
|
|
.then(() => {
|
|
ProtocolTest.completeTest();
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="runTest()">
|
|
<input></input>
|
|
<input id="second"></input>
|
|
</body>
|
|
</html>
|