From 0aadb83b00d601daa27c609f3ce41defd6614a9f Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Thu, 8 Feb 2018 20:05:28 +0100 Subject: [PATCH] feat(html/editing/focus): New test for inserting element with autofocus --- .../focus-fixup-rule-one-no-dialogs.html | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html b/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html index d8171abc715990..dc150140622473 100644 --- a/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html +++ b/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html @@ -13,6 +13,7 @@
+
Div
editor
@@ -83,6 +84,25 @@ assert_equals(document.activeElement, document.body, "After changing a legend element, the body must be focused"); }, "Changing the first legend element in disabled
"); +async_test(t => { + const button = document.querySelector("#button6"); + button.focus(); + + assert_equals(document.activeElement, button, "Sanity check: the button must start focused"); + + const newButton = document.createElement("button"); + newButton.id = "button7"; + newButton.innerText = "Button 7"; + newButton.autofocus = true; + + button.parentElement.insertBefore(newButton, button.nextElementSibling); + + t.step_timeout(() => { + assert_equals(document.activeElement, newButton, "After inserting a button with autofocus, that button must be focused"); + t.done(); + }); +}, "Inserting a button with autofocus"); + test(() => { const div = document.querySelector("#div"); div.focus();