testing/web-platform/tests/selection/canvas-click.html
author Sotaro Ikeda <sotaro.ikeda.g@gmail.com>
Thu, 10 Jul 2025 00:10:09 +0000 (6 hours ago)
changeset 795941 23763b72c35abeead04f63e4503c28abc73d065d
parent 792097 b47b552e50ed99ba33e378a7fc3e5ca754b5eb00
permissions -rw-r--r--
Bug 1976135 - Remove nightly only limitation of pref gfx.webrender.layer-compositor r=gfx-reviewers,gw Differential Revision: https://phabricator.services.mozilla.com/D256379
<!doctype html>
<meta charset="utf-8">
<title>Clicking on a text-selectable canvas should not select it</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.com" title="Mozilla">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1969829">
<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>
<style>
  :root { user-select: none }
  canvas {
    user-select: text;
    outline: 2px solid hotpink;
    background-color: green;
    width: 200px;
    height: 200px;
  }
</style>
Clicking the green square should not select it.<br>
<canvas></canvas>
<script>
promise_test(async function() {
  await test_driver.click(document.querySelector("canvas"));
  assert_true(getSelection().isCollapsed, "Clicking a canvas shouldn't generate a non-collapsed selection");
});
</script>