summaryrefslogtreecommitdiffstats
path: root/dom/html/test/test_bug556645.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/html/test/test_bug556645.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/test_bug556645.html')
-rw-r--r--dom/html/test/test_bug556645.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/dom/html/test/test_bug556645.html b/dom/html/test/test_bug556645.html
new file mode 100644
index 0000000000..3c308f9ef6
--- /dev/null
+++ b/dom/html/test/test_bug556645.html
@@ -0,0 +1,73 @@
+<html>
+<head>
+ <title>Test for Bug 556645 and Bug 1848196</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<script>
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(async () => {
+ const object = document.createElement("object");
+ object.setAttribute("type", "text/html");
+ object.setAttribute("width", "200");
+ object.setAttribute("height", "200");
+ document.body.appendChild(object);
+ const promiseLoadObject = new Promise(resolve => {
+ object.addEventListener("load", resolve, {once: true});
+ });
+ object.setAttribute("data", "object_bug556645.html");
+ await promiseLoadObject;
+ runTest(object);
+ object.remove();
+
+ const embed = document.createElement("embed");
+ embed.setAttribute("type", "text/html");
+ embed.setAttribute("width", "200");
+ embed.setAttribute("height", "200");
+ document.body.appendChild(embed);
+ const promiseLoadEmbed = new Promise(resolve => {
+ embed.addEventListener("load", resolve, {once: true});
+ });
+ embed.setAttribute("src", "object_bug556645.html");
+ await promiseLoadEmbed;
+ runTest(embed);
+ embed.remove();
+
+ SimpleTest.finish();
+});
+
+function runTest(aObjectOrEmbed)
+{
+ const desc = `<${aObjectOrEmbed.tagName.toLowerCase()}>`;
+ const childDoc = aObjectOrEmbed.contentDocument || aObjectOrEmbed.getSVGDocument();
+ const body = childDoc.body;
+ is(document.activeElement, document.body, `${desc}: focus in parent before`);
+ is(childDoc.activeElement, body, `${desc}: focus in child before`);
+
+ const button = childDoc.querySelector("button");
+ button.focus();
+ childDoc.defaultView.focus();
+ is(document.activeElement, aObjectOrEmbed, `${desc}: focus in parent after focus()`);
+ is(childDoc.activeElement, button, `${desc}: focus in child after focus()`);
+
+ button.blur();
+ const pbutton = document.getElementById("pbutton");
+ pbutton.focus();
+
+ synthesizeKey("KEY_Tab");
+ is(document.activeElement, aObjectOrEmbed, `${desc}: focus in parent after tab`);
+ is(childDoc.activeElement, childDoc.documentElement, `${desc}: focus in child after tab`);
+
+ synthesizeKey("KEY_Tab");
+ is(document.activeElement, aObjectOrEmbed, `${desc}: focus in parent after tab 2`);
+ is(childDoc.activeElement, button, `${desc}: focus in child after tab 2`);
+}
+
+</script>
+
+<button id="pbutton">Parent</button>
+
+</body>
+</html>