summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/first-reconnected.html
blob: 99ee9198d1b0a39605ee7115ba71b1178e815943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>

<input autofocus id="i1">
<input autofocus id="i2">
<script>
"use strict";

promise_test(async () => {
  const input1 = document.querySelector("#i1");
  const input2 = document.querySelector("#i2");
  input1.remove();
  input2.parentNode.insertBefore(input1, input2);

  await waitUntilStableAutofocusState();
  assert_equals(document.activeElement, input2);
}, 'The second autofocus element wins if the first autofocus element was ' +
   'disconnected and reconnected before flushing the autofocus candidates.');
</script>