Source code

Revision control

Other Tools

Test Info:

<!DOCTYPE html>
<title>No user activation through 'Escape' key</title>
<meta name="timeout" content="long">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="author" title="Google" href=" "/>
<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>
#target {
width: 40ex;
background-color: yellow;
<script type="text/javascript">
let keydown_event_fired = false;
let keyup_event_fired = false;
function run() {
let textbox_elem = document.getElementById("target");
let test_esc_key = async_test("'Escape' key doesn't activate a page.");
test_esc_key.step(() => {
assert_true(!!navigator.userActivation, "This test requires user activation query API");
on_event(textbox_elem, "keydown", () => {
test_esc_key.step(() => {
keydown_event_fired = true;
assert_false(navigator.userActivation.isActive, "No user activation on keydown");
on_event(textbox_elem, "keyup", () => {
test_esc_key.step(() => {
if (keydown_event_fired)
keyup_event_fired = true;
assert_true(keydown_event_fired, "keydown event fired before keyup");
assert_false(navigator.userActivation.isActive, "No user activation on keyup");
// Inject mouse inputs.
const escape_key = "\uE00C";
.send_keys(textbox_elem, escape_key)
.then(() => {
assert_true(keyup_event_fired, "keydown event fired before keyup");
<body onload="run()">
<h1>No user activation through 'Escape' key</h1>
<h4>Tests that pressing/releasing 'Escape' key is not treated as a user activation.</h4>
<input id="target" value="Press and release the 'Esc' key." />