summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/events/shadow-relatedTarget.html
blob: 713555b7d8ab6117d12c70d08185335246e44e1a (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
27
28
29
30
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
  This test is adopted from Olli Pettay's test case at
  http://mozilla.pettay.fi/shadow_focus.html
-->
<div id="host"></div>
<input id="lightInput">
<script>
const root = host.attachShadow({ mode: "closed" });
root.innerHTML = "<input id='shadowInput'>";

async_test((test) => {
  root.getElementById("shadowInput").focus();
  window.addEventListener("focus", test.step_func_done((e) => {
    assert_equals(e.relatedTarget, host);
  }, "relatedTarget should be pointing to shadow host."), true);
  lightInput.focus();
}, "relatedTarget should not leak at capturing phase, at window object.");

async_test((test) => {
  root.getElementById("shadowInput").focus();
  lightInput.addEventListener("focus", test.step_func_done((e) => {
    assert_equals(e.relatedTarget, host);
  }, "relatedTarget should be pointing to shadow host."), true);
  lightInput.focus();
}, "relatedTarget should not leak at target.");

</script>