diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/focus/support/hasfocus-different-site-outer.sub.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
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> |