summaryrefslogtreecommitdiffstats
path: root/dom/html/test/test_bug556645.html
diff options
context:
space:
mode:
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>