<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script>
<body>
<dialog></dialog>
<script>
// https://github.com/whatwg/html/issues/4788
promise_test(async () => {
  const dialog = document.querySelector('dialog');
  dialog.show();
  dialog.close();
  const input = document.createElement('input');
  input.autofocus = true;
  document.body.insertBefore(input, dialog);
  await waitUntilStableAutofocusState();
  assert_not_equals(document.activeElement, input,
      'Non-dialog autofocus processing should be skipped.');
}, 'After showing a dialog, non-dialog autofocus processing won\'t work.');
</script>
</body>
