summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/focusable-area-in-top-document.html
blob: 327040eeeeb7da9bf134cb7120b60c7d1e76d5c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>

<iframe srcdoc="<input><script>document.querySelector('input').focus();</script>"></iframe>

<script>
'use strict';

promise_test(async () => {
  await waitForLoad(window);
  let iframe = document.querySelector('iframe');
  assert_equals(document.activeElement, iframe, 'Prereq: IFRAME should be focused');

  let input = document.createElement('input');
  input.autofocus = true;
  document.body.appendChild(input);

  await waitUntilStableAutofocusState();
  assert_equals(document.activeElement, iframe, 'activeElement should not be changed');
  assert_not_equals(document.activeElement, input);
}, 'If topDocument\'s focused area is not topDocument, autofocus is not processed.');
</script>