blob: eaab77c0eacc01c3517f17bf9ad438950dc048b3 [file] [log] [blame]
<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>