diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html')
-rw-r--r-- | testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html b/testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html new file mode 100644 index 0000000000..bf91adb59e --- /dev/null +++ b/testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>hasFocus() outer</title> +<script> +var w = null; +var hadInitialFocus = false; +var hadLostFocus = false; +window.onmessage = function(e) { + if (e.data == "restored") { + if (hadInitialFocus && hadLostFocus) { + let verdict = document.hasFocus() ? "PASS" : "FAIL: hasFocus false"; + window.opener.postMessage(verdict, "*"); + } else { + window.opener.postMessage("FAIL: should have failed already", "*"); + } + } else if (e.data == "focused") { + w = window.open("hasfocus-other.html"); + } else if (e.data == "noblur") { + window.opener.postMessage("FAIL: no inner blur", "*"); + } else if (e.data == "opened") { + if (document.hasFocus()) { + w.close(); + window.opener.postMessage("FAIL: focus not lost when other window opened", "*"); + } else { + hadLostFocus = true; + window.frames[0].postMessage("hasfocus", "*"); + } + } else if (e.data == "close") { + w.close(); + } else if (e.data == "wrongfocus") { + w.close(); + window.opener.postMessage("FAIL: hasFocus was true in iframe", "*"); + } +} +window.onload = function() { + if (document.hasFocus()) { + hadInitialFocus = true; + window.frames[0].postMessage("focus", "*"); + } else { + window.opener.postMessage("FAIL: did not have initial focus", "*"); + } +} +</script> +</head> +<body> +<iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/focus/support/hasfocus-inner.html"></iframe> +</body> +</html> |