Commit 951ddc08 authored by Mason Freed's avatar Mason Freed Committed by aborovova@mozilla.com
Browse files

Bug 1967006 [wpt PR 52610] - Closing interest invoker target popover loses interest,

Automatic update from web-platform-tests
Closing interest invoker target popover loses interest

Since it's possible that the target popover for an interest
invoker (via `interesttarget`) can be closed through other means
such as light dismiss or programmatic `.hidePopover()`, that
should cause a loss of interest. Without this, the UI can get
into an odd state where the target popover is already closed,
yet the invoker still "has interest". To get the popover to
show up again, the invoker needs to be de-hovered *and left
de-hovered for the "hide" delay* so that interest can be lost.
Since that's completely invisible, the user has no way to know
whether it's "done" and the invoker can be re-hovered. With
this change, the UX will be intuitive.

Bug: 364669918
Change-Id: Ifab53af643ffdccfda47524b187255c756b3a106
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6536349
Commit-Queue: Mason Freed <masonf@chromium.org>
Reviewed-by: default avatarJoey Arhar <jarhar@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1461575}

--

wpt-commits: ce2db66a012a77d8b1b948f71a08ab15db6e2cdd
wpt-pr: 52610

Differential Revision: https://phabricator.services.mozilla.com/D250675
parent 882a7534
Loading
Loading
Loading
Loading
+11 −6
Changes for testing/web-platform/tests/html/semantics/the-button-element/interest-target/interesttarget-keyboard-behavior.tentative.html: 11 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -110,9 +110,7 @@ allInterestTargetElements.forEach(el => {

  let events = [];
  function addListeners(t,element) {
    const controller = new AbortController();
    const signal = controller.signal;
    t.add_cleanup(() => controller.abort());
    const signal = t.get_signal();
    element.addEventListener('interest',(e) => events.push(`${e.target.id} interest`),{signal});
    element.addEventListener('loseinterest',(e) => events.push(`${e.target.id} loseinterest`),{signal});
  }
@@ -147,10 +145,16 @@ allInterestTargetElements.forEach(el => {
    await focusOn(el);
    assert_array_equals(events,['target interest'],'setup');
    verifyInterest(el,`After show interest in ${el.id}`);
    target.addEventListener('loseinterest',(e) => e.preventDefault(),{once: true});
    const signal = t.get_signal();
    let shouldCancelLoseInterest = true;
    target.addEventListener('loseinterest',(e) => {
      if (shouldCancelLoseInterest) {
        e.preventDefault();
      }
    },{signal});
    await focusOn(another);
    assert_array_equals(events,['target interest','target loseinterest','anothertarget interest'],
        'the loseinterest listener should fire, and anothertarget should still get interest');
    assert_array_equals(events,['target interest','target loseinterest','anothertarget interest','target loseinterest'],
        'the loseinterest listener should fire but get cancelled, anothertarget should still get interest, and that should close the first target popover firing another loseinterest');
    events = [];
    verifyInterest([el,another],`${el.id} should still have interest because loseinterest was cancelled`);
    assert_false(target.matches(':popover-open'),'anothertarget popover opens, closing target');
@@ -159,6 +163,7 @@ allInterestTargetElements.forEach(el => {
    assert_array_equals(events,['anothertarget loseinterest'],'Lose interest hot key on focused element loses just interest in that element');
    assert_false(target.matches(':popover-open'));
    assert_false(anothertarget.matches(':popover-open'));
    shouldCancelLoseInterest = false;
    await focusOn(el);
    await sendLoseInterestHotkey();
    assert_array_equals(events,['anothertarget loseinterest','target loseinterest'],'Now both lost interest');
+21 −0
Changes for testing/web-platform/tests/html/semantics/the-button-element/interest-target/interesttarget-pseudo-classes.tentative.html: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -174,6 +174,27 @@ promise_test(async (t) => {
  await do_cleanup();
},`Lose interest hotkey works`);

promise_test(async (t) => {
  checkPseudos(invoker,target,false,false,false,false,'initial');
  await focusOn(invoker);
  checkPseudos(invoker,target,true,true,true,true,'focusing invoker shows partial interest');
  invoker.setAttribute('style',`interest-target-delay: 10000s`);
  target.hidePopover();
  checkPseudos(invoker,target,false,false,false,false,'closing the popover loses interest');
  assert_equals(document.activeElement,invoker,'focus does not move');
  await do_cleanup();
},'Closing the target popover loses interest, without any delays (keyboard activation)');

promise_test(async (t) => {
  checkPseudos(invoker,target,false,false,false,false,'initial');
  await hoverOver(invoker);
  checkPseudos(invoker,target,false,true,false,true,'hovering invoker shows full interest (and not partial interest)');
  invoker.setAttribute('style',`interest-target-delay: 10000s`);
  target.hidePopover();
  checkPseudos(invoker,target,false,false,false,false,'closing the popover loses interest');
  await do_cleanup();
},'Closing the target popover loses interest, without any delays (mouse activation)');

const invokerDelayMs = 100; // The CSS delay setting.
const hoverWaitTime = 200; // How long to wait to cover the delay for sure.
promise_test(async (t) => {