summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/form-control-form-attribute.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/shadow-dom/form-control-form-attribute.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/shadow-dom/form-control-form-attribute.html')
-rw-r--r--testing/web-platform/tests/shadow-dom/form-control-form-attribute.html80
1 files changed, 80 insertions, 0 deletions
diff --git a/testing/web-platform/tests/shadow-dom/form-control-form-attribute.html b/testing/web-platform/tests/shadow-dom/form-control-form-attribute.html
new file mode 100644
index 0000000000..2e782b2587
--- /dev/null
+++ b/testing/web-platform/tests/shadow-dom/form-control-form-attribute.html
@@ -0,0 +1,80 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Form controls' form attribute</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="testcontent">
+ <form id="form">form</form>
+ <input id="input" form="form">
+</div>
+
+<script>
+
+test(() => {
+ assert_equals(document.getElementById('input').form,
+ document.getElementById('form'));
+}, "Form control's form attribute should point to the form element.");
+
+test(() => {
+ var testcontent = document.getElementById("testcontent");
+ var host = document.createElement("div");
+ var sr = host.attachShadow({mode: "open"});
+ sr.innerHTML = testcontent.innerHTML;
+ var input = sr.getElementById("input");
+ var form = sr.getElementById("form");
+
+ // Should have null form when shadow DOM isn't connected.
+ assert_equals(input.form, null);
+
+ testcontent.appendChild(host);
+ assert_equals(input.form, form);
+
+ host.remove();
+ assert_equals(input.form, null);
+
+ testcontent.appendChild(host);
+ assert_equals(input.form, form);
+
+ input.remove();
+ assert_equals(input.form, null);
+
+ sr.appendChild(input);
+ assert_equals(input.form, form);
+
+ form.id = "foobar";
+ assert_equals(input.form, null);
+
+ form.id = "form";
+ assert_equals(input.form, form);
+
+ form.remove();
+ assert_equals(input.form, null);
+
+ sr.appendChild(form);
+ assert_equals(input.form, form);
+
+ host.remove();
+}, "Shadow form control's form attribute should work also in shadow DOM.");
+
+test(() => {
+ var testcontent = document.getElementById("testcontent");
+ var host = document.createElement("div");
+ var sr = host.attachShadow({mode: "open"});
+ sr.innerHTML = "<form id='form'><input id='input'></form>";
+ var input = sr.getElementById("input");
+ var form = sr.getElementById("form");
+
+ assert_equals(input.form, form);
+
+ input.remove();
+ assert_equals(input.form, null);
+
+ form.appendChild(input);
+ assert_equals(input.form, form);
+
+ form.remove();
+ assert_equals(input.form, form);
+
+ host.remove();
+}, "Form element as form control's ancestor should work also in shadow DOM.");
+</script>