<!DOCTYPE html>
<html>
<head>
<script src="./result_queue.js"></script>
<script>
var resultQueue = new ResultQueue();
function focusInputField() {
var inputField = document.getElementById("text-field");
inputField.focus();
return resultQueue.pop();
}
function getInputFieldText() {
var inputField = document.getElementById("text-field");
return inputField.value;
}
async function waitForBlur() {
while (true) {
const result = await resultQueue.pop();
if (result == "input-blur") {
return true;
}
}
}
async function waitForInput() {
while (true) {
const result = await resultQueue.pop();
if (result != "input-focus" && result != "input-blur") {
return result;
}
}
}
function onInputFocus() {
resultQueue.push("input-focus");
}
function onInputBlur() {
resultQueue.push("input-blur");
}
</script>
</head>
<body>
This page has a cross-site iframe and a text input field.
<input type='text' id='text-field'
onfocus="onInputFocus()" onblur="onInputBlur()"
style="width: 120px;height: 20px;"><br>
<iframe id='subframe' src="/cross-site/b.com/page_with_blur.html"></iframe>
</body>
</html>