• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<script src="/resources/testharness.js"></script>
3<script src="/resources/testharnessreport.js"></script>
4<!--
5  This test is adopted from Olli Pettay's test case at
6  http://mozilla.pettay.fi/shadow_focus.html
7-->
8<div id="host"></div>
9<input id="lightInput">
10<script>
11const root = host.attachShadow({ mode: "closed" });
12root.innerHTML = "<input id='shadowInput'>";
13
14async_test((test) => {
15  root.getElementById("shadowInput").focus();
16  window.addEventListener("focus", test.step_func_done((e) => {
17    assert_equals(e.relatedTarget, host);
18  }, "relatedTarget should be pointing to shadow host."), true);
19  lightInput.focus();
20}, "relatedTarget should not leak at capturing phase, at window object.");
21
22async_test((test) => {
23  root.getElementById("shadowInput").focus();
24  lightInput.addEventListener("focus", test.step_func_done((e) => {
25    assert_equals(e.relatedTarget, host);
26  }, "relatedTarget should be pointing to shadow host."), true);
27  lightInput.focus();
28}, "relatedTarget should not leak at target.");
29
30</script>
31