summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/events/mouse-event-retarget.html
blob: c9ce6240d40cc8e877a0c1f8299a2215e50841cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<html>
<title>Script created MouseEvent properly retargets and adjusts offsetX</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
body {
  margin: 8px;
  padding: 0;
}
</style>

<div id="target">Hello</div>

<script>
async_test(t => {
  target.addEventListener('click', ev => {
    t.step(() => assert_equals(ev.offsetX, 42));
    t.done();
  });

  const ev = new MouseEvent('click', { clientX: 50 });
  target.dispatchEvent(ev);
}, "offsetX is correctly adjusted");
</script>