summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/popovers/popover-change-type.html
blob: 978d1d149568c5f0340767a313cb59632d676dfd (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
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/issues/9034">
<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>
<script src="/resources/testdriver-actions.js"></script>
<script src="/html/semantics/popovers/resources/popover-utils.js"></script>

<div id=mypopover>popover</div>

<script>
promise_test(async () => {
  const mypopover = document.getElementById('mypopover');

  mypopover.popover = "manual";
  mypopover.showPopover();

  await new Promise(resolve => {
    mypopover.addEventListener("beforetoggle", (e) => {
      if (e.newState === "closed") {
        mypopover.remove();
        requestAnimationFrame(() => {
          document.body.append(mypopover);
          mypopover.showPopover();
          resolve();
        });
      }
    }, {once: true});

    mypopover.popover = "auto";
  });

  assert_true(mypopover.matches(':popover-open'),
    'The popover should be open after the toggling sequence.');

  await sendEscape();
  assert_false(mypopover.matches(':popover-open'),
    'The popover should light dismiss because it is in the auto state.');
}, 'Changing the popover attribute should always update the auto/manual behavior.');
</script>