diff --git a/html/semantics/forms/autofocus/once-per-document-2.window.js b/html/semantics/forms/autofocus/once-per-document-2.window.js
new file mode 100644
index 00000000000000..41a58213b380a2
--- /dev/null
+++ b/html/semantics/forms/autofocus/once-per-document-2.window.js
@@ -0,0 +1,13 @@
+async_test(t => {
+ const input = document.createElement("input");
+ input.autofocus = true;
+ document.body.appendChild(input);
+ input.remove();
+ const input2 = document.createElement("input");
+ input2.autofocus = true;
+ document.body.appendChild(input2);
+ t.step_timeout(() => {
+ assert_equals(document.activeElement, document.body);
+ t.done();
+ }, 100);
+}, "autofocus should only work for the first inserted element matching the conditions???");
diff --git a/html/semantics/forms/autofocus/once-per-document.window.js b/html/semantics/forms/autofocus/once-per-document.window.js
new file mode 100644
index 00000000000000..9a0b6a09432282
--- /dev/null
+++ b/html/semantics/forms/autofocus/once-per-document.window.js
@@ -0,0 +1,20 @@
+async_test(t => {
+ const input = document.createElement("input");
+ input.autofocus = true;
+ document.body.appendChild(input);
+ t.step_timeout(() => {
+ assert_equals(document.activeElement, input);
+ document.body.appendChild(input);
+ t.step_timeout(() => {
+ assert_equals(document.activeElement, document.body);
+ input.remove();
+ const input2 = document.createElement("input");
+ input2.autofocus = true;
+ document.body.appendChild(input2);
+ t.step_timeout(() => {
+ assert_equals(document.activeElement, document.body);
+ t.done();
+ }, 100)
+ }, 100)
+ }, 100);
+}, "autofocus should work once per document");