Debian Codegraph @

testing/web-platform/mozilla/tests/focus/support/iframe-focus-event-after-same-site-iframe-gets-focus-outer.html

raw
1 <!doctype html>
2 <meta charset="utf-8">
3 <title>Iframe focus event after same site iframe gets focus outer</title>
4 <iframe src="iframe-focus-event-after-iframe-gets-focus-inner.html"></iframe>
5 <script>
6 let outerlog = "outerlog:";
7
8 let iframe = document.querySelector("iframe");
9 window.onmessage = function(e) {
10 if (e.data == "start") {
11 window.onfocus = function() {
12 outerlog += "windowfocus,";
13 };
14 } else if (e.data == "iframefocus") {
15 iframe.focus();
16 } else if (e.data == "iframecontentWindowfocus") {
17 iframe.contentWindow.focus();
18 } else if (e.data == "windowfocus") {
19 iframe.contentWindow.postMessage("windowfocus", "*");
20 } else if (e.data == "getlog") {
21 iframe.contentWindow.postMessage("getlog", "*");
22 } else {
23 opener.postMessage(outerlog + e.data, "*");
24 }
25 };
26
27 window.onload = function() {
28 window.onblur = function() {
29 outerlog += "windowblur,";
30 };
31
32 iframe.onfocus = function() {
33 outerlog += "iframefocus,";
34 };
35
36 iframe.onblur = function() {
37 outerlog += "iframeblur,";
38 };
39
40 opener.postMessage("ready", "*");
41 };
42 </script>