Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
            
- /selection/canvas-click.html - WPT Dashboard Interop Dashboard
 
 
<!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">
<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>