<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Iframe focus event inner document</title>
</head>
<body>
<h1>Inner</h1>
<script>
let innerlog = "innerlog:";

window.onmessage = function(e) {
  if (e.data == "windowfocus") {
    innerlog += "willfocuswindow,";
    window.focus();
    innerlog += "didfocuswindow,";
  } else if (e.data == "getlog") {
    parent.postMessage(innerlog, "*");
  }
};

window.onfocus = function() {
  innerlog += "windowfocus,";
};

window.onblur = function() {
  innerlog += "windowblur,";
};
</script>
</body>
</html>
