<!doctype html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=author href="mailto:japhet@chromium.org">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1312594">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>

<div id='d' style='height: 100px; width: 100px'></div>
<script>
// *not* \uu001B; see https://w3c.github.io/webdriver/#keyboard-actions
const ESC = '\uE00C';

promise_test(async t => {
  let watcher = new CloseWatcher();
  let onclose_called = false;
  watcher.onclose = () => onclose_called = true;

  window.onkeydown = e => e.preventDefault();

  await test_driver.send_keys(document.getElementById('d'), ESC);
  assert_false(onclose_called);
}, "normal event listeners come before CloseWatcher");
</script>
